Subj:  OS and CALL                      Section: Psion Programming
  To:  Bertram Hochstetter, 100573,3530 Sunday, 19 May, 1996 4:14:19 PM
From:  Mark Esposito (SYSOP), 72662,3050#217379

Bertram,

        I'm not sure off hand what your doing wrong, but I can give you
maybe an easier service to use. In your case, your drive$ probably needs
to be zero terminated. Also, cx% is the address of the buffer you should
be reading, and not ax%. Anyway, if you only need the device type, you can
use the FILLocDevice service, which writes just the media type to a word
pointed to by cx%. Here's an example of how to use it.

Proc test:
print SSDtyp$:(filocdv%:(%m))   /* Drive M in our example */
get
Endp

PROC filocdv%:(drive%)
    LOCAL ax%,bx%,cx%,dx%,si%,di%
    LOCAL flags%
    LOCAL medtype%
    ax% = $1500
    bx% = drive% AND $00ff
    cx% = ADDR(medtype%)
    dx% = 0
    si% = 0
    di% = 0
  flags% = OS($87,ADDR(ax%))
  IF flags% AND 1
        RAISE (ax% OR $ff00)
  ELSE
        return medtype%
  ENDIF
ENDP

Proc SSDtyp$:(medtype%)
local r$(16),r%
r%=(medtype% and $0f)
IF r% = 1
        r$= "Floppy"
ELSEIF r% = 2
        r$="Hard Disk"
ELSEIF r% = 3
        r$= "FLASH"
ELSEIF r% = 4
        r$= "RAM"
ELSEIF r% = 5
        r$= "ROM"
ELSEIF r% = 6
        r$= "Write-Protected"
else
        r$="None"
ENDIF
return r$
Endp

Subj:  Reading Files                    Section: Psion Programming
  To:  Karl-Henry Lahmann, 100733,2752  Tuesday, 21 May, 1996 9:57:21 AM
From:  Mark Esposito (SYSOP), 72662,3050#217705

Karl,

    >> It shall count the number of characters in the file, the number of
words and paragraphes and the number of some special characters within the
text. <<

 Couldn't you just get the file size using a call(), and then estimate the
number of lines based on an average? or is this not accurate enough?

 The other thing you can do is to read in the file as a binary stream of
data, and not line by line.

    toread%=Number of bytes you want to read in, max is 16k
    toread%=2000
    mode%=$0200    REM allows IOSEEK if you need it.
    ret%=IOOPEN(handle%,file$,mode%)
    ret%=IOREAD(handle%,addr(buf%()),toread%)

    buf%(1-2000) now contains the first 2000 bytes of your text file.
    ret%=number of bytes read in.

 Hope this helps.


  -Mark Esposito


Subj:  OS and CALL                      Section: Psion Programming
  To:  Bertram Hochstetter, 100573,3530 Wednesday, 22 May, 1996 8:48:22 PM
From:  Mark Esposito (SYSOP), 72662,3050#218036

Sebastian,

    Glad it worked for you. The Filocdev service can report the status of
the batteries in a RAM SSD.

    << medtype% and $0f >>

    Gets the low byte of the value of medtype%.



  -Mark Esposito

Subj:  OS and CALL                      Section: Psion Programming
  To:  Mark Esposito (SYSOP), 72662,3050Wednesday, 22 May, 1996 2:28:26 PM
From:  Bertram Hochstetter, 100573,3530 #217949

Hallo Mark!

Thanks for your fast anwser!!! I tested your listing and it works very
very fantastic. But what is with the battery status in bits 7 to 8? And
what means $0f (r%=medtype AND $0f) in his context? - 15(dez.)?

My name is not Bertram (he`s my father - also PSION user). He is
CompuServe member. I only use it, too. My name is Sebastian Hochstetter.
But it doesn't metter.

Bye,
        Sebastian


Subj:  Diamond key                      Section: Psion Programming
  To:  Chris Nicholson, 100522,2324     Friday, 07 June, 1996 1:34:13 AM
From:  Mark H J Fitzpatric, 100026,2452 #220856

Chris,
>>>I have 3 different data screens that I want to be able to swop between
and would like to utilise the diamond key. I have found how to use the key
and how  to change between 2 screens but I cannot workout how to introduce
a 3rd screen.. Can anyone please offer some useful advice??
<<<

I presume in OPL, and it goes like this for example...

Proc DiamTest:
        local diapos%
        defaultwin 1
        Rem Set up Diamond Menu with 3 items, 1st selected initially
        DiamInit 1,"Search","Results","Details"
        diapos%=1
        key%=get
        if key%=DIAMOND
                diapos% = diapos%+1
                if diapos%>3
                        diapos%=1
                endif
                DiamPos diapos%
        endif
EndP
Good luck!
Mark

Subj:  Launching Word                   Section: Psion Programming
  To:  John Wojcik, 100041,1711         Monday, 10 June, 1996 11:49:01 PM
From:  Mark Esposito (SYSOP), 72662,3050#221406

John,

    << I need to be able to launch Word with a text file. I have worked
out to use Filexecute but I cant get it to work. <<


 Here's some code:

 -----------------------------------------------------
 FULL_FILENAME = "LOC::B:\WRD\File.wrd"    REM example
 als$=""    REM Normal Word file
 als$="$"    REM text editor
 cbyte$="C"    REM to create, or "O" to open

 pgname$="ROM::WORD.APP"+chr$(0)
 cmdl$=cbyte$+"Word"+chr$(0)+".WRD "+als$+chr$(0)+FULL_FILENAME+chr$(0)
 ret%=call($0187,uadd(addr(pgname$),1),addr(cmdl$),0,0,addr(spid%))
 if ret%<0
        giprint"Couldn't Launch Word"
        return 0
 endif

 call($0688,spid%)       /* Resume */
 ------------------------------------------------------

 Hope this helps.



  -Mark Esposito

Subj:  Launching Word                   Section: Psion Programming
  To:  Mark Esposito (SYSOP), 72662,3050Tuesday, 11 June, 1996 6:57:31 AM
From:  John Boyce (Sysop), 100014,1240  #221467

John

 >>  ret%=call($0187,uadd(addr(pgname$),1),addr(cmdl$),0,0,addr(spid%))

After you have got the thing going with this code you also need to send a
ProcResume...

   call($688,spid%,0,0,0,0)

to actually get the thing moving.

Best wishes

John


Subj:  Screen display                   Section: Psion Programming
  To:  Svein Birkeland, 100667,3207     Monday, 10 June, 1996 11:03:12 PM
From:  Mark H J Fitzpatric, 100026,2452 #221400

Svein,
        Have you looked at using gPrintb instead of gprint. With gPrintb
you could specify your maximum width and the rest takes care of itself. It
would be a little hazardous using the method you put forward. If you were
using proportional fonts, the spaces wouldn't necessarily occupy the same
with as 30 other characters would. Anyway, IMO gPrintb is the way to go
for what you seem to be doing.

Good luck,
Mark :~)


Subj:  own dialog with app-icon         Section: Psion Programming
  To:  all                              Wednesday, 12 June, 1996 4:12:16
PM
From:  Bertram Hochstetter, 100573,3530 #221712

HI!

For a information box in a programm I want to use one with the app-icon.
This is not possible with OPL, so I think I will do it myself. I designed
a nice box with gXBORDER 1,3 OR $200,400,130 in a new bitmap.
The problem is-  the box stay still on the screen when I close the bitmap.
Another problem is that the screen is clear after I used DEFAULTWIN 1 to
have the grey color. The code I used, you can see below:

PROC inform:(name$)
        LOCAL id%,i%(2),k%
        i%(1)=gLOADBIT(name$,0,0) REM load the pic file
        i%(2)=gLOADBIT(name$,0,1)
        id%=gCREATE(40,15,400,130,1)
        DEFAULTWIN 1
        gSETWIN 40,15
        gXBORDER 1,3 OR $200,400,130
        gAT 30,12
        gGREY 1 :gCOPY i%(2),0,0,48,48,0
        gGREY 0 :gCOPY i%(1),0,0,48,48,0
        gFONT 8 :gSTYLE 1 :gAT 130,30 :gPRINT "Programm"
        ..... REM the informations
        DO
                k%=GET
                IF k%=291
                        gAT 0,0 :gXBORDER 1,4 OR $200,400,130
                        help:
                        gXBORDER 1,3 or $200,400,130
                ENDIF
        UNTIL k%=13 OR k%=27

        REM now I must used cls
        gGREY 1 :gCLS gGREY 0 :gCLS
        gCLOSE id% :gCLOSE i%(1) :gCLOSE i%(2)
ENDP

Well, maybe anybody could help me

Bye,
        Sebastian


Subj:  own dialog with app-icon         Section: Psion Programming
  To:  Bertram Hochstetter, 100573,3530 Wednesday, 12 June, 1996 9:48:01
PM
From:  Ajai Khattri, 104127,3257        #221782

Bertram,

Off the top of my head:
Use DEFAULTWIN 1 before *any* other drawing commands. Enabling the grey
plane changes the window ID and so I guess clears the screen.

Regards,
Aj. (ajai@nwt.com)
New World Technologies, Inc.
`the psion house'



Subj:  own dialog with app-icon         Section: Psion Programming
  To:  Bertram Hochstetter, 100573,3530 Thursday, 13 June, 1996 2:11:09 PM
From:  Mark Esposito (SYSOP), 72662,3050#221878

Bertram,

    >> Well, maybe anybody could help me <<

Defaultwin affects the default window (1), and doesn't affect the grey
plane of a window you create. Therefore...

    id%=gCREATE(40,15,400,130,1)

 is not creating a window with grey plane. You'de need...

    id%=gCREATE(40,15,400,130,1,1)

Defaultwin should be at the top of your procedure. Your program is
drawing to the default window, and not the one you're creating, (id%) so
that when you close id%, you are closing a window that has nothing in it,
and you are left with the default window which has your bitmaps drawn to
it.

In OPL there is a window set up for you automatically. If you don't need
it, use the following to reduce memory used by the window.

    guse 1
    gsetwin 0,0,0,0

 Hope this helps.


  -Mark Esposito



Subj:  OPL & Sprites                    Section: Psion Programming
  To:  Ajai Khattri, 104127,3257        Thursday, 20 June, 1996 7:54:02 PM
From:  Mark H J Fitzpatric, 100026,2452 #222993

Aj,
        Here's SPRITEC.OPH. Its reasonably self explanatory, but ask away
if there are any questions etc. To use this on PIC's embedded in your OPA
you also need to know about the call to set a file offset in your OPA for
the bitmap function calls. I can send an example of this too if you'd
like.

Good luck,
Mark ... in the land of Oz :~)
>>>
REM Refer to the C manual for details on these functions. The C function
names
REM are given in the line under the PROC definition below.

REM NB!!!: The sprite, bitmap and file ids are WSRV IDs not OPL's so
REM don't pass them to any OPL function.
REM When you have finished using these bitmaps or sprites, use wFree: to
free
REM each of them passing the WSRV id%.

REM You can use gInitB%: to open a bitmap file containing more than one
bitmap
REM once and for all and gGetB%: to read them. Note that the C SDK manual
has
REM a bug saying that gGetBit() returns zero on no error when in fact it
REM returns the WSRV bitmap ID.
REM gOpenB%: will open the file, load the bitmap and close the file again.

REM pPoint% args must point to two integers giving pixels {x,y}.
REM pSprite% points to a W_SPRITE structure listing the 6 bitmaps IDs in
the
REM bitmap-set in the same order as in OPL's appendSprite(), followed by
two
REM integers giving the pixel offset {x,y} followed by the time between
REM bitmap-sets. Use gInitB%: with gGetB%: (or use gOpenB%:) to load the
REM bitmaps, getting these IDs.
REM The window ID required for wCrtSpr%: is a WSRV ID not OPL's. Use the
REM OPL gInfo i%() command to find this id in i%(31).

rem
-------------------------------------------------------------------------

proc gInitB%:(file$,pCount%)
  rem gInitBit()
  local f$(130)

  f$=file$
  return call($e78d,uadd(addr(f$),1),0,0,pCount%)
endp

rem
-------------------------------------------------------------------------

proc gGetB%:(hand%,index%,flags%,pPoint%)
  rem gGetBit()
  rem !!! returns the WSRV bitmap ID !!!

  rem flags% should be zero for readOnly or 1 for readWrite

  return call($e88d,hand%,index%,flags%,pPoint%)
endp

rem
-------------------------------------------------------------------------

proc gOpenB%:(file$,index%,flags%,pPoint%)
  rem gOpenBit()
  rem flags% should be zero for readOnly or 1 for readWrite
  local f$(130)

  f$=file$
  return call($ae8d,uadd(addr(f$),1),index%,flags%,pPoint%)
endp

rem
-------------------------------------------------------------------------

proc wCrtSpr%:(wId%,pPoint%,flags%,count%,pSprite%)
  rem wCreateSprite()

  return call($f68d,wId%,pPoint%,0,pSprite%,count%)
endp

rem
-------------------------------------------------------------------------

proc wSetSpr%:(id%,pPoint%,index%,pSprite%)
  rem wSetSprite()

  return call($f58d,id%,pPoint%,index%,0,pSprite%)
endp

rem
-------------------------------------------------------------------------

proc gIniMlt%:(file$,count%)
  rem gInitMultiSave()
  local ax%,bx%,cx%,dx%,si%,di%
  local f$(130)

  f$=file$
  cx%=count%
  bx%=uadd(addr(f$),1)
  ax%=$ff00
  os($8d,addr(ax%))
  return ax%
endp

rem
-------------------------------------------------------------------------

proc gSavMlt%:(handle%,bitmap%)
  rem gSaveMultiBit()
  local ax%,bx%,cx%,dx%,si%,di%

  cx%=bitmap%
  bx%=handle%

  ax%=$ff01
  os($8d,addr(ax%))
  return ax%
endp

rem
-------------------------------------------------------------------------

proc gEndMlt%:(handle%)
  rem gEndMultiSave()
  local ax%,bx%,cx%,dx%,si%,di%

  bx%=handle%
  ax%=$ff03
  os($8d,addr(ax%))
  return ax%
endp

rem
-------------------------------------------------------------------------

proc wFree:(id%)
  rem wFree()
  rem Frees any WSRV entity - not for use with OPL IDs

  call($118d,id%)
endp
<<<


Subj:  Shift key                        Section: Psion Programming
  To:  Chris Nicholson, 100522,2324     Thursday, 27 June, 1996 2:09:18 PM
From:  John Boyce (Sysop), 100014,1240  #224165

Chris

You can't use Shift and a key on a Menu, you can only use Psion-x or
Shift-Psion-x. To specify them in the mCARD use lower case for Psion-x
(%x) and upper case for Shift-Psion-x (%X) (obviously substitute your key
for 'x').

You can tell if the Shift has been used by examining event%(2) - if
(event%(2) and 2)=2 then the shift has been pressed.

I hope this helps a little.

Best wishes

John


Subj:  Shift key                        Section: Psion Programming
  To:  Chris Nicholson, 100522,2324     Friday, 28 June, 1996 1:56:09 PM
From:  John Boyce (Sysop), 100014,1240  #224344

Chris

If you were to create a little program which displayed the ASCII values of
the pressed keys you would find that, regardless of whether the Shift key
is pressed, GET and GETEVENT return the same value if the Psion key is
pressed at the same time. MENU, however, doesn't so you will need to do
something like...

     GETEVENT i%()
     key%=i%(1)
     mod%=i%(2)
     ...
     mINIT
     ....
     menu%=MENU
     IF menu%<91
         mod%=2
         key%=menu%+32+512
     ELSE
         mod%=0
         key%=menu%+512
     ENDIF

And then, in your key catch loop have something like...

     IF key%=%f + 512
         IF (mod% AND 2)=2
             do whatever for Shift
         ELSE
             do whatever for no Shift
         ENDIF
     ENDIF

Of course, you will need to trap the other things that can be returned by
GETEVENT as well (such as $401) and you could omit the +32 and look for...

     IF key%=%F+512

I hope this gives you some ideas on how you need to go about things - if
you need more details don't hesitate to get in touch.

Best wishes

John


Subj:  Printing with PsiPrint?          Section: Psion Programming
  To:  Daniel Pfund, 101743,775         Wednesday, 10 July, 1996 3:28:24
PM
From:  Bertram Hochstetter, 100573,3530 #226552

Hallo Daniel,

>>how do you print with PsiPrint from within OPL?<<
Well, there is a code to call the normal print preview or the print option
and the print setup. In the print setup you must look after the
PsiPrint-printer and then call the print-preview or -option. You can then
print to the PC, I hope.


Use this:

---------------------------------------------------------------------------
-------------
REM print setup:
        SEND(PEEKW($38),25)

REM print preview:
        SEND(PEEKW($38),24,#1,#100,orec%(1))
        REM 100 is only a example.

REM print option:
        SEND(PEEKW($38),24,#0,#100,orec%(1))

---------------------------------------------------------------------------
-------------

REM a whole example
proc main:
        global orec%(300),styles%(10),msg$(10,40)
        msg$(1)="First line of the OPL printout"
        msg$(2)="This line is bold"
        msg$(3)="Three"
        msg$(4)="Four"
        msg$(5)="Five" REM and so on
        setstys:
        do
                busy off
                send(peekw($38),25)
                settext:
                actions:
                busy "PRINT OK"
        until get=27
endp

proc setstys:
        styles%(1)=6 rem bold italic
        styles%(2)=2 rem bold
        styles%(3)=4 rem italic
        styles%(10)=1 rem underlined
endp

proc settext:
        local i%
        i%=1
        do

                dinit "Define line "+num$(i%,2)
                dedit msg$(i),"Text",40+
                dialog
                i%=i%+1
        until i%>10
endp

proc actions:
        setorec:
        preview:
endp

proc setorec:
        local i%,j%
        i%=1
        while i%<300
                j%=1
                while j%<=10
                        orec%(i%)=styles%(j%)
                        orec%(i%+1)=len(msg$(j%))
                        orec%(i%+2)=addr(msg$(j%))+1
                        i%=i%+3
                        j%=j%+1
                endwh
        endwh
endp

proc preview:
        tidycom:
        send(peekw($38),24,#1,#100,orec%(1))
endp

proc tidycom:
        local wws%,com%
        wws%=peekw($12)
        com%=peekw(wws%+$1c)
        if com%
                send(com%,0)
                pokew wws%+$1c,0
        endif
endp

I found this example in the mailbox of Psion Germany. Have fun!

If you have some questions, please ask. I hope I can answer these then.

Bye,
        Sebastian PsiSoft/Germany
        (http://ourworld.compuserve.com/homepages/PsiSoft)


Subj:  PEEKW etc                        Section: Psion Programming
  To:  Patrick Bell, 101456,3524        Friday, 12 July, 1996 5:08:22 PM
From:  John W Dawson, 100415,370        #226953


Patrick

I'm not quite clear what you are trying to achieve here. However here is
an example that may help.

Normally you use ALLOC to reserve a block of memory in which you want to
store some data, use POKE instructions. E.g. to store 10 strings of 100
characters you need to allocate 1010 bytes (including a byte count for
each string):

  ptext%=ALLOC(1010)

ptext% points to the space for the first string, which you can store using
a POKE$:

  POKE$ ptext%, "First String"

To get to the the position of nth string you need to add (n-1) * 101 bytes
to the pointer (pointers are unsigned values so use UADD to avoid overflow
problems):

  POKE$ UADD(ptext%, (n%+1)*101), "String " + FIX$(n%,0,6)

However I would recomend that if you are doing 'serious' OPL programming
involving system calls and manipulation of complex data structures such as
dynamically sized arrays, then you should consider using Andy Clarkson's
excellent OPP Pre-Processor.

Please ask if you want further explanation.

Best wishes John


Subj:  Searching for Files              Section: Psion Programming
  To:  Paul R.Law, 100411,2311          Monday, 29 July, 1996 8:48:05 PM
From:  John Boyce (Sysop), 100014,1240  #230057


Paul

<< How can I get my opl programme to search all the drives for particular
files with a set path. I wish to use this with a dFILE command? >>

dFILE uses what is in the string as a clue to what to display (so, if the
string is "\DAT\*.DBF" then dFILE will start in the \DAT\ directory and
will show all files with a .DBF extension on the default drive). dFILE
will not display a list of matching files spanning drives as the drive has
to be specified separately. If you only wish to display the files that
match your clue in the string then you need to use type 8 (so the line
would be...

   dFILE file$,"Filename",8

).

<< How can I stop the aforemention dFILE command from displaying all files
in a given directory? >>

It is difficult to be specific without knowing precisely what you are
trying to do but the type number at the end of the dFILE line may be of
some help. However, if all you want to do is show all the files beginning
with 'S' then you could have "\DAT\S*.DBF" as your seed and this can be
adjusted as required.

Best wishes

John


Subj:  Terminate an Application         Section: Psion Programming
  To:  JOHN PIPER, 101547,2012          Thursday, 01 August, 1996 5:41:14
PM
From:  Mark Esposito (SYSOP), 72662,3050#231046

John,

    >> I have tried obtaining a Proc ID for the sheet [successfully], but
when I use the system call ProcTerminate <<

 Right, ProcTerminate is not a safe shutdown. You need to send a message
to the process telling it *nicely* to get the heck out of you life.<g>

 -----------------------------------------
    m$="X"
    call($da8d,pid%,uadd(addr(m$),1),1)
    Rem safe shutdown using wSendCommand
 -----------------------------------------

 If the app is locked, this won't work. You check to see if the app is
locked like this:

    call($91,pid%,2,0,$3a,addr(lock%)) REM check if locked - read 2 bytes
from addr $3a
    if lock%
        rem Application is busy
    endif
 ------------------------------------------

 Hope this helps.

  -Mark Esposito


Subj:  Dialog Boxes                     Section: Psion Programming
  To:  Christopher Farwell, 101766,3243 Friday, 02 August, 1996 7:53:23 PM
From:  Mark Esposito (SYSOP), 72662,3050#231313

Christopher,

    >> I'm creating a sub-routine which needs to be able to call a further
3 sub-routines depending on user requirements (ie 1, 2 or all 3) plus a
4th when all have been called or none are required. <<

 I don't know if this will help, but I'm going to post this code to my web
page. Might as well post it here. This is a multi-button window.

 -----------------------------------
 PROC appbut:
 local w%,q%,ty%,g%,p%,out%
 local act%
 act%=1
 onerr aerr
 ty%=0
 if act%=0
    w%=gcreate(480/2-200,160/2-40,402,80,0,1)
 else
    w%=gcreate(5,160/2-40,470,80,0,1)
 endif
 gxborder 1,$201
 ggrey 0
 gat 5,25 :glineby gwidth-10,0
 gstyle 1 :gat 5,20 :gprintb"Application Link",gwidth-10,3
 gstyle 0 :gat 5,40 :gprintb"Choose an Application to Link
to...",gwidth-10,3
 top::
 q%=(gwidth/(4+act%))-3

 wb::
 gat q%-80,gheight-30 :gbutton "(W)ord",1,80,20,ty%
 ty%=0 :if out% :pause 3 :gclose w% :return %w :endif

 db::
 gat q%*2-80,gheight-30 :gbutton "(D)ata",1,80,20,ty%
 ty%=0 :if out% :pause 3 :gclose w% :return %d :endif

 sb::
 gat q%*3-80,gheight-30 :gbutton "(S)heet",1,80,20,ty%
 ty%=0 :if out% :pause 3 :gclose w% :return %s :endif

 ab::
 if act%
    gat q%*4-80,gheight-30 :gbutton "(A)ct",1,80,20,ty%
    ty%=0 :if out% :pause 3 :gclose w% :return %a :endif
 endif

 pb::
 gat (q%*(4+act%))-80,gheight-30 :gbutton "(P)ic",1,80,20,ty%
 ty%=0 :if out% :pause 3 :gclose w% :return %p :endif

 if p% :p%=0 :pause 2 :goto top :endif
 gvisible on
 g%=get
 ty%=2 :p%=1

 if g%=27
        goto out
 elseif g%=291
        guse w% :gxborder 1,$202
        applhelp: :ty%=0 :p%=0 :guse w% :gxborder 1,$201 :goto top
 elseif g%=%w or g%=%W
        out%=1 :goto wb
 elseif g%=%d or g%=%D
        out%=1 :goto db
 elseif g%=%s or g%=%S
        out%=1 :goto sb
 elseif g%=%a or g%=%A
        out%=1 :goto ab
 elseif g%=%p or g%=%P
        out%=1 :goto pb
 else
        ty%=0 :p%=0 :goto top           /* Unsupported Key */
 endif
 out::
 gclose w%
 return
 aerr::
 giprint err$(err)
 if w% :gclose w% :endif
 Endp

 Proc applhelp:
        dinit
        dtext"","Help:  Application Links",$302
        dtext"","Notepad lets you link a note to an application"
        dtext"","file. Choose the application type, and then the"
        dtext"","actual file to open or create."
        dialog
 endp
 ------------------------------------------------

 Hope this helps.


  -Mark Esposito


Subj:  Dialog Boxes                     Section: Psion Programming
  To:  Christopher Farwell, 101766,3243 Friday, 02 August, 1996 1:24:28 PM
From:  Chris Nicholson, 100522,2324     #231227

>>I'm creating a sub-routine which needs to be able to call a further 3
sub-routines depending on user requirements (ie 1, 2 or all 3) plus a 4th
when all have been called or none are required.

I've used minit/mcard but thats a bit messy with the menu permanently
displayed and although dButtons would seem to be ideal, it only allows 3
exit keys.<<

Why not use a dialog box using the $402 command at the end which allows
the user to scroll to select. Example:

dinit "Heading text"
dtext "","Select option 1",$402
dtext "","Select option 1",$402
dtext "","Select option 3",$402
dtext "",Select option 4",$402
dia%=dialog
if dia%=1
        prog1:
        elseif dia=2
                prog2:
        elseif dia%=3
                prog3:
        elseif dia%=4
                prog4:
endif

Hope this helps?

Regards

Chris Nicholson - Hertford UK.


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


Subj:  Sheet                            Section: Psion Programming
  To:  Chris Nicholson, 100522,2324     Thursday, 15 August, 1996 6:26:27
PM
From:  Steven Burke, 100572,3442        #234034

Here's some code from one of my OPL programs.  It creates a spreadsheet.
I've missed out some code which sets landscape, etc., because this is very
specific to my requirements, but I hope the following will give you the
gist of what is happening.  Sorry if it's not very clear - I'm about to go
on holiday and I'm a bit rushed.  It will only be comprehensible by
looking at the various FAQ's relating to file formats.


PROC openspr:()  REM creates a spreadsheet
        local f$(70),ret%,h%,i%,off&
        f$="\spr\name.spr"
        ret%=IOOPEN(h%,addr(f$),$302)
        if ret%<0
                return 0
        endif
        f$="SPREADSHEET"
        i%=0
        do
                f$=f$+CHR$(0)
                i%=i%+1
        until i%=12
        off&=0
        ret%=IOSEEK(h%,2,off&)
        REM write header
        ret%=IOWRITE(h%,uadd(addr(f$),1),22)
        REM default col width
        f$=chr$(4)+chr$(0)+chr$(2)+chr$(0)+chr$(8)+chr$(0)
        ret%=IOWRITE(h%,uadd(addr(f$),1),len(f$))
        return h%  REM ie the handle
ENDP

PROC strinsh:(h%,w$,c%,r%)      REM adds a string w$ to spreadsheet,
                                REM at column c%, row r%
        local f$(50),lw$(80),ret%
        lw$=w$
        f$=chr$(2)+chr$(0)+chr$(len(w$)+8)+chr$(0)+
chr$(c%-1)+chr$(0)+chr$(r%-1)+chr$(0)
        f$=f$+chr$(10)+chr$(127)
        ret%=IOWRITE(h%,uadd(addr(f$),1),len(f$))
        ret%=IOWRITE(h%,addr(lw$),len(lw$)+1)
        f$=chr$(0)
        ret%=IOWRITE(h%,uadd(addr(f$),1),1)
ENDP

When finished, close with IOCLOSE(h%)

Steve



Subj:  IO programming in OPL/g          Section: Psion Programming
  To:  ALL                              Saturday, 17 August, 1996 5:59:08
PM
From:  Quentin Mayberry, 100271,2150    #234417

Can anyone point me in the right direction, I think I must be grasping
the wrong end of the stick here:-

Using the IO functions, if I create a binary file as so:-

#include <l_file.oph>

Proc testio:

local handle%,buf$(20),ret%,mode%,add%

Mode%= FCREATE OR FSTREAM OR FUPDATE

ret%=IOOPEN(handle%,"M:\test.fil",mode%)
 /* this seems to create the binary file with zero length*/
add%=ADDR(buf$)
 /* this gets me the address of the buffer that I am going to use */
ret%=IOWRITE(handle%,add%+1,20)
 /* and I assume that this writes 20 empty bytes to the file, as it has
now become 20 bytes long */

POKEB add%,ret%
 /*What is the object of poking in the byte count of the buf$, when I
already know it is 20? */

Endp

How can I actually write some information into these 20 bytes and then
be able to see what was written?

Quentin

Subj:  IO programming in OPL/g          Section: Psion Programming
  To:  Quentin Mayberry, 100271,2150    Sunday, 18 August, 1996 7:10:24 AM
From:  Wolfgang Schirmer(Sysop), 100022,1371#234498


Quentin,

<< POKEB add%,ret%  /*What is the object of poking in the byte count of
the buf$, when I already know it is 20? */  >>

you need this line only when reading some information with IOREAD. In this
case this line would be:

ret%=IOREAD(handle%,add%+1,20)

which allows you to read up to 20 bytes. If there are less bytes available
ret% contains the number of bytes read. To be sure that the length byte
contains the right information you hae to poke it into the first position
of the string.


Best wishes

Wolfgang@Hamburg


Subj:  IO programming in OPL/g          Section: Psion Programming
  To:  Quentin Mayberry, 100271,2150    Saturday, 17 August, 1996 8:58:25
PM
From:  Cade Roux (New Orleans), 73733,1014#234443

Quentin,

 >> local handle%,buf$(20),ret%,mode%,add%

buf$ is a string variable - it contains 22 bytes (I think)  1 byte
(probably, since OPL strings are restricted to 255 bytes) for max length,
1 byte for current length and then the data.  The ADDR() command returns
the address of the byte count.  (the max count shouldn't be touched _at_
_all_, since the runtime probably uses that to free up the allocated
block)

 >> POKEB add%,ret%
 >>  /*What is the object of poking in the byte count of the buf$, when I
 >> already know it is 20? */

You probably copied this code from a _read_ example?  When you read 20
bytes and then later want to interpret it as a string, you need to fool
OPL into thinking it is a real string by putting the actual byte count in
the normal position (unless you read it in that way from the file,
directly to addr(buf$) of course)

 >> How can I actually write some information into these 20 bytes and then
 >> be able to see what was written?

How about:

local handle%,buf$(20),ret%,mode%,add%

Mode%= FCREATE OR FSTREAM OR FUPDATE

ret%=IOOPEN(handle%,"M:\test.fil",mode%)
 /* this seems to create the binary file with zero length*/
add%=ADDR(buf$)

buf$="TEST.DATA.TEST.DATA." <<<<<<<<<<<< FILL buf$

 /* this gets me the address of the buffer that I am going to use */
ret%=IOWRITE(handle%,add%+1,20)

I think there's a hex file viewer available here in the library?

Cade




Subj:  Help on IOA                      Section: Psion Programming
  To:  All                              Sunday, 18 August, 1996 5:21:14 AM
From:  Tony Denson, 100034,1643         #234487

Can anyone tell me what device the following IOA is for -

 IOA(-2,14,Cstat%,arr%(),#(0))
  On a more general note is there a list anywhere of IOA/IOW calls (I have
the OPL SDK but it doesn't seem to be documented there).

Tony

Subj:  Help on IOA                      Section: Psion Programming
  To:  Tony Denson, 100034,1643         Sunday, 18 August, 1996 2:11:17 PM
From:  Tony Denson, 100034,1643         #234600

I've just realised that it's the KB handler (console chapter of the SDK
manual).

Tony

Subj:  Help on IOA                      Section: Psion Programming
  To:  Tony Denson, 100034,1643         Monday, 19 August, 1996 8:38:28 PM
From:  Mark Esposito (SYSOP), 72662,3050#234952

Tony,

    >> Can anyone tell me what device the following IOA is for -
    >>  IOA(-2,14,Cstat%,arr%(),#(0)) <<

 This is an asynchronous Getevent. It's almost the same as OPL's GETEVENT.

 /* from p_file.h */
 #define E_FILE_PENDING -46

 Proc sleep:
 local cstat%,keys%(2)        /* cstat% is our statusword - all asynch
services need them */
 IOA(-2,14,Cstat%,keys%(1),#(0))    /* getevent */
 do
     iowait
     if cstat%<>E_FILE_PENDING    /* event received */
         /* keys%(1) Tells you which event was received */
         if keys%(1) = $402        /* Our app has gone to the background
*/
             back:
         else ...
         elseif keys%(1)<$400 or keys%(1)>$405
             break        /* out of here */
         endif
     else
        giprint"oops - shouldn't get here"
     endif
 IOA(-2,14,cstat%,keys%(1),#(0))    /* re-queue getevent */
 until 0
 return keys%(1)
 Endp
 ------------------------------------------------------------

 The benefit of an asynchronous event loop is that you can have multiple
requests running at the same time. For example, the Pelican battery
checker program has a timer set to go off every second to update the
display, and it also has to check for keyboard/console events, messages
from the system screen. (like to close down)

 You need the above IOA() to do this. The IOWAIT is like GET, except that
it is waiting on one of our requests to complete. The code moves beyond
IOWAIT as soon as any request is completed. In the case of the battery
checker, the timer returns each second, but if the user presses the menu
key, this request is complete too, and my program knows the menu key has
been pressed.

 I hope this is clear.


  -Mark Esposito


Subj:  Word                             Section: Psion Programming
  To:  Chris Nicholson, 100522,2324     Tuesday, 27 August, 1996 4:53:16
PM
From:  Jochen Siegenthaler, 100127,3167 #236785


<< I am writing a program where I want the option of jumping to Word and
opening a predefined file, eg.  >>

Try this - it works on *any* file type, not just word, you can always
prune it down to just work with Word....

PROC View:(file$, Mode%)
        REM Analyses a file to see what type it is,
        REM then sets a command line for that app
        REM and launches it

        LOCAL pid%, ret%, cl$(128), off%(6)
        LOCAL als$(2), app$(6), n%

        ONERR ViewErr

        REM Set off%() so we can get the extension
        REM of the file
        PARSE$(file$,file$,off%())

        REM if Mode%=1 launch Word
        REM if Mode%=2 launch Text editor
        REM if Mode%=3 launch Auto detect
        VECTOR Mode%
                Word::,Text::
        ENDV

        REM open file
        REM read in 16 bytes and close
        IOOPEN(pid%, file$, $0400)
        IOREAD(pid%,UADD(ADDR(cl$),1),16)
        IOCLOSE(pid%)
        POKEB ADDR(cl$),16


        REM A file descriptor is normally 15 bytes
        REM terminated in 0x00, except for sheet.
        REM So we must detect 0x00 within first 16
        REM bytes to assume it is a file desciptor,
        REM otherwise show as text file in Word
        REM use pid% as a flag to indicate
        REM non-text (True) or text (False)

        ONERR Text
        POKEB ADDR(cl$),LOC(cl$,CHR$(0))-1 :rem find 0x00

        IF cl$ = "SPREADSHEET"  REM Sheet (odd one out!)
                app$="SH3"
        ELSEIF cl$ = "AgendaFileType*"  REM Agenda
                app$="Agenda"
        ELSEIF cl$ = "PSIONWPDATAFILE"  REM Word
                Word::
                app$="Word"
                als$=""

        ELSEIF cl$ = "OPLDatabaseFile"  REM Data
                app$="Data"
        ELSEIF cl$ = "WorldFileType**"  REM World
                app$="World"
        ELSEIF cl$ = "ALawSoundFile**"  REM Record
                app$="Record"
        ELSEIF cl$ = "ScriptFileType*"  REM Comms
                app$="Comms"
        ELSEIF cl$ = "OPLObjectFile**"  REM RunOPL
                app$="RunOPL"
        ELSE
                REM anything we can't detect show in Word
                Text::
                app$="Word"
                als$=" $"
        ENDIF


        GIPRINT "Running "+app$
        ONERR ViewErr
        REM build the command line cl$
        REM     1st char is O=open or C=create
        REM     then Icon to go under
        REM     then File extension and alias
        REM             for Word: ""=word, "$"=text, "O"=OPL, "S"=script
        REM     then File to open
        REM don't forget the CHR$(0) after each section
        REM pid% will contain the handle for the app launch
        cl$ = "O" + app$ + CHR$(0) +
MID$(file$,off%(5),LEN(file$)-off%(5)+1) + als$ + CHR$(0) + File$ +
CHR$(0)
        ret%=runapp%:("ROM::"+UPPER$(app$)+".APP", ADDR(cl$), ADDR(pid%))
        IF ret% :RAISE ret% :ENDIF
        RETURN


ViewErr::
        ONERR OFF
        REM error handler goes here
 GIPRINT "Error" ENDP


PROC RunApp%:(appname$,cmdl%,ppid%)
        LOCAL ax%,bx%,cx%,dx%,si%,di%
        LOCAL ret%,flags%
        LOCAL img$(128)
        img$=appname$+CHR$(0)
        ax%=$0100          REM set AH = 1 for "FilExecute" call
        bx%=ADDR(img$)+1   REM set BX = pointer to application name
        cx%=cmdl%          REM set CX = pointer to length of command line
        di%=ppid%          REM set DI = ADDRess to take process id
        flags%=OS(135,ADDR(ax%))  REM call "FilExecute"
        IF (flags% AND 1)
                ret%=(ax% AND $FF)-256  REM error returned from O/S call
in AL
        ELSE
                ax%=$0600        REM set AH = 6 for "ProcResume" call
                bx%=peekw(ppid%) REM set BX = process id
                flaDR(ax%))  REM call "ProcResume"
                IF (flags% AND 1)

       REM return success
                ENDIF
        ENDIF
        RETURN ret% ENDP


 --
Jochen @ Zurich, Switzerland


Subj:  Word                             Section: Psion Programming
  To:  Chris Nicholson, 100522,2324     Thursday, 29 August, 1996 2:32:05 AM
From:  Jochen Siegenthaler, 100127,3167 #237203


Chris,

<< I am unsure as to the 2 variables file$ and mode%. I will assume that
file$ is the name of the word file, does this have to be specially created
to work with this code, or can I use lopen test.wrd to create it ? What is
mode% ?  >>

file$ is the filename of the file to view.

From the code...

        REM if Mode%=1 launch Word
        REM if Mode%=2 launch Text editor
        REM if Mode%=3 launch Auto detect

..which means that...

        view:("\wrd\text.wrd",3)

..will view the file \wrd\text.wrd and *automatically* detect what
application to view it in (in this case word)

You can also use...

        view:("\agn\test.agn",3)

..to open an agenda file (called test.agn) in the Agenda application, and
then view:("\agn\test.agn",1) will open the agenda file in the Word
application, which is handy for analysing files sometimes - but be careful
that you do not save any changes, or you'll corrupt the file!

Regards, Jochen
 --
 Jochen @ Zurich, Switzerland
 Written on 28/08/96 at 20:14


Subj:  Word                             Section: Psion Programming
  To:  Chris Nicholson, 100522,2324     Monday, 02 September, 1996 5:52:06
PM
From:  Jochen Siegenthaler, 100127,3167 #238330


Chris,

The code you supplied me was incomplete.

Between the last ENDIF  and the endp you need the following code...

        GIPRINT "Running "+app$
        ONERR ViewErr
        REM build the command line cl$
        REM     1st char is O=open or C=create
        REM     then Icon to go under
        REM     then File extension and alias
        REM             for Word: ""=word, "$"=text, "O"=OPL, "S"=script
        REM     then File to open
        REM don't forget the CHR$(0) after each section
        REM pid% will contain the handle for the app launch
        cl$ = "O" + app$ + CHR$(0) +
MID$(file$,off%(5),LEN(file$)-off%(5)+1) + als$ + CHR$(0) + File$ +
CHR$(0)
        ret%=runapp%:("ROM::"+UPPER$(app$)+".APP", ADDR(cl$), ADDR(pid%))
        IF ret% :RAISE ret% :ENDIF
        RETURN


ViewErr::
        ONERR OFF
        ShowErr:("Cannot view """ +
Nice$:(MID$(file$,off%(4),LEN(file$)-off%(4)+1)) + """", ret%) ENDP


PROC RunApp%:(appname$,cmdl%,ppid%)
        LOCAL ax%,bx%,cx%,dx%,si%,di%
        LOCAL ret%,flags%
        LOCAL img$(128)
        img$=appname$+CHR$(0)
        ax%=$0100          REM set AH = 1 for "FilExecute" call
        bx%=ADDR(img$)+1   REM set BX = pointer to application name
        cx%=cmdl%          REM set CX = pointer to length of command line
        di%=ppid%          REM set DI = ADDRess to take process id
        flags%=OS(135,ADDR(ax%))  REM call "FilExecute"
        IF (flags% AND 1)
                ret%=(ax% AND $FF)-256  REM error returned from O/S call
in AL
        ELSE
                ax%=$0600        REM set AH = 6 for "ProcResume" call
                bx%=peekw(ppid%) REM set BX = process id
                flags%=OS(136,ADDR(ax%))  REM call "ProcResume"
                IF (flags% AND 1)
                        ret%=(ax% AND $FF)-256 REM error returned from O/S
call in AL
                ELSE
                        ret%=0         REM return success
                ENDIF
        ENDIF

        RETURN ret% ENDP

I have tested the code again and it works for me.

Regards, Jochen
 --
 Jochen @ Zurich, Switzerland
 Written on 02/09/96 at 22:41



Subj:  Shareware Registration           Section: Psion Programming
  To:  Peter Briggs, 106226,27          Tuesday, 27 August, 1996 10:25:21
PM
From:  Mark Esposito (SYSOP), 72662,3050#236863

Peter,

    >> Can anyone give me any info/sources of info for how best to
implement shareware registration into a program. <<

 You can make it simple, or if you're worried there are more complex
solutions. You can devise a registration number based on the users name,
or based on some other algorithm. You'll need to save the registration
number to file, or to an environment variable, the first being a bit
easier with standard OPL.

 Here's a shell for a simple solution:

 Proc Yourprogram:
 global legal%
 register:
 REM start program
 if legal%
    mcard "Options",etc.
 else
    mcard "Options",etc
 endif
 Endp

 Proc register:
 if exist("M:\myapp\myapp.cfg")
    trap open "M:\myapp\myapp.cfg",a,reg$
    if err
        REM report error, close program, or recreate the file based on
error
    endif
 else
        REM starting for the first time
        dinit
        dtext"","Welcome to Myapp",$302
        dtext"","whatever"
        dialog
        trap create "M:\myapp\myapp.cfg",a,reg$,start&
        if err :giprint err$(err) :pause 40 :stop :endif
        a.start&=days(day,month,year)    REM record start date if you want
crippling
        append :close :return
 endif
 if checknum:(a.reg$,a.start&)
    close
    legal%=1    REM registered user
 else
    close
    legal%=0    REM not registered
 endif
 Endp

 Proc checknum:(reg$,sd&)
 REM do whatever you want to do here to verify the registration number
 if days(day,month,year)>sd&+21

    dinit
    dtext"","Trial period is over",$302
    dtext"","blah blah blah",2
    dbuttons "Continue",13
    dialog
    return 0    REM or STOP if you want to be nasty<g>
 else giprint "You have such and such days left"
 endif
 return 1
 Endp


 This is simple, but I hope it may give you an idea anyway.


  -Mark Esposito



Subj:  Exit No.55??                     Section: Psion Programming
  To:  Peter Briggs, 106226,27          Tuesday, 03 September, 1996
6:26:24 PM
From:  Mark Esposito (SYSOP), 72662,3050#238607

Peter,

    >>  I want to print several differrent variables to a file on one line
looping x no. of times but I always want the string variable to take up
the same space (22 chars) <<

 Do you mean you want the text printed right or left justified? If not,
I'm not sure what you mean. Printing to file is easy though. Here's an
example:

 Proc tofile:
 open "M:\data.dbf",a,a$    REM first field only

 lopen "M:\test.xxx"        REM overwrites file if it already exists
 busy" Printing "
 do
    lprint right$(rept$(" ",22)+a.a$,22)    REM right justified
    lprint a.a$            REM left justified
    next
 until eof
 lclose
 close
 beep 10,200
 Endp

  -Mark Esposito


Subj:  Spaces                           Section: Psion Programming
  To:  Chris Nicholson, 100522,2324     Wednesday, 04 September, 1996
8:12:23 AM
From:  Daniel James [UK], 100024,704    #238732

Space is ASCII 32 (decimal) or $20

You might find this useful:

 Rem Display character code table
 PROC ctable:
  local i%,j%,First%
  print "   ";
  i%=0:do
    print 0;
    i%=i%+1
  until i%=16
  i%=0:do
  print 1;
  i%=i%+1
  until i%=16
  print
  print "   ";
  i%=0:do
    print hexstr$:(i%,1);
    i%=i%+1
    until i%=16
  i%=0:do
    print hexstr$:(i%,1);
    i%=i%+1
  until i%=16
  print
  j%=0:do
    print hexstr$:(j%,2),
    i%=0:do
      print char$:(i%+j%);
      i%=i%+1
    until i%=32
    print
    j%=j%+32
  until j%>=255
  get
 ENDP

 Rem returns integer vaue as Hex string of fixed length
 proc hexstr$:(val%,len%)
  return Right$(rept$("0",len%-1)+hex$(val%),len%)
 endp

 Rem Returns string containing character whose code is
 Rem passed as argument, or space if code is for a control char
 proc char$:(c%)
  if c%<3 or c%=5 or c%=6 or c%>13
    return chr$(c%)
  else
    return " "
  endif
 endp

It's one of the first things I wrote when I got my first Series 3.


Cheers,
 Daniel


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$(fi
x$(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


Subj:  WVE files in OPL                 Section: Psion Programming
  To:  Graeme Farnell, 101726,2606      Thursday, 05 September, 1996
3:36:10 PM
From:  Mark Esposito (SYSOP), 72662,3050#239294

Graeme,

    >> Does ANYONE know how to play WVE files in OPL - it must be possible
(I hope!). <<

 Proc playsnd:
 local snd$(129),t%,v%
 t%=100 :v%=1
 snd$="\wve\*.wve"
 dinit
 dtext"","Play a sound",$302
 dfile snd$,"",0
 if dialog=0 :return :endif
 snd$=snd$+chr$(0)
 call($1f86,uadd(addr(snd$),1),t%,v%)
 Endp

  -Mark Esposito


Subj:  Psion Help                       Section: Psion Programming
  To:  Peter Briggs, 106226,27          Saturday, 07 September, 1996
9:31:15 AM
From:  Jochen Siegenthaler, 100127,3167 #240025


<< Can anyone tell me how to make use of the Psion key to access help in
my programs.  >>

Easy... build a dialog (or menu) like this...

PROC main:
        LOCAL ky%

        DO
                dINIT "A little dialog"
                dTEXT "Title","Something",$400
                dTEXT "","Press Help for help",$200
                ky%=LastKey:(DIALOG)
                IF ky%=291
                        help:
                ELSEIF ky%=27
                        RETURN ky%
                ENDIF
        UNTIL ky%<>291 ENDP


PROC lastkey:(k%)
        REM This returns the last key pressed.
        REM Use: lastKey:(MENU) or lastKey:(DIALOG)
        REM Returns:
        REM          Quit key    Value
        REM          Enter      selection
        REM          Help         291
        REM          Esc          27
        REM Variable d%=dummy
        LOCAL d%
        IF k%                   REM Enter was pressed
                RETURN k%
        ELSE                    REM Esc or Help was pressed
                RETURN SEND(PEEKW($38),23,d%)
        ENDIF ENDP


PROC help:
        REM This is the help procedure
        REM each integer is 2 bytes, so buf%(65) is
        REM enough for 130 bytes for a filename
        REM r% is a general purpose variable
        LOCAL buf%(65), r%

        REM If any error, show "Help not found""
        ONERR NoHelp

        REM Convert help filename to "C" string: (use any char as first
char)
        REM C-string is terminated with a NUL (CHR$(0))
        REM Remember each buf%() takes 2 bytes of mem

        rem use this if you have an .opa

        rem     POKE$ ADDR(buf%(1)), "x" + PARSE$(".HLP",CMD$(1),buf%())
        rem otherwise use this
        POKE$ ADDR(buf%(1)), "x" + "loc::m:\opd\help.rsc") rem your help
file

        REM Set help filename
        ChkRet%:(SEND(PEEKW($38),27,buf%(2)))

        REM Show help
        REM r%=page and then base
        r%=1
        ChkRet%:(SEND(PEEKW($38),26,#r%,#r%))
        RETURN

        REM Some error, probably Help file not found,
        REM so show something
        NoHelp::
        ONERR OFF
        GIPRINT "Help not found" ENDP

 --
 Jochen @ Zurich, Switzerland
 Written on 07/09/96 at 12:59
 This email was made from 100% recycled electrons.


Subj:  Psion Help                       Section: Psion Programming
  To:  Peter Briggs, 106226,27          Saturday, 07 September, 1996
6:48:21 AM
From:  Martin Gartner, 106257,3267      #239999


<< Can anyone tell me how to make use of the Psion key to access help in
my programs. I recently downloaded the Psion Help Editor for Windows which
creates .rsc or .hlp files but I'm not really sure if I'm on the right
tracks & if so what to do to access the help files from within my
programs. >>



Hi Peter,

You are on the right way, here is a small listing of OPL Code you have to
insert in your Programm:

 IF ... here you have to ask for HELP-key ....

     POKE$ ADDR(buf%(1)),"#"+RSCpath$
     gate%=PEEKW($38)
     SEND(gate%,27,buf%(2))
     SEND(gate%,26,#page&,#base&)

 ENDIF

RSCpath$ has to include path for your 'help.rsc' file!


Hope I was a help!

(p.s. You can also trie the 'helpkit.zip' wich enables you to create/
compile your help files directly on 3a.)


Bye,

   Martin@Austria
   via ReadCIS&JBCIS


Subj:  Filesize in OPL ?                Section: Psion Programming
  To:  Martin Hoech, 106246,2364        Thursday, 12 September, 1996
6:04:11 AM
From:  Jochen Siegenthaler, 100127,3167 #242073


Martin,

<< I am writing a little OPL application and need to know how to find out
the size of a given file.  >>

Easy with an OS call. Try this....

 (everyone please excuse me for loading up lots of code)

PROC main:
        LOCAL temp1$(12),temp2$(12),temp3$(12),temp4$(55)
        LOCAL file$(128)
        LOCAL x%(5),cl$(150)
        LOCAL off%(6), buf%(40)
        LOCAL ret%,handle%,mode%,ctrl%,conn$(4)
        LOCAL ax%,bx%,cx%,dx%,si%,di%

        file$="loc::m:\somefile.ext"
        PARSE$(file$,file$,off%())

                ax%=$0800          REM set AX = 8 for "FileInfo" sub call
                bx%=ADDR(file$)+1 REM set BX = pointer to cstr file name
                cx%=ADDR(buf%())   REM set CX = pointer to 16 byte result
buffer
                dx%=0              REM set DX = 0 (unused)
                si%=0              REM set SI = 0 (unused)
                di%=0              REM set DI = 0 (unused)
                OS($87,ADDR(ax%))  REM call Function
                IF ax%<>0 :RAISE ax% :ENDIF

                REM get date and time of file
                DT:(PEEKL(UADD(ADDR(buf%()),8)), ADDR(temp2$),
ADDR(temp3$))

                REM get file attributes
                REM Offset  2 (word): attributes
                ax%=PEEKW(UADD(ADDR(buf%()),2))
                temp4$=""
                IF ax%+1 AND 1 :temp4$="Read only, " :ENDIF
                IF ax% AND 32 :temp4$=temp4$+"Modified, " :ENDIF
                IF ax% AND 2 :temp4$=temp4$+"Hidden, " :ENDIF
                IF ax% AND 4 :temp4$=temp4$+"System, " :ENDIF
                IF LEN(temp4$)=0
                        REM ensure we do not have a null string
                        temp4$="None set"
                ELSE
                        REM remove last ", "
                        temp4$=LEFT$(temp4$,LEN(temp4$)-2)
                ENDIF

                dINIT "File information"
                dTEXT "Path:",LEFT$(file$,off%(4)-1),0
                dTEXT "Name:", temp1$ ,0
                dTEXT "Size:",GEN$(PEEKL(UADD(ADDR(buf%()),4)),7) + "

Bytes",0
                dTEXT "Date & Time:",temp2$ + "  " + temp3$,0
                dTEXT "Attributes:",temp4$,$200
                DIALOG
 ENDP

You'll also need this...

PROC DT:(sc&,date%,time%)
        REM Returns date and time from supplied sc&
        REM seconds in the current system format
        REM sc& = time in seconds
        REM date% = address of a date string, must be
        REM         at least 8 bytes long
        REM time% = address of a time string, must be
        REM         at least 6 bytes long
        LOCAL yr%, mo%, dy%, hr%, mn%, sc%, yrday%
        LOCAL buf%, buf%(40), sep$(1), tmp$(7)

        REM now get the user preferences
        REM Use Fn $8B Sub $05
        REM Fills the buffer with country-specific data:
        REM  Offset  0 (word): country code (e.g. UK is 44) of locale
        REM  Offset  2 (word): current offset from GMT in minutes (+ is
ahead)
        REM  Offset  4 (byte): date format (0 = MDY, 1 = DMY, 2 = YMD)
        REM  Offset  5 (byte): time format (0 = am-pm, 1 = 24 hour)
        REM  Offset  6 (byte): currency symbol position (0 = before, 1 =
after)
        REM  Offset  7 (byte): currency symbol separated with space (0 =
yes, 1 = no)
        REM  Offset  8 (byte): currency decimal places
        REM  Offset  9 (byte): currency negative format (0 = minus, 1 =
brackets)
        REM  Offset 10 (byte): currency separate thousands
        REM                    (0 = no, 1 = yes, 4 = 10000 and over)
        REM  Offset 11 (byte): thousands separator
        REM  Offset 12 (byte): decimal separator
        REM  Offset 13 (byte): date separator
        REM  Offset 14 (byte): time separator
        REM  Offset 15 to  23: zero terminated currency symbol
        REM  Offset 24 (byte): start of week (0 = Mon, 1 = Tue, ... 6 =
Sun)
        REM  Offset 25 (byte): summer times group
        REM                    (1 = Home, 2 = European, 4 = Northern, 8 =
Southern)
        REM  Offset 26 (byte): clock type (0 = analogue, 1 = digital)
        REM  Offset 27 (byte): number of letters in day abbreviation (0 to
6)
        REM  Offset 28 (byte): number of letters in month abbreviation (0
to 255)
        REM  Offset 29 (byte): workdays (the set bits indicate the
workdays)
        REM    Bit 0: Monday
        REM    Bit 1: Tuesday
        REM    Bit 2: Wednesday
        REM    Bit 3: Thursday
        REM    Bit 4: Friday
        REM    Bit 5: Saturday
        REM    Bit 6: Sunday

        REM    Bit 7: always zero
        REM  Offset 30 (byte): units (0 = inches, 1 = centimetres)

        REM get days etc
        SECSTODATE sc&, yr%, mo%, dy%, hr%, mn%, sc%, yrday%

        REM fill buf%() with user options
        buf%=ADDR(buf%())
        CALL($58B,buf%,0,0,0,0)

        REM set time
        sep$=CHR$(PEEKB(UADD(buf%,14)))
        IF PEEKB(UADD(buf%,5))=1
                REM 24 Hour
                tmp$=cstr2$:(hr%) + sep$ + cstr2$:(mn%)
        ELSE
                REM 12 Hour am/pm
                tmp$=GEN$(MOD%:(hr%+12,12),2) + sep$ + cstr2$:(mn%)
                IF hr%>=12
                        tmp$=tmp$+"pm"
                ELSE
                        tmp$=tmp$+"am"
                ENDIF
        ENDIF
        POKE$ time%, tmp$

        REM set date
        sep$=CHR$(PEEKB(UADD(buf%,13)))

        REM vector uses less mem then IF..ENDIF
        VECTOR PEEKB(UADD(buf%,4)) :DMY,YMD :ENDV

        REM 0 = MDY
        POKE$ date%, cstr2$:(mo%) + sep$ + cstr2$:(dy%) + sep$ +
cstr2$:(yr%)
        RETURN

        REM 1 = DMY
        DMY:: :POKE$ date%, cstr2$:(dy%) + sep$ + cstr2$:(mo%) + sep$ +
cstr2$:(yr%)
        RETURN

        REM 2 = YMD
        YMD:: :POKE$ date%, cstr2$:(yr%) + sep$ + cstr2$:(mo%) + sep$ +
cstr2$:(dy%)

 ENDP

You should get the Psionics files for lots of useful system info.
 --
 Jochen @ Zurich, Switzerland
 Written on 12/09/96 at 08:38
 This email was made from 100% recycled electrons.


Subj:  Filesize in OPL ?                Section: Psion Programming
  To:  Martin Hoech, 106246,2364        Friday, 13 September, 1996 1:12:05
PM
From:  Barry Childress, 73510,1420      #242589

<< I am writing a little OPL application and need to know how to find out
the size of a given file. >>

This is what I do in Reader:

  r%=ioOpen(han%,file$,$200)
  filelen&=0
  ioSeek(han%,2,filelen&)

 -=Barry=-


Subj:  Spliting Long in OPL             Section: Psion Programming
  To:  A. Sparkowsky, 100703,1424       Saturday, 14 September, 1996
7:34:22 AM
From:  Konstantin Saliy, 106062,203     #242791


A.,

<< how can I split an OPL long (&) into to integer (low% and high%)? >>

Use PEEKW instead:

   low%=peekw(addr(l&))
   high%=peekw(uadd(addr(l&),2))

 Regards,
 Konstantin @ MOCKBA 14/09/96 15:16


Subj:  Icon in OPA file                 Section: Psion Programming
  To:  Don Hinds, 76004,612             Wednesday, 18 September, 1996
9:35:20 AM
From:  Mark Esposito (SYSOP), 72662,3050#243992

Don,

   >> What BYTES of the OPA file are the icon? <<


First 20 bytes = Signature

Next byte = length of OPL path name

Skip forward this amount past OPL path name

Next Word = length of Embedded PIC file.

  -Mark Esposito

Subj:  Dual channels on S3a             Section: Psion Programming
  To:  Graeme Farnell, 101726,2606      Friday, 27 September, 1996 1:55:24
PM
From:  Ian Pinkard, 106255,1266         #246541

There is an example in the programming manual, "2 tone ice cream van"(in
library). I went on from this to do a jingle for Ultimate Poker(also in
library). Here it is.

proc tune:(s%) rem s%=tempo
local nt%(9),a%,ret%,hndl%,len1%,slstat%,v%
local t$(30),t2$(30),b$(30),n1%(44),n2%(44)
t2$="5676587676587676523211" 
REM the notes channel 1, I used this method so that at some 
REM point I could pass a tune to this routine as three strings, or just one, I suppose. Could be 
REM useful if you were doing a game that needed lots of tunes.
t$=  "3454365454365454313233" rem the notes channel 2
b$= "1111121211121211121222" rem beats
nt%(1)=587 :nt%(2)=740 :nt%(3)=784 :nt%(4)=880
nt%(5)=988 :nt%(6)=1046 :nt%(7)=1174 :nt%(8)=1318 rem frequencies
a%=1 :len1%=22: v%=1400
do REM convert the strings into arrays of integers ready for playing
        n1%(a%*2-1)=nt%(val(mid$(t2$,a%,1)))
        n2%(a%*2-1)=nt%(val(mid$(t$ ,a%,1)))
        n1%(a%*2)=val(mid$(b$,a%,1))*s%
        n2%(a%*2)=n1%(a%*2)
        a%=a%+1
until a%=23
ret%=ioopen(hndl%,"SND:",-1)
if ret%<0
        print "Sound switched off on system screen" rem the usual problem
        get :return
else
        iow(hndl%,7,v%,#0) rem turn volume down
        ioc(hndl%,1,slstat%,n1%(),len1%) rem play ch1 notes
        iow(hndl%,2,n2%(),len1%) rem play ch2 notes
        iowaitstat slstat%
        ioclose(hndl%)
        endif
endp

The volume adjust I got from the Psionics files in the library. It's all
there if you keep digging.

Regards

Ian


Subj:  3c and Siena                     Section: Psion Programming
  To:  John Horn (Leeds, UK), 100413,3654Sunday, 29 September, 1996
4:01:23 PM
From:  Mark Esposito (SYSOP), 72662,3050#247031

John,

    >> I see how I could get away with the SIENA but how would a 3a and a
3c differ in this respect? <<

 They wouldn't. Most programs won't need to know they are running on a S3c
as opposed to a S3a, however, here is one way to know.

    Proc Myapp:
    local machtyp%,wid%
    wid%=gwidth
    if wid%=480
        machtyp%=1    REM S3a
        if exist("ROM::sys$irda.img")
            machtyp%=3    REM S3c
        endif
    elseif wid%=240
        machtyp%=2    REM siena
    elseif ...    REM add more here if you need them
    endif

  -Mark Esposito



