>>>psion/opl 3204 tdenson(471)16Oct96 19:32
Oddity with KEY$
Can anyone tell mewhat's going on with the code below -

DO
K$=KEY$
IF K$<>"" :PRINT ASC(K$) :ENDIF
UNTIL 0

If I type normal ascii characters it's fine and prints the 
appropriate code, however if I give it cursor keys (which are assigned 
codes 256,257,258,259 for U,D,R,L respectively) then R & L give 2 and 
3, but Down arrow gives two codes of 257 and 1, and Up arrow gives 
nothing. I'm actually trying to check for the user typing up arrow.

Tony

>>>psion/opl 3207 spooley(435)16Oct96 23:20 c3204*
The cursor keys return character codes 256, 257, 258 and 259.
These values can not be represented as string characters, so you'll have to 
use KEY to read them as integers, rather than K$

        LOCAL k%
        DO
          k% = KEY
          IF k% <> 0 :PRINT k% :ENDIF
        UNTIL 0
        
Having eliminated cursor or other 'special' keys, if you need the key as a 
string for other parts of your program you can use CHR$(k%)

>>>psion/opl 3220 tsteven(166)17Oct96 20:43
TITLE: Calendar?
Can anybody tell me how I can call up a calendar and or calculator in
an app! i.e Like Agenda does when you press Tab.

Rgds Tony.
(Via ReadCiX 4.9)

>>>psion/opl 3222 richardcox(154)18Oct96 11:36 c3220*
The calendar stuff is in "FORM" oo library on the 3a... and should be 
accessible from OPL but IMHO you are going to need the docs...
------- 
Richard

>>>psion/opl 3223 gryalls(232)18Oct96 12:43 c3220*
I have found that if you define a date input field in a dialog box, the 
tab/calendar works just as in Agenda.

Perhaps someone else can say whether it is possible to jump to the 
calendar without having to call the dialog.
Gavin

>>>psion/opl 3225 psion_c(409)18Oct96 15:20 c3222*
Hello
It is unlikely that you could make use of this object in an OPL program 
as the object makes certain assumptions which don't hold true for OPL. 
I tried to provide access to this functionality in a vanilla (i.e. 
non-OO) C program and fell at the first fence.

This does not mean that you definitely can't do it (people are doing 
things with OPL today which were thought unlikely).

All the best
Ali

>>>psion/opl 3241 jezar(260)21Oct96 09:51 c3225*
You can use the calwin stuff if you write a program based around 
appman.OPL but otherwise it would be too hard to use because part of the 
active code is driven by redraw messages.

You might be able to use some of the calender imaging stuff though.
Jezar.

>>>psion/opl 3265 chennings(1010)26Oct96 11:05 c3223*
This is because the dialog services have done / will do much of what is 
necessary. Key points on using the CALWIN class from HWIF/OPL

a) Needs to be enclosed within an AM_START / AM_STOP pairing.

b) You can't use the CALWIN class directly because of the way it handles 
the transition between 1/3/12 month views (ie on TAB). CALWIN expects to 
be owned by another object and records the handle of this in one of it's 
properties. When a size transition occurs, CALWIN 1st creates a new 
instance of a CALWIN in the appropriate view and sets the owner of the new 
instance to be that of the current. The current instance then destroys 
itself. This means that CALWIN generally has to be contained rather than 
sub-classed (CALWIN is essentially sui/infanti-cidal).

All this boils down to as Ali says - CALWIN can't be used directly (even 
in HWIM) but on the other hand it's pretty simple to make a .DYL that 
provides these services to OPL and this is what MarkE does in say NotePad.

Rgds
Chris Hennings

>>>psion/opl 3298 chennings(964)4Nov96 22:55 c3294*
>? Eh? - surely you mean HWIF? It must be possible to use it from HWIM 
>otherwise no-one would be able to use it at all..

True. I guess I blurred 2 separate points:

a) CALWIN can't be used *directly* from HWIF/OPL as say a C_VASTR might be 
'cos of the AM stuff.

b) The HWIM issue is that CALWIN is not really suitable for subclassing 
(unless you're on for completely replacing WN_KEY) - a point I must have 
missed in the documentation(!) Suppose you start (in all good faith) with 
an instance of a subclass C_MYCALWIN. When a 1/3/12 month view transition 
occurs and is handled by the parent class WN_KEY, the fact that we're a 
subclass is ignored and the new view is always created as C_CALWIN - 
that's what I meant by it being infanticidal. Having the properties and 
methods associated with your sub-class whipped from underneath you in this 
way is ... interesting. Once you know what's going on work rounds are not 
a problem.

Rgds
Chris Hennings

>>>psion/opl 3229 mcockerell(1553)19Oct96 08:43 c3194*
This OPL app will display the labels for a .dbf file:

APP dbflabel
TYPE $1004
PATH "\dat"
EXT "dbf"
ENDA
PROC dbflabel:
  LOCAL info%(4),len%,ptr%,header%
  LOCAL ax%,bx%,cx%,dx%,si%,di%
  rem 
  rem Open DBF file
  rem
  OPEN CMD$(2),A,f1$,f2$
  rem 
  rem Get DBF info
  rem
  ODBINFO info%()
  rem 
  rem DBF Handle
  rem
  bx%=PEEKW(info%(1))
  rem 
  rem Read Descriptive Record
  rem
  ax%=$1700
  OS($D8,ADDR(ax%))
  rem 
  rem Length of record returned in AX
  rem
  len%=ax%
  rem 
  rem Get pointer to start of record
  rem (skip 2 byte header)
  rem
  ptr%=UADD(PEEKW(UADD(info%(1),8)),2)
  rem 
  rem Loop until end of record
  rem
  WHILE len%
    rem
    rem Get header of next descriptive
    rem record field. Top nibble is field
    rem type, rest is field length
    rem
    header%=PEEKW(ptr%)
    rem
    rem labels are in type 4 fields
    rem
    IF header%/$1000=4
      len%=header% AND $FFF
      rem
      rem point to first field name
      rem
      ptr%=UADD(ptr%,2)
      WHILE len%
        rem
        rem Print label
        rem
        PRINT PEEK$(ptr%)
        rem
        rem Advance to next label
        rem
        len%=len%-PEEKB(ptr%)-1
        ptr%=UADD(ptr%,PEEKB(ptr%)+1)
      ENDWH
      GET
      STOP
    ELSE
      rem
      rem Skip to next field in descriptive
      rem record
      rem
      len%=len%-(header% AND $FFF)-2
      ptr%=UADD(ptr%,(header% AND $FFF)+2)
    ENDIF
  ENDWH
ENDP

I claim no credit for it - I copied it from somewhere !
Hope it gives you what you need,
Martin Cockerell


>>>psion/opl 3274 hzk(932)29Oct96 17:12
3a/3c detection
It has dawned on me that some of my OPL comms programs will not work on a
3c, because they check for the presence of drive LOC::C:, then close the
link if it is running, etc.  Presumably drive LOC::C: doesn't exist on a 3c!

The reason I check for the presence of the 3-Link lead is because some early 
3a's will lock up their serial port if you LOPEN("TTY:A") when it's not 
plugged in.

I assume that on a 3c the serial port is always ready to be opened, so this 
problem will not arise anyway.  But I need to check whether the machine 
hosting my program is a 3a or 3c.  So can anyone tell me the correct file 
name for the IRDA driver in the 3c ROM please!

The next problem may be that the 3c is set for IR comms!  Perhaps I should 
just do a TRAP LOPEN("TTY:A") and see if I get an error.  I wonder what error 
message the 3c will give in the case of the IR comms setting?

Any comments very welcome!
Roger

>>>psion/opl 3280 rovoreed(230)30Oct96 08:05 c3276*

Your supposed to enquire of the Window Server which version it is.
I suppose you could always call p_romversion() ($2A) or p_version() 
($00) from the General Manager $8B if you want to do it in OPL.

Mike Davies

>>>psion/opl 3288 tsteven(223)31Oct96 18:47 c3274*
It's not exactly what you want but this is how I detected whether it
it a 3c or not:

Local psion$(2)
If exist ("ROM::IR.WVE")
Psion$=3c
else
Psion$=3a
endif

Not exactly perfect, but it works!

Rgds Tony
(Via ReadCiX 4.9)

>>>psion/opl 3296 jezar(248)4Nov96 10:23 c3274*
Checking for LOC::C isn't a good way to see if the link cable is plugged 
in. If PsiWin is running and link turned on, sys$tycl.pdd will make drive 
C: vanish - so you'll assume the cable is unplugged when it's actually 
very much in use.

Jezar.

>>>psion/opl 3304 hzk(359)5Nov96 18:49 c3296*
Yes, that's another reason to change the way I have done it in the past.  
The program was started before PsiWin became available, so originally 
checking for C: seemed foolproof.

At the moment I just do a TRAP LOPEN("TTY:A").
If I get an error code of -40 the program turns off the LINK, if anything 
else it gracefully terminates after an ALERT.  

Roger

>>>psion/opl 3314 fit(177)7Nov96 16:05
Setting ERR=0 after using TRAP
After using a TRAP command, how do you set ERR back to 0?
(I am using TRAP OPEN <database file> , because the file may already be 
open)
Dave

>>>psion/opl 3317 hzk(505)7Nov96 20:53 c3314*
Well, you can do a TRAP <something> which will always set ERR to zero.
Like:

TRAP OPEN "file",A,a$,b$
IF ERR = -40   REM file in use
        REM any error handling here...
        TRAP USE A   REM returns ERR = 0
ENDIF

This assumes that your program always opens this file as logical name A.  Otherwise 
something like TRAP FIRST will set ERR to zero.
Otherwise arrange your code so that ERR is checked only after the TRAP command which 
sets ERR to a value.  If you see what I mean...
Roger

>>>psion/opl 3318 ple(75)7Nov96 23:23 c3314*
To clear the last ERR value - use:

POKEW PEEKW($1c)+$16,0
Cheers, Leigh

>>>psion/opl 3332 jezar(440)11Nov96 09:10 c3318*
Oooeerr..... 

Best avoided really. Peeking/poking should always be a last resort.
As I say, it should be possible to arrange the code so that clearing of 
ERR isn't required. The fact that this doesn't seem to be the case makes 
me a tad suspicious of the structure of the code.

However, if you *must* clear ERR for some odd reason, it's probably best 
to do this:

    ONERR ErrClear :RAISE 0
    ErrClear:: ONERR OFF

Regards,
Jezar.

>>>psion/opl 3342 ple(96)12Nov96 14:57 c3332*
The little ERR clearing gem I posted came from the OPL SDK, so I assumed 
it was approved (-8
Leigh

>>>psion/opl 3316 hzk(626)7Nov96 20:01
OPL COPY command
Here's a curious one:

If I COPY src$,dest$  the destination file is 'stamped' with the current date 
and time, not the originals as you might expect.

The file selector COPY does preserve the original data, though.

Any thoughts on this?  It's easy enough to restore the original date 
stamp, although it's a few lines of OPL and a couple of CALLS.

(While trying this out, I accidentally substituted the FilStatusSet 
subfunction number for the FilSetFileDate numbers - oops!  Had to format 
the internal drive to clear the mess that resulted!  Just as well I backed 
up an hour before this!)

Roger

>>>psion/opl 3334 fit(397)11Nov96 09:47 c3331*
The program uses data files.
If you shut the program down _from_the_System_Screen_, then these data 
files stay open - the files get closed if you shut the program from 
inside the program.

When you start the program up again, an error occurs because the program 
is trying to open data files that are already open.

That is why I've been using TRAP, in order to get round this problem.
Dave

>>>psion/opl 3338 hzk(727)11Nov96 22:18 c3334*
Ah. It should be easy to restructure your code to detect the shutdown signal 
from the system screen.

What you need to do is to use a GETEVENT function to pause your program when 
waiting for key presses. You should always use event detection in an OPA 
rather than a GET etc. An event of value $404 means a system screen shutdown 
message has been received:

DO
  GETEVENT e%()
  IF e%(1)=$404
        shutdown:   REM go to proc which shuts down your app.
  ELSEIF e%(1)=.... REM keys you are looking for
        REM         REM action associated with key above
  ENDIF
UNTIL 0

There is an example on page 113 (Example OPAs) in my programming manual. 
It also shows how to detect file changes from the system screen.
Roger

>>>psion/opl 3350 jezar(1427)18Nov96 09:57 c3346*
The List view in the S3c is based on a new GRID class in the ROM. 
Although it's possible to use this from OPL, you'd need to be very 
experienced to do so - and in any case, that would restrict your code to 
running only on the S3c and not on Series 3a machines.

There's no "special technique" to writing your own - just do the obvious 
thing that comes to mind - go round a loop of some kind, retrieving 
records from your file, and then splat them onto the screen according to 
the position in the loop. You use the same calculation to position the 
highlight. When the user attempts to navigate off the screen, instead of 
redrawing the whole screen, you use the gSCROLL command to move the 
display, and then render your next record into the gap left behind. You 
need to work hard to make sure that this part of the code doesn't get 
messy and unmanageable.

The tricky bit is making it work properly with zoom. To do a neat job, 
you should write it so that it *doesn't* clear the screen first when 
updated, but instead, it draws to every pixel on the screen. This gives 
you smooth looking graphics when the user zooms in/out or changes the 
size of the status window (yes, you need to think about what happens when 
the user changes the status window too! :-)

So it's definately not a trivial task (if you intend to do it well), but 
it's an interesting task that teaches you a lot along the way.

Regards,
Jezar.

>>>psion/opl 3374 sboswell(870)30Nov96 18:26
Title: Help
Help
I need help with the Help compiler / displayer in Helpkit1.zip in the
flist.
It all works fine but..

I'm writing a front end for the compiler to tie everything together
(Editor, Compiler, Viewer) and I keep getting file or device in use
errors.
It happens the second time round the Edit->Compile->Preview loop, it
looks like when the help file is previewed the RSC file is opened
and then not closed again when you finish. The compiler then falls
over when trying to replace the file.

How do I force the help system to release the RSC file?

I tried opening another help file but it appears not to release
the first help file, I just get two locked files!

I could translate the previewer as a seperate module and have my program
launch it but I really want to have a single file App.

Any help would be much appreciated
_
(_
 _)tevie B {ENTP}

>>>psion/opl 3378 spooley(397)1Dec96 10:26 c3374*
I tried something similar and had exactly the same problem...like you it 
seems to me that the
        SEND(gate%, 27, help filename)
        SEND(gate%, 26, etc)
sequence from Jezar's help toolkit to load the help file needs to be undone 
to free-up the resource that is loaded.  I've tried looking through the old 
(S3-vintage) SDK documentation that I have but haven't found anything relevent.

>>>psion/opl 3382 sboswell(227)2Dec96 12:44 c3378*
O_GT_SET_RSCFILE (27) doesn't appear to return a handle and none of the
other availble gate classes seem to offer the freeing of an RSC so it looks
like the two file method is gonna have to do. Shame
_
(_
 _)tevie B {ENTP}

>>>psion/opl 3384 richardcox(944)2Dec96 16:31 c3374*
> How do I force the help system to release the RSC file?

Given GATE is designed for OPL/HWIF apps to access some of the HWIM 
functionality and HWIM apps only have one resource file (which is opened on 
start up)[1]. 

If you can get access to the application manager object, it holds the handle 
of the resource file. One of the "magic statics" on the process should have 
its handle[2], and from there it should be possible to close and reload the 
resource file. But, this will almost certainly be rather dubious breaking of 
the application framework; and need a lot of information from the C SDK files 
to workout the layout of the various objects that make up the core of a HWIM 
application.

[1] OK, and the system resource file.
[2] w_am is the handle of the application manager. w_am->appman.rcb is the 
handle of a RSCFILE object. The RS_INIT method of RSCFILE is passed the name 
of the resource file to open.

------- 
Richard

>>>psion/opl 3400 hzk(911)8Dec96 17:13
Launching custom aliases
I have a problem.

While it is easy enough to launch a file inside one of the rom based WORD 
aliases (OPL editor, SCR editor, text editor) from OPL, I cannot seem to 
launch a file run from a 'custom' alias held on a local drive.

What I am trying to do is to launch an OPP file inside the OPP editor 
alias OPP.ALS.  The code I use to launch an OPL file in its editor is as 
follows:

appname$="OProgram"
alias$=" OROPO"
prgname$="ROM::WORD.APP"+CHR$(0)
cmdline$=appname$+CHR$(0)+alias$+CHR$(0)+file$+CHR$(0)
r%=CALL($0187,UADD(ADDR(prgname$),1),ADDR(cmdline$),0,0,ADDR(pid%))
IF r%<0
        ALERT("Cannot Start "+prgname$,"Cause: "+ERR$(r%))
ELSE
        CALL($0688,pid%)
ENDIF

I have tried changing appname$ to "OM:\APP\OPP", and als$ to " PROPO" but 
then it does not use the pre-processor, and flags up syntax error for 
defines, etc.

Has anyone any idea how to do it?
Roger

>>>psion/opl 3402 hzk(179)10Dec96 00:07 c3400*
Got a bit further - set alias$ to ".OPP PROPO*" which now runs the 
correct "translator" SYS$PRGP.  But it dumps the OPO file in the \OPP 
directory?All mysterious stuff!
Roger

>>>psion/opl 3426 cebab(407)12Jan97 21:20
Reading Directory entries, etc. dirctly from memory.
Can anybody please tell me where and how I can directly read (peek) 
the directory entries held by the Series 3a/3c machines and what bit 
stream I can expect to find and what it means? Also, where is the 
User information stored - it seems to exist in a number of places.

For example where does the root diectory start?
Andrew
http://www.ceb.co.uk

>>>psion/opl 3435 psion_c(2443)16Jan97 13:23 c3426*
>Can anybody please tell me where and how I can directly read (peek) 
>the directory entries held by the Series 3a/3c machines and what bit 
>stream I can expect to find and what it means?

The PEEK command allows you access to your own data segment and, as you 
might expect, the filing system on one of the devices isn't in your data 
segment so you can't practically do this. Indeed, a filing system isn't 
really in memory at all.

You don't nneed to get your hands dirty to do this kind of stuff. The 
OPL command DIR$() does a perfect job of this.

>Also, where is the User information stored - it seems to exist in a 
>number of places.

It is stored in an environment variable and you can use the following 
code to read it:

 /* The following OPL code extracts the owners information from the
   environment variable in which it is stored ($WS_WP) into a string
   (here called buff$). The format of the resulting string is as
   follows:

The environment variable is called $WS_WP

18 byte header made up of:

first 2 bytes = always $00
next sixteen bytes = 4 * 4 byte groups:

first is horizontal inset= always $06
second is length of line of text
third and fourth together are byte offset in the whole variable

The procedure only returns the contents of the user information.
To SET the environment variable, make up the buffer as described
above and then use 'CALL' with 'GenEnvBufferSet' and the        
        appropriate parameters:

The parameters for GenEnvBufferSet are:

ES:DIPointer to environment variable name
DLLength of environment variable 
name
ES:SIPointer to the buffer containing 
variables data
CLLength of the data as ES:SI

Return:Carry clear
Success
:Carry set
NoMemoryErr
No space available to store variable
FailErr
Name contains wildcards
Panic:
PanicEnv0
DL exceeded MaxEnvNameSize

Copyright Psion U.K. Plc. 1992.
*/
#define GeneralManager$008b
#define GenEnvBufferGet$2100
#define GenEnvBufferSet$2200

PROC user:

LOCAL ax%,bx%,cx%,dx%,si%,di%
LOCAL flags%

LOCAL env$(6),penv%,lenenv%
LOCAL buff$(255),pbuff%,lenbuff%

env$    = "$WS_PW"
penv%   = ADDR(env$) + 1
lenenv% = LEN(env$)

pbuff% = ADDR(buff$) + 1

ax% = GenEnvBufferGet
bx% = 0
di% = penv%
dx% = lenenv%
si% = pbuff%

flags% = OS(GeneralManager,ADDR(ax%))

IF flags% AND 1
PRINT "An error has occurred",ax% OR $ff00
PRINT ERR$(ax% OR $ff00)
GET
STOP
ELSE
lenbuff% = ax%
POKEB ADDR(buff$),lenbuff%
GET
ENDIF
ENDP

All the best
Ali

>>>psion/opl 3430 tsteven(535)14Jan97 07:04
TITLE: Name from file!
Could someone please show me, with opl, how I can extract the name of
a file from a complete filename.
i.e How do I extract the word "Home" from: Loc::m:\dat\home.dbf
I don't want to use MID$, because for what I have in mind I will not
know what the name of the file will be! So I will not know how long
the string has to be. (I know a max of 8, but that doesn't help much.)
Please do not say use PARSE$, because I know that much, but I do not
how to actually make it work.
TIA
Rgds Tony
(Via ReadCiX 4.9c & 3c)

>>>psion/opl 3431 hem(321)14Jan97 11:57 c3430*
At a guess:
For filename with extension

proc getfile$:(fullname$)
local filename$(12),off%(6)
return mid$(parse$(fullname$,"",off%()),off%(4),12)
endp

For filename without extension

proc getfile$:(fullname$)
local filename$(12),off%(6)
return mid$(parse$(fullname$,"",off%()),off%(4),off%(5)-off%(4)-1)
endp
ANDREW

>>>psion/opl 3433 gryalls(602)15Jan97 22:59 c3430*
>How do I extract the word "Home" from: Loc::m:\dat\home.dbf

Seems to me that the problem cannot be resolved without knowing, or being 
able to derive, the length of "Loc::m:\dat\". Since this is presumably a 
variable it becomes key.

A long winded method might be to search the string for the period in the 
file name:

path$="Loc::m:\dat\home.dbf"
i%=0
do
  i%=i%+1
  x$=mid$(path$,i%,1)
until x$="."

Then count back along the string to find the last sub-directory mark:

i2%=i%
do
  i2%=i2%-1
  x$=mid$(path$,i%,1)
until x$="\"

The word "home" should then be

mid$(path$,i2%+1,i%-i2%-1)

Gavin

>>>psion/opl 3434 richardcox(124)16Jan97 10:37 c3433*
PARSE$ is a lot easier than all that.
The final parameter gives the offsets of the various components.
------- 
Richard

>>>psion/opl 3436 psion_c(498)16Jan97 13:23 c3430*
>Could someone please show me, with opl, how I can extract the name of
>a file from a complete filename.
>i.e How do I extract the word "Home" from: Loc::m:\dat\home.dbf
>I don't want to use MID$, because for what I have in mind I will not
>know what the name of the file will be!

Use PARSE$ and then MID$. PARSE$ will tell you the start of all of the 
components of a fully specified file name: filing system; device; path; 
name; and extension as well as flags for wildcards.

All the best
Ali

>>>psion/opl 3438 hzk(297)16Jan97 22:56 c3433*
You can easily do a reverse search on a string, like:

        pos%=CALL($5cb5,0,0,0,UADD(ADDR(string$),1))

which will locate the right-most character $5C (backslash) in string$.
This is sometimes useful for extracting parts of strings.  But PARSE$ is 
magic when you get the hang of it.
Roger


>>>psion/opl 3448 csljohns(433)3Feb97 23:45
OPL to access the serial port
Hi
I want to read data (ascii) from the serial port on my 3a -
but I also want to be able to send ascii data to the serial
port and not lose any that may be inbound.  And I want to
be monitoring the serial port for inbound when I press the
keys to send stuff out of the serial port.

The LOPEN TTY commands will do one of these at a time- but I'm guessing
I need to know hard-sums to do all this?
Carl

>>>psion/opl 3455 hzk(364)5Feb97 20:09 c3448*
It's not too difficult to do this using async commands like IOC, IOA.

I wrote a skeleton terminal program for someone recently, with a fair bit 
of commenting.  It may not be what you want, but illustrates one way of 
dealing with serial port IO.  It's about a 160 line OPL file (mostly 
comments), I can post it here if no-one object, or mail it to you.
Roger

>>>psion/opl 3457 csljohns(325)6Feb97 21:04 c3455*
Yes please.
If no one else squeeks could you email/binmail it
If they do, perhaps to the flist - but soonish if poss.

I have managed to get the port being read ok, and can send the
odd word back, but I lose the odd character and the whole thing
locks up now and again which is less than ideal (or even useful
really)

Carl

>>>psion/opl 3460 perseus(442)7Feb97 10:48 c3457*
Two things to be very careful of (amongst many) are that you should make 
sure that handshaking is set correctly on both machines, otherwise one 
false move and communications drops dead.

Secondly, and one which you might otherwise spend hours of time trying to 
sort out, is that the length byte passed in IOA/IOC/IOW has to remain in 
existance for the whole time that a read/write is outstanding.  Otherwise 
again, comms stands still.

>>>psion/opl 3462 csljohns(386)9Feb97 18:13 c3460*
> false move and communications drops dead.

:-)
I used to have a phrase taped to the top of my PCW (8bit CP/M)
'If it still isn't working it is something to do with XON/XOFF'
Always was. 

> sort out, is that the length byte passed in IOA/IOC/IOW has to remain 
Oh yes. I can see how that might disrupt things :-)
Thanks.  It's coming along now - slowly, but there you are.

Carl

>>>psion/opl 3782 chrontec(853)3Jun97 10:56
The dreaded serial port
I'm trying to write a grim little utility to display whatever is received 
on my 3c's serial port.  Using the sparse example in Psion's programming 
manual, I can read and display information received with a terminator, 
but as soon as I want to read the input byte-by-byte, I hit trouble.  I 
need to be able to start off an async read, then be able to check the 
keyboard and the async read status until something happens.

The Psion book rather patronisingly tells me that I need to be an OPL 
expert to understand the IO calls - funny, I thought I bought the book to 
understand such things.

Does anyone have an example of bytewise reading, or any advice on the 
serial driver implementation?  Or am I just being a bit hopeful that the 
3c will be able to keep up with 9600 baud input and display anyway?

TIA,
Martin

>>>psion/opl 3783 jezar(48)3Jun97 13:12 c3782*
Try my OPL.ZIP from the flist. (see \JEZAR - on disk LE)

Regards,
Jezar

>>>psion/opl 3794 hzk(442)4Jun97 20:36 c3786*
> On the 3a serial comms really eats up 
> CPU time and on top of the performance of OPL this could be a problem.

If the data is not continuous this need not be the case. With async IO the 
program simply stops when nothing is being received or sent. But reading 
one character at a time is not the fastest way of getting your data. I 
just grab as much incoming data as I can, and sort it out after it has 
been read into a buffer.
Roger

>>>psion/opl 3798 psion_c(1352)5Jun97 18:01 c3782*
>The dreaded serial port

Why "dreaded" ?

Schematically, here is the normal approach. In this case, I have used 
pseudo-code and am using a serial read and a timeout. You could 
change the timer for a key read (KEYA) easily or, if necessary, just 
add the KEYA as another event source.

The actual code should be self-evident but, if not, mail me back 
(ali-manson@psion.com):

queue a timer (IOC on TIM:)
queue a serial read (IOC on TTY:)
DO
{
IOWAIT
IF (timer completed i.e. timeout)
{
cancel serial read
IOWAITSTAT(SerStat)
take timeout-related action
break
}
ELSEIF (serial read completed)
{
cancel timer
IOWAITSTAT(TimStat)
take success-related action
break
}
ELSE
panic - stray signal
ENDIF
}
UNTIL 0

In the case of the serial completing successfully the appropriate action 
might be to save data to a file and then requeue the read. In your case, 
that might be to print the key to the screen and then requeue another 
key (using wGetEvent() once more) like this:

queue a timer
queue a serial read
DO
{
IOWAIT
IF (timer completed i.e. timeout)
{
cancel serial read
IOWAITSTAT(SerStat)
take timeout-related action (probably report error)
break
}
ELSEIF (serial read completed)
{
cancel timer
IOWAITSTAT(TimStat)
take success-related action
requeue a timer
requeue a serial read
break
}
ELSE
panic - stray signal
ENDIF
}
UNTIL 0

regards
Ali

>>>psion/opl 3799 psion_c(1592)5Jun97 18:01 c3791*
>I set up an asynchronous read, and then try to check the status in a 
>loop together with looking at the keyboard.  This does not work, nor 
>does a similar IOC loop.

Polling in a loop in a killer for you or your customer's batteries and 
will create an unresponsive application. Schematically, here is the 
normal approach. In this case, I have used 
pseudo-code and am using a serial read and a timeout. You could 
change the timer for a key read (KEYA) easily or, if necessary, just 
add the KEYA as another event source.

The actual code should be self-evident but, if not, mail me back 
(ali-manson@psion.com):

queue a timer (IOC on TIM:)
queue a serial read (IOC on TTY:)
DO
{
IOWAIT
IF (timer completed i.e. timeout)
{
cancel serial read
IOWAITSTAT(SerStat)
take timeout-related action
break
}
ELSEIF (serial read completed)
{
cancel timer
IOWAITSTAT(TimStat)
take success-related action
break
}
ELSE
panic - stray signal
ENDIF
}
UNTIL 0

In the case of the serial completing successfully the appropriate action 
might be to save data to a file and then requeue the read. In your case, 
that might be to print the key to the screen and then requeue another 
key (using wGetEvent() once more) like this:

queue a timer
queue a serial read
DO
{
IOWAIT
IF (timer completed i.e. timeout)
{
cancel serial read
IOWAITSTAT(SerStat)
take timeout-related action (probably report error)
break
}
ELSEIF (serial read completed)
{
cancel timer
IOWAITSTAT(TimStat)
take success-related action
requeue a timer
requeue a serial read
break
}
ELSE
panic - stray signal
ENDIF
}
UNTIL 0

regards
Ali

>>>psion/opl 3800 hzk(5134)5Jun97 23:28 c3793*
I've just knocked this together, it is basically a simple ascii terminal 
which reads one byte at a time from the serial port, and sends each 
keypress to the serial port. I have arrived at this code by judiciously 
editing something else, so it is only a skeleton.

Basically you set up a loop, and queue a serial port read (for one byte), 
and an event read. The latter will read a keypress or a system event (like 
shut down from system screen).after the IOWAIT you check in turn for a 
serial character arrival, or an 'event'. Since you check both each time, 
there should be no need for IOSIGNAL. I check the status of each IO 
function before doing anything else, to ensure I have only one read and 
one write waiting to return at any time.

On my original code I used independent GLOBAL status flags for each IOA 
function. This was to ensure that I did not miss anything that returned 
during some other computation, and thus queue two IOA's for the same 
event. I have removed that code in this example, but it's worth checking 
with SPY that you are not missing completions.

Note that as this example reads/writes one byte at a time, I have used 
integer variables to store the characters. Even if you want to read more 
than one character at a time, it's still best to queue a read for one 
character, and then use IOW(-1,10,c%,#0) to find out how many more 
characters are waiting. You can then read them synchronously, knowing that 
the IOW will return immediately.

At the least, this example will show how fast OPL works at reading and 
writing one character at a time. Note that key presses will be shown only 
if the remote device echoes them back.

Apologies for any errors.... (I've not seen Jezars file either!)

Roger.

REM Very simple async terminal which reads single bytes.
REM you can test this with Windows terminal or similar.

PROC terminal:
        GLOBAL k%(2),buf%
        GLOBAL sfg%,ser%,evnt%
        LOCAL ret%,c%

        TRAP LOPEN("TTY:A")
        IF ERR=-40
                ret%=ALERT("Link in use.")
                STOP  REM close link code not present!
        ELSEIF ERR<>0
                ret%=ALERT("Serial Port problem:",ERR$(ERR))
                STOP
        ENDIF

        set232:(15,0,8,0)  REM 9600, no parity, 8bit, RTS/CTS
        PRINT "Press Psion-X to quit."
        
        DO

                REM If no serial read is oustanding,
                REM queue an async read for 1 byte.
                IF ser%=0
                        c%=1
                        IOA(-1,1,ser%,buf%,c%)
                ENDIF

                REM If no event read is outstanding,
                REM set up an async read for one keyboard or system event.
                REM This is an async version of GETEVENT.
                IF evnt%=0
                        IOA(-2,14,evnt%,k%(1),#0)
                ENDIF

                IOWAIT  REM wait for a serial, keyboard, or system event.

                REM ser% will remain at -46 until a byte has been received.
                REM So if it is not -46, at least one byte received.
                IF ser%<>-46
                        PRINT CHR$(buf%);
                ENDIF

                REM Now check if any keyboard or system events have been 
received.

                IF evnt%<>-46  REM not -46, therefore something has 
happened.                       IF k%(1)=$404  REM shutdown from system 
screen.                         REM put tidy up code here.
                                LCLOSE
                                STOP
                        ELSEIF k%(1)>512  REM Psion+key command pressed
                                REM deal with command here like next line:
                                docmd:(k%(1)-512)
                        ELSEIF k%(1)<$400  REM normal key (or shifted or 
control) pressed.                               REM deal with keypress 
here...                         REM IOCANCEL(-1) might be needed.
                                IF sfg%<>-46  REM If it's not -46, we can 
send another byte.                                      c%=1
                                        IOA(-1,2,sfg%,k%(1),c%) : rem send 
byte to RS232                           ELSE
                                        REM last character not sent yet...
                                        BEEP 1,1000
                                        gIPRINT "TX  Error!"
                                ENDIF
                        ENDIF
                ENDIF
                
        UNTIL 0
ENDP

PROC set232:(baud%,parity%,data%,hand%)
        REM This procedure from Programming Manual
        REM Sets up RS232 port.
        LOCAL srchar%(6),dummy%,r%,frame%
        frame%=data%-5
        IF parity% :frame%=frame% OR 32 :ENDIF
        srchar%(1)=baud% OR (baud%*256)
        srchar%(2)=frame% OR (parity%*256)
        srchar%(3)=(hand% AND 255) OR $1100
        srchar%(4)=$13
        IOW(-1,7,srchar%(1),dummy%)
ENDP

PROC docmd:(comd%)
        REM Deals with Psion modified keys...
        IF comd%=%x
                LCLOSE
                STOP
        ENDIF
ENDP

***************** End **********************


>>>psion/opl 3463 msvassie(332)14Feb97 17:18
TITLE: OPL FONT QUERY
Can anyone help.  Is is possible in OPL using the PRINT command to
have two lines of text displayed in different fonts?
I have tried the following:
        FONT 12
        PRINT "HELLO"
        FONT 4
        PRINT "GOODBYE"
but the font command seems to clear the screen.
Suggestions appreciated

Martin V.

>>>psion/opl 3465 rbenno(129)16Feb97 11:20 c3463*
It seems the text window can only display one font at a time.
Create a graphics window and use gFONT, gAT, gPRINT ect.
Richard

>>>psion/opl 3467 allsorts(341)20Feb97 23:11
Probably bordering on and FAQ but how does one get the system settings for
date and time out of the system for use in your own OPL program? dDate
formats the date as per those settings but there is no command that I can see
that simply returns a correctly formated date or time string given secs since
1970 or days since 1900.

Cheers
Dave.

>>>psion/opl 3468 rick(92)21Feb97 11:28 c3467*
You want to look at DATIM$ or the SECOND, MINUTE, HOUR, DAY, MONTH,
and YEAR OPL commands.

>>>psion/opl 3469 ple(97)21Feb97 15:49 c3467*
d$=DATIM$ is one way
see also:
SECOND, MINUTE, HOUR, DAY, MONTH, YEAR, WEEK etc etc
Cheers,PLE

>>>psion/opl 3474 allsorts(231)21Feb97 23:40 c3469*
How does DATIM$ give you anything but the curent system date/time?

I want to get the date format (DD/MM/YYYY etc) and the separator so I can
display varibale date data stored in my program as per the system setting.

Cheers
Dave.

>>>psion/opl 3475 ple(8998)22Feb97 13:52 c3474*
Ok here's everything I can find on the subject - apologies for the info 
dump.

Subj:  dDATE help                       Section: Psion Programming
  To:  Michael Molloy, 71703,543        Thursday, 15 August, 1996 8:40:03
AM
From:  Michel Sabatier, 100071,1014     #233864

Michael

The date which come out of the ddate function is in days since 1/1/1900.
If you are interested I have written a procedure to transform this date in
a string in the "DD/MM/YY" format. See below (with no prejudice
obviously).

Michel

proc daydate$:(a&) Rem days from 1/1/1900 in string
  local b&,yy%,mm%,dd%,hh%,mn%,ss%
  local anjr%,d$(8),dd$(2),mm$(2),yy$(2)
  b&=((a&-days(1,1,1970))*86400)
  secstodate b&,yy%,mm%,dd%,hh%,mn%,ss%,anjr%
  if yy%<2000
    yy%=yy%-1900
  else
    yy%=yy%-2000
  endif
  if yy%>9
    yy$=gen$(yy%,-2)
  else
    yy$="0"+gen$(yy%,-1)
  endif
  if mm%>9
    mm$=gen$(mm%,-2)
  else
    mm$="0"+gen$(mm%,-1)
  endif
  if dd%>9
    dd$=gen$(dd%,-2)
  else
   dd$="0"+gen$(dd%,-1)
  endif
  d$=dd$+"/"+mm$+"/"+yy$
  return d$
endp

****************************************************
Now calculating the date from the Long value
****************************************************
Subj:  Dates                            Section: Psion Programming
  To:  Chris Nicholson, 100522,2324     Tuesday, 03 September, 1996
7:17:27 PM
From:  Mark Esposito (SYSOP), 72662,3050#238624

Chris,

    >> I know how to convert it into a string variable but not how to
calculate the date from the 5 figure number that it gives ? <<

 ----------------------------
 Proc showdate:
 local date&
 local yr%,mn%,dy%,hr%,mi%,sc%,yd%

 date&=days(day,month,year)    REM gets todays date in days() format
 date&=(date&-25567)*86400     REM convert to seconds

 secstodate date&,yr%,mn%,dy%,hr%,mi%,sc%,yd%    REM convert seconds to
date
 

 print right$("00"+fix$(dy%,0,2),2)+"."+right$("00"+fix$(mn%,0,2),2)+"."+right$(fix$(y r%,0,4),2)
 pause 40
 Endp
 
 -----------------------------

You can also use a system service to get the users date format, and date
separators.

 Hope this helps.  -Mark Esposito

**********************************************************
Here is some code to get the date and time formatting info.
************************************************************
/*      procedure to return the type of clock set       

        Author  DP      2/11/92

        The procedure uses a call to GenGetCountryData
        which returns a structure listed below.  The 27th byte
        of the structure is the clock type, it returns
        0 Analog
        1 Digital

        Given the structure included below it is possible to change
        the procedure to return any or all of the values.

CDataEnt struc
CDataCountryCode                dw      ?
CDataGmtOffset                  dw      ?
CDataDateType                   db      ?
CDataTimeType                   db      ?
CDataCurrencySymbolPosition     db      ?
CDataCurrencySpaceRequired      db      ?
CDataCurrencyDecimalPlaces      db      ?
CDataCurrencyNegativeInBrackets db      ?
CDataCurrencyTriadsAllowed      db      ?
CDataThousandsSeparator         db      ?
CDataDecimalSeparator           db      ?
CDataDateSeparator              db      ?
CDataTimeSeparator              db      ?
CDataCurrencySymbol             db      9 dup(?)
CDataStartOfWeek                db      ?
CDataSummerTime                 db      ?
CDataClockType                  db      ?
CDataDayAbbreviation            db      ?
CDataMonthAbbreviation          db      ?
CDataWorkDays                   db      ?
CDataUnits                      db      ?
CDataSpare                      db      9 dup(?)
CDataEnt ends
                                                         */
proc clock:

        LOCAL   buf$(40)        /*   40 byte buffer to return structure   
 */          
        LOCAL   clock%          /*   return the value of the clock type   
 */
        
        call($058b,(addr(buf$)+1))      /*   Call GenGetCountryData       
 */

        pokeb addr(buf$),40             /*   poke the length of the 
buffer */
        clock% = peekb(addr(buf$)+27)      
        print clock%                    /*   return the clock type        
 */
        get
ENDP

*******************************
Here's a more explicit example.
*******************************

*/ The Following is to get certain system information from a Series 3
   to allow the programmer to make his apps use the same info as the
   Standard Series 3 apps. /* 
PROC tgetctd:
  local c%(20)
  getctd:(addr(c%()))
  print "Country code",c%(1)
  print "GMT offset",c%(2)
  print "Date type",peekb(addr(c%(3)))
  print "Time type",peekb(addr(c%(3))+1)
  print "Currency symbol position",peekb(addr(c%(4)))
  print "Currency symbol space required",peekb(addr(c%(4))+1)
  print "Currency decimal places",peekb(addr(c%(5)))
  print "Currency negative in brackets",peekb(addr(c%(5))+1)
  get
  print "Separate thousands",peekb(addr(c%(6)))
  print "Thousands separator",chr$(peekb(addr(c%(6))+1))
  print "Decimal separator",chr$(peekb(addr(c%(7))))
  print "Date separator",chr$(peekb(addr(c%(7))+1))
  print "Time separator",chr$(peekb(addr(c%(8))))
  print "Currency symbol",
  prints:(addr(c%(8))+1)
  print "Start of week",peekb(addr(c%(13)))
  get
  print "Summer times",peekb(addr(c%(13))+1)
  print "Clock type",peekb(addr(c%(14)))
  print "Day abbreviation",peekb(addr(c%(14))+1)
  print "Month abbreviation",peekb(addr(c%(15)))
  print "Work days",peekb(addr(c%(15))+1)
  print "Units",peekb(addr(c%(16)))
  get
ENDP

PROC getctd:(bx%)
REM Writes copy of E_CONFIG struct to *bx%
REM bx% must point to buffer at least 40 bytes long
  call($058b,bx%,0,0,0,0)
ENDP

PROC prints:(buf%)
REM Prints ZTS pointed to by buf%
REM This routine assumes length<=64
  local mess$(64)
  scpy:(addr(mess$)+1,buf%)
  pokeb addr(mess$),slen%:(buf%)
  print mess$
ENDP

PROC scpy:(di%,si%)
REM Copies ZTS from si% to di%
  call($ac,0,0,0,si%,di%)
ENDP

PROC slen%:(di%)
REM Returns length of ZTS at di%
  return call($b9,0,0,0,0,di%)
ENDP

********************************************************************
Here is an app with some conversion routines and other relevant data.
*********************************************************************

REM TIME2.OPL by Mark Emery / Psion Tech Support.
REM A time and date setting program based on source
REM code supplied by Psion Technical Support Team.
REM Changes made: Shorten some variables, make some
REM variables ints.

REM Remove this APP header if you dont want to create
REM an application.

APP time2
ICON "\opd\time2.pic"
ENDA

PROC time:
GLOBAL AM12HR%
GLOBAL PM12HR%
GLOBAL T24HR%
LOCAL er%

        AM12HR%=1
        PM12HR%=2
        T24HR%=4

        PRINT "Setting time."

REM Change this line to show the correct time.

        er%=ossettm%:(13,25,00,T24HR%)

        IF er% < 0
                PRINT "Error =",er%
                GET
                STOP
        ENDIF
        
        PRINT "Setting Date."

REM Change this line to show the correct date.

        er%=ossetdt%:(17,1,1992)

        IF er% < 0
                PRINT "Error =",er%
                GET
                STOP
        ENDIF
        
        PRINT "Done"
        GET
ENDP

PROC ossettm%:(hh%,mm%,ss%,md%)
LOCAL hr%

        IF md%<AM12HR% OR md%>T24HR% OR hh%<0 OR mm%<0 OR SS%<0
                RETURN -2
        ENDIF
        hr%=hh%
        IF (md%=AM12HR% OR md%=PM12HR%)
                IF (hr%<1 OR hr%>12)
                        RETURN -2
                ELSEIF md% = AM12HR% AND hr%=12
                        hr%=0
                ELSEIF md%=PM12HR% AND hr%<>12
                        hr%=hr%+12
                ENDIF
        ELSEIF md%=T24HR% AND hr%>23
                RETURN -2
        ENDIF
        IF mm%<=59 AND SS%<=59
                RETURN setdttm%:(DAY,MONTH,YEAR,hr%,mm%,ss%)
        ENDIF
        RETURN -2
ENDP

PROC ossetdt%:(dd%,mm%,yyyy%)
        RETURN setdttm%:(dd%,mm%,yyyy%,HOUR,MINUTE,SECOND)
ENDP

PROC setdttm%:(day%,month%,year%,hr%,min%,sec%)
LOCAL ax%,bx%,cx%,dx%,si%,di%
LOCAL sec&
        IF year%>=1970
                onerr e::

REM Calculate the number of seconds elapsed between 00:00 on 1st Jan 1970.

        sec&=((days(day%,month%,year%)-25567)*86400) + 
(hr%*&e10+min%*60+sec%)

REM Psions comment to the above. /* seconds since 01/01/1970 00:00:00
REM 25567 = days (01/01/1970) 86400 = seconds in a day (24*60*60)
REM &e10 = 3600 (seconds in an hour) */

REM Put MS Word into cx, LS word into dx and "TimSetSystem" value into
REM dx. TimSetSystem is function 3 of TimManager.

                cx%=peekw(addr(sec&)+2)
                dx%=peekw(addr(sec&))
                ax%=$0300

REM $89 = TimManager interrupt - no flags returned

                os($89,addr(ax%))

                RETURN 0
        ENDIF

REM Jump here if error.

        e::
        ONERR OFF
        RETURN -2
ENDP
*********************************
Hope that lot helps, Cheers Leigh
*********************************

>>>psion/opl 3494 allsorts(1204)24Feb97 21:54 c3475*
Brilliant.
It's all buried in there somewhere.  B-)
Many thanks.

<later>
Yep, here are two small routines required to return a date string formated to
the system settings.

Obviously you need to call Csetup: before Day$: and you feed Day$ with the
number of days since 1/1/1900, as returned by the built in DAYS() command.

Easyly tweakable to use the other data supplied from the CALL $058B. See
previous message with the full layout of buf$.

  GLOBAL Datesep$(1),Datefmt%

PROC Csetup:
  LOCAL buf$(40)
  CALL($058B,(addr(buf$)+1))
  POKEB addr(buf$),40
  Datesep$ = chr$(peekb(addr(buf$)+14))
  Datefmt% = peekb(addr(buf$)+5)
ENDP

PROC Day$:(d&)
  LOCAL yr%,mo%,dy%,hr%,mn%,sc%,yrday%
  LOCAL yr$(4),mo$(2),dy$(2)
  SECSTODATE (d&-INT(25567))*INT(86400),yr%,mo%,dy%,hr%,mn%,sc%,yrday%
  yr$=GEN$(yr%,-4)
  mo$=GEN$(mo%,-2)
  dy$=GEN$(dy%,-2)
  If LEFT$(mo$,1)=" "
    mo$="0"+RIGHT$(mo$,1)
  ENDIF
  If LEFT$(dy$,1)=" "
    dy$="0"+RIGHT$(dy$,1)
  ENDIF
  IF Datefmt% = 0
    RETURN mo$+Datesep$+dy$+Datesep$+yr$
  ELSEIF Datefmt% = 1
    RETURN dy$+Datesep$+mo$+Datesep$+yr$
  ELSEIF Datefmt% = 2
    RETURN yr$+Datesep$+mo$+Datesep$+dy$
  ELSE
    RETURN "? Datefmt"
  ENDIF
ENDP

Cheers
Dave.

>>>psion/opl 3486 hzk(528)23Feb97 18:20 c3474*
The separator stored by the system can be read using the system call 
GenGetCountryData, which is CALL($058b, etc....
Offset 13 in the 40 byte buffer.

You can read the rest in OPL.  Assuming the separator is stored in a 
variable called sep$...

LOCAL buf%(20),sep$(1)
CALL($058b,ADDR(buf%()),0,0,0)
sep$=CHR$(PEEKB(ADDR(buf%())+13))

IF DAY < 10
        PRINT 0;        REM adds leading zero
ENDIF
PRINT DAY; sep$;
IF MONTH < 10
        PRINT 0;        REM adds leading zero
ENDIF
PRINT MONTH; sep$;
PRINT YEAR

Cheers
Roger

>>>psion/opl 3470 jjohnson(304)21Feb97 19:09
Printing from 3a
Eventually got round to write a program to print off reports from the db. 
However, the formatting is non existant.
Is there anyway I can print something on the lines of;
PRINT "Name:" n$

where Name: is in bold, but n$ is not bold
I am printing direct reports to the printer
cheers
jon

>>>psion/opl 3472 mavc(215)21Feb97 21:43 c3470*
Yes, usually there is. Look in your printer manual at the use of escape 
sequences. If you bury escape sequences in your OPL print statements 
you can usually turn bold on and off, set italic, condensed etc.

Mark

>>>psion/opl 3471 robfitz(255)21Feb97 20:42
Please help a thicky !
I've got a text file from a pc that has one 'record' per line,
what I want to do is read it in one line at a time and put the text from 
each line into elements of an array.
Prob is I havent got a clue where to start

..... Rob

>>>psion/opl 3484 hzk(2466)23Feb97 18:20 c3471*
Here's a bit of code I extracted from another program. There may be the 
odd superfluous variable, and I may have deleted something essential (I 
don't think so), as I have just edited on the PC and not tested the code 
:-(

It will read a line at a time from a text file, and put them into a string 
array. The maximum line length is set by b% to 100 characters, and if a 
line of text is longer than this, it is truncated to the first 100, the 
rest of the line being discarded. The temp$ is really superfluous, you can 
read the line directly into the array element, but using temp$ makes 
things a little clearer. You may also want to trim surplus characters from 
within temp$, e.g. if there are leading/trailing spaces, etc.

Remember that an OPL string can hold a maximum of 255 characters. If your 
lines are longer than this, you could use an integer buffer instead of 
temp$, like temp%(250) would hold up to 500 characters. You would then 
have to add a lot more code to interpret this buffer, and reduce it to a 
255 character (or less) string.

Roger

PROC read:(name$)
        GLOBAL temp$(255),array$(20,100)
        LOCAL hand%,bytes%,max%,r%,mode%,index%
        
        mode%=$20       REM read mode for text file
        index%=1        REM first element of array
        max%=100        REM maximum read is 100 characters

        r% = IOOPEN(hand%,name$,mode%)
        IF r% <> 0
                ALERT("Cannot Open "+name$,"Cause: "+ERR$(r%))
                RETURN
        ENDIF

        WHILE 1
                bytes%=IOREAD(hand%,UADD(ADDR(temp$),1),max%)
                IF bytes%=-43           REM record is too long
                        bytes%=100      REM read first 100 characters and
                                        REM discard the rest.
                ENDIF

                IF bytes%<0     REM EOF or error?
                        IF bytes%=-36   REM EOF (End of file)
                                GET     REM wait for key press
                        ELSE    REM not EOF - i.e. another error
                                Alert("Cannot Read "+name$,"Cause: "+ERR$(ERR))
                        ENDIF
                        BREAK
                ELSE
                        POKEB ADDR(temp$),bytes%
                        array$(index%)=temp$    REM store line in array
                        index%=index%+1         REM increment array index
                ENDIF
        ENDWH

        IOCLOSE(hand%)
ENDP

>>>psion/opl 3492 robfitz(233)24Feb97 09:46 c3471*
Panic Mode On !!!
I've just had a horrible thought, when ive stuck all of my elements in the 
array together the resulting string will be longer than 255 chars. 

Tell me ive got this wrong and it will all be alright :-(

..... Rob

>>>psion/opl 3493 twagstaff(266)24Feb97 17:46 c3492*
>Tell me ive got this wrong and it will all be alright :-(

Get longlist.zip from the CIX flist. It shows how to build very big 
dChoice lists.
I'm doing lots of this at the mo, building big dChoice lists from 
dbf files, so ask here or mail me if you need help.
Tony

>>>psion/opl 3489 twagstaff(965)23Feb97 18:33 c3479*
Is this what you want:

#define MAX_TXT_LENGTH 255
PROC ioread:
LOCAL h%, ret%, txt$(50,MAX_TXT_LENGTH),add%, f$(255)
local ct%,ct1%
 dinit "Open files"
 f$="LOC::M:\"
 dFILE f$,"Source",0
 if dialog=0
  stop
 endif
 ret%=ioopen(h%,f$,$0020)
 if ret%<0
  raise ret%
 endif
 while ct%<50
  ct%=ct%+1
  add%=addr(txt$(ct%))
  ret%=ioread(h%,add%+1,MAX_TXT_LENGTH)
  if ret%<0
   if ret%=-43
    giprint "Text too long"
    pokeb add%, MAX_TXT_LENGTH
    print txt$(ct%)
   elseif ret%=-36
    break
   else
    raise ret%
   endif
  else
   pokeb add%, ret%
   print txt$(ct%)
  endif
 endwh
 get
 while ct1%<ct%
  ct1%=ct1%+1
  print txt$(ct1%)
 endwh
 get
ENDP

>If I ever work this bit out , I also want to write to a text file 
to send back to the PC.

This is easier, using LOPEN and LPRINT but only if you want to 
create the file, ie you can't append to an existing file, these 
commands overwrite it. For that it's IOWRITE I'm afraid.

Hope this helps
Tony

>>>psion/opl 3514 swadey(232)28Feb97 07:45
File attributes.
What is the easiest way to read and possibly change the modified flag
of a file? I've probably read the appropriate information a
half-dozen times without realising it, but any help would be
appreciated.

TIA
Steve

>>>psion/opl 3515 ple(3549)28Feb97 10:18 c3514*
File Attributes Code

    Rem Pelican Software Inc.
    Rem ---------------------
    Rem Here's the proc for setting attributes
    Rem Getting Attrib's part is from Psion
    Rem Setting is from Pelican Software Inc.
    Rem Sorry it's not well structured

PROC Attrib:
local fname$(128),g%,ro%,hid%,sys%,mod%,mask%,win%,fl%
local name$(128),fzts$(130)            :rem Zero Terminated String 
version of fname
local e%                               :rem error from FilStatusGet
local ver%,attrib%,size&,mdate&,spare& :rem Dont change order
local yr%,mo%,dy%,hr%,mn%,sc%,yrday%   :Rem For parsing Date
Win%=gcreate(0,0,60,80,1)              :Rem info window
gborder 1
fname$=cmd$(1)                         :Rem initialise to program name
top::
do
fzts$=fname$+chr$(0)                   :Rem add zero
e%=call($887,addr(fzts$)+1,addr(ver%),0,0,0)  :Rem FilStatusGet call
cls
if e%                                  :Rem if error
  giprint err$(e%) :pause 30
 else
  ro%=0 :hid%=0 :sys%=0 :mod%=0        :Rem set our flags to zero for loop
  guse win% :gcls :gborder 1           :Rem setup the info window
  secstodate mdate&,yr%,mo%,dy%,hr%,mn%,sc%,yrday%     :Rem parse the date
  fl%=0
  if attrib% and $20 :gat 1,10 :gprintb"Mod",55,3 :mod%=2 :fl%=1 :endif
  if attrib% and $4 :gat 1,20 :gprintb"Sys",55,3 :sys%=2 :fl%=1 :endif
  if attrib% and $2 :gat 1,30 :gprintb"Hid",55,3 :hid%=2 :fl%=1 :endif
  if (attrib% and $1)=0 :gat 1,40 :gprintb"RdOnly",55,3 :ro%=2 :fl%=1 
:endif
if fl%=0                                :Rem Set all flags after reading 
attributes
 gat 5,35
 gprintb"No Flags",50,3                 :Rem if no flags set display
 gat 5,45
 gprintb"Set!",50,3
endif
if len(parse$:(fname$,7))>13            :Rem truncate display of fname
 name$=parse$:(fname$,8)+"..."+parse$:(fname$,6)
else name$=fname$
endif
dinit"File: "+name$                     :Rem diplay dialog
dtext"Size:",fix$(size&,0,12)
dposition 1,1                           :Rem set window in lower right
dchoice ro%,"Read Only:","No,Yes"
dchoice hid%,"Hidden:","No,Yes"
dchoice sys%,"Sys file:","No,Yes"
dchoice mod%,"Modified:","No,Yes"
dtext "Last modified",fix$(mo%,0,2)+"/"+fix$(dy%,0,2)+"/"+fix$(yr%,0,4)
g%=dialog
mask%=0                                 :Rem zero mask% int
if ro%=2                                :Rem set flags and mask
 ro%=$0
else ro%=$ff :mask%=mask%+1
endif
if hid%=2 :hid%=$ff :mask%=mask%+2
else hid%=0
endif
if sys%=2 :sys%=$ff :mask%=mask%+4
else sys%=0
endif
if mod%=2 :mod%=$ff :mask%=mask%+$20
else mod%=0
endif
  if g%
 e%=call($987,addr(fzts$)+1,$27,0,0,0)      :Rem start by clearing flags
 e%=call($987,addr(fzts$)+1,mask%,0,0,$ff)  :Rem FilStatusSet call
if e%<0
 giprint err$(e%)                           :Rem display errors
endif
 goto top
  endif
endif
        dInit "Load file"                :Rem load next file
        dPosition 1,1
        dFile fname$,"File",0
      until dialog=0
ENDP

Rem ----------- Start of new proc ---------------------

PROC parse$:(fil$,req%)
local b%(6),p$(128),rel$(8),fsys$(8)
local dev$(2),path$(128),fn$(12),ext$(4)
p$=parse$(fil$,rel$,b%())
fsys$=mid$(p$,1,b%(2)-1)
dev$=mid$(p$,b%(2),b%(3)-b%(2))
path$=mid$(p$,b%(3),b%(4)-b%(3))
fn$=mid$(p$,b%(4),b%(5)-b%(4))
ext$=mid$(p$,b%(5),4)
if req%=1 :Return fsys$
elseif req%=2 :return dev$
elseif req%=3 :return path$
elseif req%=4 :return fn$
elseif req%=5 :return ext$
elseif req%=6 :return fn$+ext$
elseif req%=7 :return fsys$+dev$+path$
elseif req%=8 :return fsys$+dev$
rem Add your own combinations here
endif
ENDP

Hope this helps, PLE

>>>psion/opl 3518 swadey(63)28Feb97 20:43 c3515*
Many thanks! It works perfectly - just what was needed.
Steve

>>>psion/opl 3552 hzk(109)6Mar97 22:51 c3551*
See the file DIULINE.TXT in psion/files. This explains how to add 
and remove underlines in dialogs.

Roger

>>>psion/opl 3553 allsorts(258)6Mar97 23:11 c3551*
Check the attribute that you can append to the dLONG statement. One of these
puts a line under that line. I can't remember the setting but it's in the
Psion Programming Manual, the reference part is available as .DBF file as
well, very useful.

Cheers
Dave.

>>>psion/opl 3555 rick(99)7Mar97 10:39 c3553*
> Check the attribute that you can append to the dLONG statement.

You mean dTEXT, don't ya? ;-)

>>>psion/opl 3564 allsorts(239)10Mar97 07:37 c3555*
Ah, I was making the assumption that all the dXXXX statements support the
feature. A quick look shows that it's not documented as such. Worth a try
though, seems rather restrictive if you can't control the display with them.

Cheers
Dave.

>>>psion/opl 3557 robfitz(118)7Mar97 16:00
More Dialog Qs
Can I set the 2nd ( or any line I choose ) in a dialog to have the focus 
when I open it ?
..... Rob

>>>psion/opl 3558 hzk(167)7Mar97 22:19 c3557*
There is another file which shows how to make complex dialogs, with 
progress bars and the like. Maybe that will help?

I think it's DIAGOPL.ZIP in the flist.
Roger

>>>psion/opl 3565 bpechey(81)10Mar97 08:30 c3558*
Actually it's DIALGOPL.ZIP. 
Close, but no cigar, as the Americans say.
Bill.

>>>psion/opl 3559 robfitz(391)7Mar97 23:16
Please help , Brains on fire 
I'm trying to fill a longlist choice thing up from a texfile use the code 
hacked around from flatlist.opl. I've actually got this bit working ( 
miracle ). What I get is the index of the line returned ie ret%

So I get " you picked item 12 "

What I want is "you picked Bill Smith"

I know this is probably straight forward but my brain has had it. 
..... Rob

>>>psion/opl 3561 hzk(1398)9Mar97 18:23 c3559*
Here's a bit of code I used for extracting the string from an index to a 
VASTR class of array. I expect it is similar to VAFLAT.

Here pobj% is the handle (from NEWOBJH) for the VASTR object.  Pass the 
array index returned by dCHOICE as choice%.  This PROC puts the address of 
the wanted string into str%. This will be a zero terminated string, so we 
need to copy it into result$, here using strcopy:().

PROC dispvstr:(choice%)
        LOCAL str%,t%,result$(255)
        t%=choice%
        str%=ENTERSEND(pobj%,20,#t%)
        strcopy:(str%,ADDR(result$))
        PRINT disp$
        GET
ENDP

PROC strcopy:(from%,to%)
        LOCAL len%,f%,t%,val%
        f%=from%                REM address of first character
        t%=UADD(to%,1)          REM address of first char of OPL string
        val%=PEEKB(f%)          REM get first character
        WHILE val%<>0           REM while not zero termination
                POKEB t%,val%   REM poke char into result$
                f%=UADD(f%,1)   REM increment source
                t%=UADD(t%,1)   REM increment destination
                len%=len%+1     REM increment length counter
                val%=PEEKB(f%)  REM get next character
        ENDWH
        POKEB to%,len%          REM poke length of OPL string
ENDP

I'm not sure where this code originated, I'm sure I didn't figure it out 
on my own! My thanks to whoever it was!
Roger

>>>psion/opl 3372 swebb(207)30Nov96 07:50 c3370*
Phew! Just out of interest, are you calling send(vaflat%,0) at the end to 
tidy things up.  This doesn't appear to be mentioned in the docs, but I 
read somewhere that it was needed.

Simon Webb
SW Systems

>>>psion/opl 3392 fit(127)4Dec96 11:11 c3372*
No, at the moment I'm not calling 
send(vaflat%,0) (or in my case, 
send(vastr%,0)??).

Why and where should I do this?
Dave

>>>psion/opl 3393 richardcox(643)4Dec96 12:55 c3392*
> Why and where should I do this?

To avoid memory leaks.
Method 0 of any class is its DESTROY method (from C you would use 
p_send(Handle, O_DESTROY) or hDestroy(Handle) they are equivalent). This is 
the method that calls the class's destructor, to tidy up any resources that 
it is using. In the case of VAxxx class's only memory is used--which on exit 
is tidied up anyway (but could be a problem if you are creating and not 
destroying loads of classes as you run).

OTOH if the resource is a file, not closing it can cause buffers not to be 
flushed... in which case you need to destroy the object before exiting.
------- 
Richard

>>>psion/opl 3562 dbrewood(544)9Mar97 20:36
New App
I've just started coding again on the Psion from scratch (lost all my 
libs) and am trying to work out 2 bits of code I had previously and am 
failing completely!

I'm trying to knock bits up to do the following:

- Give the application I am writing a user defined name under SPY.APP.
- Detect when the program should have been sent into the background and
therefore paused.

Any help would be appreciated.
Sun 09 Mar 1997 20:33:10
Daron Brewood                                     

>>>psion/opl 3566 slitchfield(198)10Mar97 08:41 c3562*
PROC callme:(v$)
  local pid%,k$(9),m%
  pid%=call($88)
  k$=v$+chr$(0)
  m%=addr(k$)+1
  call($c88,pid%,0,0,0,m%)
ENDP
(I think I got this from you in the first place!!! 8-)) )
Steve Litchfield

>>>psion/opl 3572 rick(226)11Mar97 11:56 c3562*
> - Detect when the program should have been sent into the background and
> therefore paused.

GETEVENT a%()

when a%(1)=$401, the program has moved to the foreground.
when a%(1)=$402, it has been moved into the background.

>>>psion/opl 3574 robfitz(585)12Mar97 21:33
URGENT Help Needed
I need to know the answer to this real soon or I die
I need to open  or create a text file and then write to it one line at a 
time from a keyboard input. 

ie 
open file
while cntr% < 10
        input mystr$
        iowrite filename mystr$
        cntr% = cntr% + 1
        endwh
close file      
        
If the file exists I need to delete it.
I tried to create a file with ret%=ioopen(h%,filenam$,$0020)
but when I want to use Iowrite it wants an address and I dont really get 
it ( dimbo ).
Please help I cant go to bed until this works
..... Rob

>>>psion/opl 3575 hzk(424)12Mar97 22:50 c3574*
To create a new text file use IOOPEN with $0022 - this will truncate any 
existing file to zero length first.  E.g.:

LOCAL r%, chars%, handle%, buf$(255)
r%=IOOPEN(handle%,filename$,$0022)

In the above, OPL creates the handle. You can write your input text like 
this:-
First read your text into buf$, then:

chars%=LEN(buf$)
r%=IOWRITE(handle%,UADD(ADDR(buf$),1),chars%)

Remember to check r% for any errors...
Roger

>>>psion/opl 3576 robfitz(383)12Mar97 23:23 c3575*
Thanks for the very swift reply, 
Im getting an error

process exited
exit number 25

I've tried trapping for the err$ using onerr but I cant get that to work
I get this error when I try to iowrite , Looking in the book ( if im 
looking in the right place) I think this means that I dont have enough 
power to write to flash , but the batts are new, I just changed them
..... Rob

>>>psion/opl 3577 robfitz(88)13Mar97 08:32 c3574*
Found it I needed to open with $0122
going to bed now,
thanx for the help

..... Rob

>>>psion/opl 3580 perseus(362)13Mar97 12:41 c3577*
As Roger said, make sure you check the value of R%.
It will be 0 or positive if the command worked, or a negative error 
(listed in the OPL manual) otherwise.

IO commands do not affect ONERR, they return a result without raising an 
error.
BTW, Panic 25 is 'Invalid IO handle', suggesting you tried to read/write 
the file when the open operation had failed.

>>>psion/opl 3634 mrbush(178)6Apr97 21:20 c3574*
Not terribly quick here, but lopen works:
e.g.

lopen "\wrd\temp.wrd"
lprint "This is some text"
lclose

This creates a new file, writing over the old one if it exists.
Kevin


>>>psion/opl 3618 rclyne(721)27Mar97 00:19
Binary Chop Routine in OPL

Assumptions:

    Database file is mostly sorted
    Often you will want sequential items

proc find_in_price:(id$)
local range%,base%

if prfile$ = "" or d.id$ = id$
return
endif

use d
if pos < price_count
next
endif
if d.id$ = id$
return
endif

base% = 1
range% = 2 ** int(ln(price_count)/ln(2)+0.999)

while ( range% > 0 )
range% = int(range% / 2)
if (base% + range%) <= price_count
position (base% + range%)
if id$ = d.id$
base% = base% + range%
range% = 0
endif
if id$ > d.id$
base% = base% + range%
endif
endif
endwh
if d.id$ <> id$
last
while (d.id$ <> id$) and (pos > 1)
back
endwh
endif

if d.id$ <> id$
d.Id$ = ""
d.buy$ = "0.00"
d.sell$ = "0.00"
return -1
else
return 0
endif
endp

>>>psion/opl 3631 kblake(516)4Apr97 18:04
Excuting compiled 'programs' in OPL
Is there any way of executing properly compiled programs (i.e. programs
compiled from 'c') from within an OPL program.

For that matter is it possible to run any application from OPL.

From the standard OPL calls the closest thing I could see were the USR
and CALL commands which obviously aren't what I want. 

Is there any macro or extension that does this or am I stuck?
(the only other alternative is for me to rewrite the whole of the existing
program in 'C')

Thanks,
kjb.

>>>psion/opl 3632 hzk(651)4Apr97 22:35 c3631*
The following code launches JBDATA.APP, a 'C' application, with file$ 
loaded. The command line contains an 'O' (capital O) for Open, and jbdata 
is the appname. It may launch .IMG programs, not sure what to do about the 
command line though!

PROC main:
        LOCAL prog$(128),cmdl$(128),file$(128),n$(1)
        LOCAL pid%,r%
        n$=CHR$(0)
        prog$="M:\app\jbdata.app"+n$
        file$="m:\dat\bbrc_mem.dbf"
        cmdl$="Ojbdata"+n$+n$+file$+n$
        r%=CALL($0187,UADD(ADDR(prog$),1),ADDR(cmdl$),0,0,ADDR(pid%))
        IF r%<0
                PRINT "Aaargh!"
                GET
        ENDIF
        CALL($0688,pid%)
ENDP
Roger

>>>psion/opl 3633 kblake(171)6Apr97 19:39 c3632*
Thanks for that.
I would expect that the cmdline$ is any command line
arguments that the program would require. Most of the 
time I would expect this to be blank.
kjb.

>>>psion/opl 3635 ntisdale(1008)8Apr97 19:14
Ajai Khattri's tcp/ip stack - WHERE?!
I have just read a document which was in the psion flist discussing a team of 
people making a tcp/ip stack first in a OPO format and then a C libary.  
It is in a working state and sounds very interesting as you can easily make 
an OPA that uses the stack...

        rem Initialise TCP/IP software
        initnet:

        rem Try and create a socket:
        s% = opensock:("stream",0)

        rem Get a port number:
        p% = getport:("ftp")

        rem Connection request:
        r% = connect:(s%,"fred.demon.co.uk",p%)

        rem Bomb out if no connection!
        if r%<0: print "Can't connect" : stop : endif

        rem Start sending data:
        r% = send:(s%,addr(buf%), 100 )
        
Above is an example of a *very* minamal prog.

It all sounds very exciting but... *WHERE CAN I FIND IT!!!!*
It is headed, I think by Ajai Khattri.  If anyone else knows where/how I can 
either get it or contact Ajai Khattri I would be must grateful.

NTisdale

>>>psion/opl 3637 jlittlew(211)9Apr97 01:30 c3635*
You could try taking a look at the Psion Java project at:
 
http://www.geocities.com/SiliconValley/9577/

I seem to recall that there are links from there to a related freeware 
TCP/IP stack project.
Jonathan


>>>psion/opl 3653 sgarratt(213)11Apr97 07:41
This is a renewed plea:

Does anyone have a piece of code for separating the dd, mm andd yyyy
values out of a date entered via dDATE, please?  Someone else must
have hit this problem before!  I hope :-)
Simon

>>>psion/opl 3655 langdale(2418)11Apr97 11:56 c3653*
I don't know what you are trying to do but is may help.

/* -----------------------------------------------------------------------

  Procedure Description
  =====================

  Purpose
  -------

  Set the current time and date

  Parameters Passed    Comments
  -----------------    --------

  Parameter Returned   Comments
  ------------------   --------

---------------------------------------------------------------------- */

Proc TimeDate:

Local SetDate&                   /* to set the new date                */
Local SetTime&                   /* to set the new time                */
Local Year%                      /* year from secstodate               */
Local Month%                     /* month from secstodate              */
Local Day%                       /* day from secstodate                */
Local Hour%                      /* hour from secstodate               */
Local Minute%                    /* minute from secstodate             */
Local Second%                    /* second from secstodate             */
Local DayYear%                   /* days this year from secstodate     */
Local D%                         /* dialog return value                */

SetDate& = Days(Day,Month,Year)  /* set the current date               */
SetTime& = (Hour * 3600.0) + (Minute * 60.0) + Second /* set the current 
time */

dInit "System"                   /* initialise dialog with title       */
dDate SetDate&,"Date",Days(1,1,1995),Days(31,12,2049) /* enter a date  */
dTime SetTime&,"Time",1,0,DATETOSECS(1970,1,1,23,59,59) /* enter a time */
D% = Dialog                      /* get the keypress from the dialog   */

If D% > 0                        /* if enter is pressed                */
  SetDate& = ((SetDate& - Days(1,1,1970)) * 86400.0) /* set the number of 
seconds since 01/01/1900 */
  SecsToDate SetDate& + 
SetTime&,Year%,Month%,Day%,Hour%,Minute%,Second%,DayYear%  /* get the 
year, month, day, hour, minute and second */

  Loadm "A:\LIM\L_GEN.OPO"       /* load general functions             */
  SetDT%:(Day%,Month%,Year%)     /* set the date                       */
  SetTM%:(Hour%,Minute%,Second%,TIME_24_HOUR) /* set the time          */
  UnLoadm "A:\LIM\L_GEN.OPO"     /* unload general functions           */
EndIf                            /* endif                              */

Endp                             /* endproc                            */

>>>psion/opl 3660 spooley(1106)11Apr97 20:30 c3647*
I had great "fun" with date/time manipulation whilst writing my Agenda Dump 
program.  Here's one of my functions that does what you want using an EPOC 
system call:

    PROC DNtoDat:(dayno&)
        REM Converts agenda days to the global DY%, MO% & YR%
        LOCAL dyscent&(2), dateent%(4)
        LOCAL flags%,ax%,bx%,cx%,dx%,si%,di%

        dyscent&(1) = dayno&
        si% = ADDR(dyscent&())
        di% = ADDR(dateent%())
        ax% = $0600 REM TimDaySecondsToDate fn.
        flags% = OS($89, ADDR(ax%))     REM TimManager int.
        IF flags% AND 1
                RAISE (ax% OR $ff00)
        ELSE
                YR% = PEEKB(di%) + 1900
                MO% = PEEKB(UADD(di%,1)) + 1
                DY% = PEEKB(UADD(di%,2)) + 1
        ENDIF
    ENDP

This function will take a dayno& (no. of days since 1/1/1900) as returned by 
dDate and turn it into day/month/year in the DY%/MO%/YR% global variables.

(As with all OPL that uses OS calls, be careful to maintain the order of the 
LOCAL declarations since they must map directly onto OS structures)

...I hope it's of use to you.
Simon.


>>>psion/opl 3678 swadey(576)24Apr97 08:06
Reading System settings for Time
Does anyone know if it is possible to find out whether the Psion is
in 12- or 24-hour mode? I'm displaying a clock in one of my progs and
for aesthetic reasons would like to center the clock in a small box
on the screen. I suppose I could just present the clock in one
format, but I would like the option of 12- or 24-hour display if
poss.

The current code reads:

 gAT 20,9 :gCLOCK ON,10,0,"%H%:%T%:%S %7",7,0

which displays the time in the correct system setting, but does not
give me the chance to center it.

Can anyone help?

TIA
Steve

>>>psion/opl 3696 psioncorp(1749)7May97 11:19 c3679*
/*      procedure to return the type of clock set       

        Author  DP      2/11/92

        The procedure uses a call to GenGetCountryData
        which returns a structure listed below.  The 27th byte
        of the structure is the clock type, it returns
        0 Analog
        1 Digital

        Given the structure included below it is possible to change
        the procedure to return any or all of the values.

CDataEnt struc
CDataCountryCode        dw  ?
CDataGmtOffset          dw  ?
CDataDateType           db  ?
CDataTimeType           db  ?
CDataCurrencySymbolPosition db  ?
CDataCurrencySpaceRequired  db  ?
CDataCurrencyDecimalPlaces  db  ?
CDataCurrencyNegativeInBrackets db  ?
CDataCurrencyTriadsAllowed  db  ?
CDataThousandsSeparator     db  ?
CDataDecimalSeparator       db  ?
CDataDateSeparator      db  ?
CDataTimeSeparator      db  ?
CDataCurrencySymbol     db  9 dup(?)
CDataStartOfWeek        db  ?
CDataSummerTime         db  ?
CDataClockType          db  ?
CDataDayAbbreviation        db  ?
CDataMonthAbbreviation      db  ?
CDataWorkDays           db  ?
CDataUnits          db  ?
CDataSpare          db  9 dup(?)
CDataEnt ends
                                                         */
proc clock:

        LOCAL   buf$(40)        /*   40 byte buffer to return structure 
   */          
        LOCAL   clock%          /*   return the value of the clock type 
   */
        
        call($058b,(addr(buf$)+1))      /*   Call GenGetCountryData     
   */

        pokeb addr(buf$),40             /*   poke the length of the 
buffer */
        clock% = peekb(addr(buf$)+27)      
        print clock%                    /*   return the clock type      
   */
        get
ENDP

Regards, David Ponsford
Psion UK plc

>>>psion/opl 3711 swadey(246)9May97 07:55 c3696*
Many thanks - this was just what was needed. I actually used
CDataTimeType in the end which returns:
 1 for 24 hour system setting, or
 0 for am-pm system setting

Is there any one place where calls such as these are explained and
listed?
Steve

>>>psion/opl 3715 psioncorp(100)12May97 13:20 c3711*
All this sort of information is detailed in the C & OPL SDKs.

Regards, David Ponsford
Psion UK plc

>>>psion/opl 3717 uk_alarms(233)12May97 14:27
OPA and Help files

I have XfHelp, which does a super job of creating a help resource file.
But can I embed the help file into the OPA file, so I only have to 
distribute one file? And if so how, please?

Kevin Golding, UK Alarms

>>>psion/opl 3718 rick(382)12May97 17:03 c3717*
> But can I embed the help file into the OPA file

I don't think you can easily do this with OPL. :-( I've seen it done
with APP (C SDK) files, for example PSIZIP.APP has the help file 
embedded within it.

Perhaps there is a trick, something similar to loading PIC files from
the OPA file, that can be performed to access a help RSC file that
has somehow been linked into an OPA.

>>>psion/opl 3719 slitchfield(83)12May97 17:36 c3717*
I don't think you can do this in OPL. But I'd be happy to be proved wrong!

Steve

>>>psion/opl 3721 ple(273)12May97 21:00 c3719*
I'm pretty sure there is no easy way to build a .rsc or .rzc file into 
an opa. If there is I'd be very interested.

Even with apps you can only add one resource file into the app file, 
so if its multi-lingual the other resource files have to be external.
cheers, Leigh

>>>psion/opl 3725 uk_alarms(46)13May97 09:20 c3721*
Thats a shame :-(
Kevin Golding, UK Alarms

>>>psion/opl 3730 perseus(1306)15May97 09:27 c3725*
Don't lose hope just yet.  You may be able to fool the help system into 
using your file.

The help file componet has an initializer method which opens the file and 
records where the resource section starts.  By devious means, you should 
be able to perform the initialisation yourself, and get the help reader 
to take input from anywhere in your executable.

You can append any size of file to the and of an OPA, and EPOC won't 
complain.  Code is loaded on demand, so you could bloat the file to 4Meg, 
and the OPA would still run OK.

I don't have much time to look into this in detail at the moment, but I 
can give you a starting point...

Help is usually stored in a resource file.  This is handled by the 
RSCFILE class in OLIB.  w_am->rcb is the handle of the application 
resource file.

You can create an RSCFILE object, and poke into its properties the 
details of where to find the start of your resource file within the 
executable.  Then when you call the Help system, you should find it uses 
your embedded help file.

You *can* embed files within an OPL.  I researched this about four years 
ago when looking at coding a self extracting OPA.  The main issue is 
knowing where the embedded file starts.  I simply added a length field to 
the very end of the file and that worked a treat.

>>>psion/opl 3731 rick(155)15May97 17:05 c3730*
> when looking at coding a self extracting OPA. 

I was thinking about this the other day when I saw a copy of PsiZip.
Do you get very far with the idea?

>>>psion/opl 3733 perseus(875)16May97 12:41 c3731*
I had a working means of producing self extracting OPAs.  All you needed 
to produce a self extracting file was :

   COPY Prog.OPA+archive.DAT /b
   
Four years is a long time ago, and the source code is probably lost in 
the sea of 'lets see if this works' files, but I'll have a look around 
for it.

It wasn't rocket science.  
     Use CMD$() to find the application file, and open it
     IOSEEK to the end of file minus four, and read in Len&
     Seek backwards by Len& (+4) bytes
     Start copying or using the added file.
     
My archive file format was similar to this in the sense that each file 
had a length byte appended, so that you could extract data from the end 
of the file, and then shrink the file.  In this way, the archive is 
repeatedly 'peeled' of files and you can extract a very large archive 
file in only a few kilobytes of spare disk space.

>>>psion/opl 3743 joegriffin(589)18May97 16:05 c3735*
I was playing about with this today ...

PROC ACGInit:
  LOCAL xy%(4)
  gUPDATE OFF
  REM Called to initialise the graphics
 
  REM First get the screen size
  scwid% = gWIDTH
  schi% = gHEIGHT
  
  REM Turn on the status window
  STATUSWIN ON
  
  REM Find out where the window is
  STATWININFO(-1,xy%())
  
  REM Now resize the screen to accommodate the window
  scwid% = scwid% - (scwid% - xy%(1))
  gSETWIN 0,0,scwid%,schi%
  
  REM Add a border to the main window
  gBORDER 0
  gSTYLE 13
  gAT (scwid%/2) - 120,27
  gPRINTB "ATC Watch Calendar", 240, 3, 3,1
  gSTYLE 1
etc
... Joe

>>>psion/opl 3758 hzk(1162)23May97 23:27
Command line to run the OPL editor.
I have recently found a 'funny' in the way I run the OPL editor from my 3T 
program. The code is something like this:

PROC main:
        LOCAL pid%,cmdl$(250),pgname$(26),r%,n$(1)
        n$=CHR$(0)
        pgname$="ROM::WORD.APP"
        cmdl$="OProgram"+n$+" OROPO"+n$+"LOC::M:\OPL\TEST.OPL"+n$
        r%=CALL($0187,UADD(ADDR(pgname$),1),ADDR(cmdl$),0,0,ADDR(pid%))
        IF r%<0
                ALERT("Cannot Start "+pgname$,"Cause: "+ERR$(r%))
                RETURN
        ENDIF
        CALL($0688,pid%)
ENDP

This produces an OPL editor without a 'Tranlate S3' option. Furthermore 
translation does not end with a 'Run Program' dialog, but a 'Translation 
Complete' (or similar) dialog. A proper S3a OPO is produced, although a 
user in the Netherlands says he gets an S3 translator which does not 
accept things like FONT 11,3.

The Psionic file suggests an asterisk is added after the OROPO, but if I 
add this, the file does not translate at all. I thought the R in OROPO 
meant the 'run' option should appear, but it doesn't! Adding .OPL after 
the OProgram bit doesn't help either.

Any ideas please?
Roger

>>>psion/opl 3759 hzk(482)23May97 23:27
Set file date
Function $87, sub $13 is the FilSetFileDate routine. It seems to require 
the date in seconds after 1/1/1970 to be fed to it.

However, feeding zero produces a date 1/1/1980, and it doesn't start 
working properly until you give it a date of 1/1/1980 or later.

It stops working in about 1/1/2038, because the long int which holds the 
date cannot be an unsigned value, so it runs out of steam at value 
+2147483647 ($7FFFFFFF).

Once again, any ideas please?
Roger

>>>psion/opl 3797 psion_c(339)5Jun97 18:01 c3759*
>However, feeding zero produces a date 1/1/1980, and it doesn't start 
>working properly until you give it a date of 1/1/1980 or later.

From the PLIB manual:

"The date may not be set earlier than January 1st 1980. If p_fdate is 
called with any earlier system time, the date is forced (without error) 
to January 1st 1980"

regards
Ali

>>>psion/opl 3767 perseus(219)26May97 18:00 c3766*
Isn't it as simple as :

a = b MOD c    is equivalent to    a = b - (c*INT(b/c))

Then again, my head may still be in weekend mode.

Heres the other 'missing' operator...

 a XOR B = (a OR b) AND NOT (a AND b)
 
Simon

>>>psion/opl 3770 robfitz(161)30May97 10:17
Workabout Docking
How in OPL can I test for the docking and undocking of the unit. I can do 
this in Oval but it would appear thats all i can do ;-)
..... Rob

>>>psion/opl 3772 perseus(294)30May97 14:19 c3770*
Open the CRD: device and queue a read.  The read request will complete 
whent the status of the cradle changes (ie the Workabout is 
docked/undocked).

I can't confirm if this also happens with the 3link on a LIF adapter.  
Your best bet there may be a relative timer polling the port.
SImon

>>>psion/opl 3774 timmoore(316)30May97 17:16
Current drive.

Help,
my opl program needs to load some data files from the same drive as the
program. Simply using filenames such as "\dat\mydata.dbf" default to
the M drive, even when run from A: or B:
Do I have to search each drive or can I determine the drive the
program is being run from?

Thanks,

Tim Moore.

>>>psion/opl 3775 jboyce(654)30May97 17:34 c3774*
> Current drive.
> 
> Help,
> my opl program needs to load some data files from the same drive as the
> program. Simply using filenames such as "\dat\mydata.dbf" default to
> the M drive, even when run from A: or B:
> Do I have to search each drive or can I determine the drive the
> program is being run from?

If you don't specify a drive in the string then it will always default to 
the drive set as the Default on the System screen. Otherwise you will need 
to either specify the drive you need or PARSE$ the CMD$(1) and extract the 
drive from that (assuming you wish the datafile to be on the same drive as 
the program code).

Best wishes
John

>>>psion/opl 3776 timmoore(58)30May97 21:37 c3775*
>Parse$ the CMD$(1)

Just the ticket, thanks.
Tim Moore.

>>>psion/opl 3777 tsteven(836)1Jun97 14:28
dTEXT/Too Wide
I have a slight problem in that I want to use dtext in a dialog 
statement, however the string that I want to display  is editable 
elsewhere in my program and thus may be too wide for a dtext statement. 
How can I error check for a wide string.
The problem I have is some characters are wider than others, if I was to 
put 41 M`s back to back I would get a too wide error but if I put 41 
characters of some proper text I don`t get the error. I tried to use 
something like:
if LEN (a$)>40
  a$=LEFT$(a$,40)
 endif 
 
This would be fine if the text was all M`s but it`s not and the real text 
is cut too much.
I can`t use dedit because I have used dbuttons below the text and any 
editable text causes conflict with the button keys.
Or is there a way to use dedit but to actually block any text input.

TIA
Rgds Tony.

>>>psion/opl 3778 gidds(390)1Jun97 14:43 c3777*
You can check how much space a string takes up on screen with the
gTWIDTH() function - it takes a string argument, and returns the
width in pixels it would take up if displayed in the current font
size and style.  So, change to the font used in dialogs, and check
whether the width is small enough (trial and error wil show how small 
that is).  If not, trim the string until it is!
Andy/

>>>psion/opl 3779 uk_alarms(149)2Jun97 13:40 c3778*
Or use l% = gprintclip at an off screen location, which will 
return the number of characters that will fit.

Kevin Golding
UK Alarms (0500-206999)

>>>psion/opl 3787 tsteven(304)3Jun97 18:29 c3779*
Thanks for all your help. 
I overcame the problem by using gcreate and gprintb instead of the dinit 
and dtext dialog window. For the buttons I created them manually. (Well 
actually no that`s a blatant lie, I used the code supplied by Pelican 
software on their web site.)

Thanks anyway. 
Rgds Tony.

