From: markson@incog.com (Tom Markson)
Subject: C SDK and make
Date: 3 Nov 1996 11:38:52 GMT

Hi,

Has anyone gotten the SIBO C SDK to work with standard makefiles instead
of the the .pr project files?  The release notes for TopSpeed indicate
this can be done with the "/link" option, but the compiler spits out an
"unknown option" message when I try to use it.

Thanks in advance,

--tom

From: "Dave Walker" <d.j.walker@slh0101.wins.icl.co.uk>
Subject: Re: C SDK and make
Date: 7 Nov 1996 11:15:32 GMT

Tom,

Tom Markson <markson@incog.com> wrote in article
<55i08c$q17@news.incog.com>...
> Has anyone gotten the SIBO C SDK to work with standard makefiles instead
> of the the .pr project files?  The release notes for TopSpeed indicate
> this can be done with the "/link" option, but the compiler spits out an
> "unknown option" message when I try to use it.

I have only ever succeeded in driving TopSpeed via the command line, and
embedding the relevant command line options in a Makefile.  With this it is
still necessary to have a .pr file, although you can control via the
makefile exactly which modules are rebuilt. I have found that it is still a
good idea to have a .pr file to set up many of the options.

Dave Walker


From: "Russell Lang" <russell.lang@bt-sys.bt.co.uk>
Subject: How to create text console in assembler
Date: 4 Nov 1996 08:13:01 GMT

Some questions from a beginner at Psion EPOC programming,
but reasonable experienced at Assembly and C programming
on a PC.

I'm trying to write some assembly code using the s3asm
assembler.  The code is intended to write a string
to the display, then wait for a keystroke.
The program just hangs.  
If the "iowrite" line is removed, the waiting for the 
keystroke bit works.
My code is below.  What (obvious) mistake am I making?

The second question is about alternatives to s3asm.
I have the Borland Turbo Assembler.  I might be able
to use this, but I would need to know the file format
for IMG and APP files.  Is this information available?
Are IMG files relocatable or fixed?

I don't have access to the EPOC SDK, only the OPL programming 
manual and the Psionic files.

	include \inc\io.inc

	image
testtxt db      "Test...",0
con     db      "CON:",0
stdout  dw      0
key     db      0

	code
	ioopen offset con, $0103, 0
	mov [stdout], ax
	iowrite [stdout], offset testtxt, 7
	ioread [stdout], offset key, 1
	ioclose [stdout]
	retf

From: kdw@dsbc.icl.co.uk (Keith Walker)
Subject: Re: How to create text console in assembler
Date: 8 Nov 1996 10:41:14 GMT

Russell Lang (russell.lang@bt-sys.bt.co.uk) wrote:

: The second question is about alternatives to s3asm.
: I have the Borland Turbo Assembler.  I might be able
: to use this, but I would need to know the file format
: for IMG and APP files.  Is this information available?
: Are IMG files relocatable or fixed?

The following is some information about the format of .IMG files which
may be usefull......

	Keith
--
Keith Walker, Fujitsu ICL, Lovelace Rd., Bracknell, Berkshire, UK     RG12 8SN
Email: kdw@oasis.icl.co.uk; Phone: +44 1344 472209 ; Fax: +44 1344 472987

-------------------------------------------------------------------------------
Series 3a Image file format

An image file begins with a 64 byte header of the following form:
  Offset  0 (cstr): "ImageFileType**"
  Offset 16(word): image version number (default is normally 0x200F)
  Offset 18 (word): size of the header
  Offset 20 (word): size of the code area in 16-byte paragraphs
  Offset 22 (word): Initial value for the IP register (usually 0)
  Offset 24 (word): size of the stack area in 16-byte paragraphs
  Offset 26 (word): size of the data area in 16-bytes paragraphs
  Offset 28 (word): initial size of the heap area in 16-byte paragraphs
  Offset 30 (word): size of initialized data in bytes
  Offset 32 (word): checksum of the code area
  Offset 34 (word): checksum of the data area
  Offset 36 (word): user definable version number (default normally 0x100f)
  Offset 38 (word): initial priority of the process (default is 0x80)
  Offset 40 (word): offset of 1st embeded file
  Offset 42 (word): length of 1st embeded file
  Offset 44 (word): offset of 2nd embeded file
  Offset 46 (word): length of 2nd embeded file
  Offset 48 (word): offset of 3rd embeded file
  Offset 50 (word): length of 3rd embeded file
  Offset 52 (word): offset of 4th embeded file
  Offset 54 (word): length of 4th embeded file
  Offset 56 (word): number of DYLs in the image
  Offset 58 (long): Offset the DYL entry descriptor table
  Offset 62 (word): not used

The code and data checksums are calculated by simply adding all the
bytes in the respective area together.

  Offset 64:  start of code data
  :
  :  (This area must be rounded up to a multiple of 16 bytes)
  :
  Offset 64+size of code area: start of initialised data
  :
  :  (This area must be rounded up to a multiple of 16 bytes)
  :
  Offset 64+size of code+size of initialised data: start of embeded files

The difference between a .IMG file and a .APP file is that a .APP
contains an embeded Icon file (.PIC), an embeded resource file
 (.RSC or .RSZ) and an embeded shell data file (.SHD).

The data segment of a running process consists of the follow areas:

  The "magic statics".  These occupy the addresses 0x0 to 0x3F.  This
			area is not included in the image file itself but is
			automatically added  when a process is loaded into
			memory.

  The stack area.       This area is not included in the image file itself but
			is created when a process is loaded into memory.
			The size of this area is determined by the size
			specified in the Image file header.

  The initialized data area.
			Initialised with data from the Image file.

  The uninitialized data area.

  The heap area.

NOTE: Due to the fact that the stack area is before the program
variables in the initialized or uninitialized areas, once a program has
been linked it is not possible to change the stack size as this would
change the offsets to these variables.

The "Magic statics" added into the data segement are as follows:
  Offset  0 (word): address which contains the value 0xDEAD
  Offset  2 (word): Next wait handler (not for application use)
  Offset  4 (word): Previous wait handler (not for application use)
  Offset  6 (word): Segment handle for language specific tables (not for
		    application use)
  Offset  8 (word): Class handle (not for application use)
  Offset 10 (word): class pointer (not for application use)
  Offset 12 (word): class handle (not for application use)
  Offset 14 (word): class pointer (not for application use)
  Offset 16 (word): enter/leave pointer (not for application use)
  Offset 18 (word): w_ws variable which is the handle to the window server.
		    Application code must set this up.
  Offset 20 (word): w_am variable which is the handle to the application
		    manager.  Application code must set this up. 
  Offset 22 (word): 
  Offset 24 (word):
  Offset 26 (word): Used by OPL translator.
  Offset 28 (word): Used by OPL transator.
  Offset 30 (word): (not for application use)
  Offset 32 (byte): (not for application use)
  Offset 33 (byte): (not for application use)
  Offset 34 (word): NULL or pointer to application display name.
  Offset 36 (word): Pointer to fully qualified name of the executable and its
		    arguments
  Offset 38 (word): Used by Psion test library
  Offset 40 (word):
  Offset 42 (word):
  Offset 44 (word):
  Offset 46 (word):
  Offset 48 (word):
  Offset 50 (word):
  Offset 52 (word):
  Offset 54 (word): Pointer to current dialog (if using dialogs)
  Offset 56 (word): Object handle
  Offset 58 (word): application can recieve termination or switchfile message
		    flag
  Offset 60 (word): Pointer to status window display string
  Offset 62 (word): Pointer to fully qualified file name



From: ttuinstr@gak.nl (Taeke S. Tuinstra)
Subject: Current File Pos 
Reply-To: ttuinstr@gak.nl, taeke@tst.xs4all.nl
Date: Mon, 11 Nov 1996 13:49:06 GMT

Hello all 

When moving around in a file opened for random access, using 
IOREAD IOWRITE IOSEEK, how do I determene the current 
position in the file. Thanks, Taeke
0) Start signature.
1) Never attribute to malice what can be adequately explained by stupidity.
2) I'm not an official spokesman for ASZ.
3) End signature.


From: ttuinstr@gak.nl (Taeke S. Tuinstra)
Subject: Re: Current File Pos
Reply-To: ttuinstr@gak.nl, taeke@tst.xs4all.nl

kis@ipmce.ru (Konstantin I. Saliy) wrote:

>ttuinstr@gak.nl (Taeke S. Tuinstra) wrote:

>>When moving around in a file opened for random access, using 
>>IOREAD IOWRITE IOSEEK, how do I determene the current 
>>position in the file.

>IOSEEK sets "offset" parameter to a value from beginning of the file. If you
>need just current position, seek to 0 bytes from the current position, and 
>see returned value. RTFM for details.

You are right, when RTBOHF I missed this sentence:

	IOSEEK sets the variable offset& to the absolute position set.

Thanks,  Taeke


From: wally@ceemore.demon.co.uk (wally wright)
Subject: Re: Current File Pos 
Date: Tue, 12 Nov 96 14:43:11 GMT
Reply-To: wally@ceemore.demon.co.uk

I've always used the following, although I'd be prepared to bet there's
a better way. Basically, you read 0 bytes relative to where you are now
(ie don't move the pointer at all), then rely on the fact that
IOSEEK updates the seek& parameter with the current position.

	seek&=0
	ioseek(handle%, 3, seek&)               REM 3 = Read Relative

This is often followed by:

	IOW(handle%, 11, seek&, #0)

which truncates the file to seek& bytes long.
\   \/   / -------------------------------------------------+-----------------+
 \/\/\/\/  Wally Wright, Information Support Ltd, Wokingham | +44 118 9770600 |
--------------------------------------------+---------------+-----------------+
Internet: wally@i-s-l.demon.co.uk (Work)    |  Compuserve: 101367,2040 (Home) |

From: Jochen Siegenthaler <jochen.siegenthaler@alcatel.ch>
Subject: Re: Current File Pos
Date: Wed, 13 Nov 1996 12:43:59 +0100
To: "Konstantin I. Saliy" <kis@ipmce.ru>

Konstantin I. Saliy wrote:
[snip]
> IOSEEK sets "offset" parameter to a value from beginning of the file. If you
> need just current position, seek to 0 bytes from the current position, and see
> returned value. RTFM for details.

Good to see you in the USENET Konstantin!

I have the same problem as the person who asked this.
I use IOOPEN to open a file as Text as I need to read each line of text
a line oat a time.

I cannot make an offset& and increment it with the amount of bytes read,
as IOREAD for a string can only read 255 bytes: if the line read is >255
bytes then a 'record too long' error occurs, and offset& would no longer
be correct.

So how can I find out the offset in a file IOOPENed as text?

Regards, Jochen
--
 Jochen Siegenthaler (Alcatel Telecom, Switzerland)
 mailto:jochen.siegenthaler@alcatel.ch
 http://www.alcatel.ch/ (now!)
 http://ourworld.compuserve.com/homepages/Jochen_Siegenthaler/ (private
page)

From: ajai@nwt.com (Ajai Khattri)
Subject: Re: Current File Pos
Date: Fri, 15 Nov 1996 01:13:26 GMT

On 13 Nov 1996 14:56:55 GMT, alanr@rd.bbc.co.uk (Alan Roberts), did
thus say:

|Jochen Siegenthaler (jochen.siegenthaler@alcatel.ch) wrote:
|
|: I use IOOPEN to open a file as Text as I need to read each line of text
|: a line oat a time.
|
|Text files are treated as sequential.
|
|: I cannot make an offset& and increment it with the amount of bytes read,
|: as IOREAD for a string can only read 255 bytes: if the line read is >255
|: bytes then a 'record too long' error occurs, and offset& would no longer
|: be correct.

This is probably less efficient however, is it possible to open the
file as a binary file and then check the file pos.?

I've not tried this, its just a suggestion.

Regards,
--
Aj. (ajai@nwt.com)
New World Technologies - `the Psion house'
(800) 886-4967 | +1 (212) 941-4633 | http://www.nwt.com

From: ajai@nwt.com (Ajai Khattri)
Subject: Re: Differences 3a-/3c-OPL?
Date: Fri, 15 Nov 1996 01:20:41 GMT

From: alanr@rd.bbc.co.uk (Alan Roberts)
Subject: Re: Current File Pos
Date: 21 Nov 1996 15:37:21 GMT

Jochen Siegenthaler (jochen.siegenthaler@alcatel.ch) wrote:

: You can use IOSEEK on text files:
: 
: For Text files, IOSEEK accepts 3 modes: P_FRSENSE, P_FRSET and P_FREWIND
: (4, 5, 6) to sense current position, return to it and rewind to the
: first
: record of the file. 
: 
: (Thanks to Konstantin for this info)

Thanks to Jochen and Konstantin for this one. I'll certainly be using it.

******* Alan Roberts ******* BBC Research & Development Department *******
* My views, not necessarily Auntie's, but they might be, you never know. *
**************************************************************************


From: "J.G. Ramage" <jgr@ulysses.att.com>
Subject: Re: SysCals $8D and $D6?
Date: Tue, 12 Nov 1996 15:33:46 GMT
To: "Konstantin I. Saliy" <kis@ipmce.ru>

Konstantin I. Saliy wrote:
> 
> PMFJH, I'll answer to J.G. Ramage question, which is not on my news server.

What question?  I made a statment... in question form.

> Just write a function which call all WServ functions, compile it and see
> results under debugger. You'll find which parameter to which register is
> passed, as well as interrupt number and AH register value (subfunction).
> 
> Note that debugger will show you opcode names rather than code to issue
> interrupt, but it is easy to convert them to what you want - see to bytes on
> the left size of assembler text. Interrupt code is CDh <IntNo>, and MOVE
> AH,<val>... don't remember ;-)
> 
> This is the answer to YOUR question. But you don't need to do it. I started to
> do it a year ago, but then I found that S3asm header files contain macroses to
> all WServe functions - just read them, you need nothing to do ;-)
> 
> The only work that might be useful is to combine SDK text with S3asm headers,
> to make description for users without SDK.

OK, that would work, but it goes *far* out of the way.  Just dump the
wlib.lib file and look for the MOVAH asm byte code under the section 
for the code you're trying to find. Take the MOVAH val and the next 
INT val and those are the numbers for the function call.
It's a lot quicker and won't cause any errors by trying to execute code 
that may not work out of context!

Dan Ramage  :)
  Damage@juno.com
  75452.3714@compuserve.com


From: brendan@informatik.uni-bremen.de (Brendan W. Breede)
Subject: Differences 3a-/3c-OPL?
Date: Wed, 06 Nov 1996 11:15:49 GMT

Does anybody know (because he already got the programming manual -
I didn't...) what important differences there are between 3a- and
3c-OPL? At least I'd like to know about the following so far:

1) how to get the analog-type 3c clock display (for QuickAlarm)

2) whether there is any 'automatic' frame style, i.e. the thin
   one if running on a 3c and the thick one on a 3a.

3) how to detect within the program whether it's running on a 3c
   (or a 3a)

4) Any changes regarding window handling (gCREATE)?

5) is it correct to presume that OPP runs without changes on a 3c?

6) is it correct to presume that any program that translates and
   runs ok on a 3a translates and runs ok on a 3c?
   
The reason why I'm asking is that some of my programs, translated
on the 3a emulator, run fine, but translated on the 3c crash with a
'no memory' error when doing a gCREATE. And I can' remember having
done any changes. I don't have the link yet, so I can't swap files.

______________________________\____________________Brendan W. Breede
					  \
brendan@informatik.uni-bremen.de              \
http://www.informatik.uni-bremen.de/~brendan/  \
________________________________________________\______________________________

From: brendan@informatik.uni-bremen.de (Brendan W. Breede)
Subject: Re: Differences 3a-/3c-OPL?
Date: Mon, 11 Nov 1996 06:28:41 GMT

In article <32807340.317421@news> I wrote:

>4) Any changes regarding window handling (gCREATE)?
>5) is it correct to presume that OPP runs without changes on a 3c?
>6) is it correct to presume that any program that translates and
>   runs ok on a 3a translates and runs ok on a 3c?
>The reason why I'm asking is that some of my programs, translated
>on the 3a emulator, run fine, but translated on the 3c crash with a
>'no memory' error when doing a gCREATE. And I can' remember having
>done any changes. I don't have the link yet, so I can't swap files.

After taking a deep breath, knocking on wood and closing my eyes
I decided to try a soft reset. And guess what - questions 4-6
apparently became obsolete... very strange.

Still leaves these three to be answered:

1) how to get the analogous type 3c clock displayed

2) whether there is any 'automatic' frame style, i.e. the thin
   one if running on a 3c and the thick one on a 3a.

3) how to detect within the program whether it's running on a 3c
   (or a 3a)
___________________________________\____________________Brendan W. Breede
brendan@informatik.uni-bremen.de              \
http://www.informatik.uni-bremen.de/~brendan/  \


On Mon, 11 Nov 1996 06:28:41 GMT, brendan@informatik.uni-bremen.de
(Brendan W. Breede), did thus say:

|3) how to detect within the program whether it's running on a 3c
|   (or a 3a)

Suggestion: check the screen size and if it is the same as the 3a
(i.e. 480 x 160) then check if SYS$IRDA.IMG is present in the ROM. If
both these are satisfied then you are indeed running on a 3c.

Regards,
Aj. (ajai@nwt.com)
New World Technologies - `the Psion house'
(800) 886-4967 | +1 (212) 941-4633 | http://www.nwt.com


From: alanc@donor2.demon.co.uk (Alan Clifford)
Subject: psion link protocol documentation
Date: 29 Nov 96 23:49:02 

Hello Nick

Replying to a message of Nick Mawby  to All:

 NM> Does anyone know the code to turn the psion remote link on and off
 NM> from within an OPL program? --  Nick Mawby

This is what I've got for turning it on:

proc runlink%:
 local regs%(6), link$(128), info$(128), stat%, pid%, flags%, errno%
  rem first close comport
  lclose
  link$ = "ROM::LINK.IMG" + chr$(0)
  info$ = "-B19200" + chr$(0)
  regs%(1) = $0100
  regs%(2) = uadd(addr(link$), 1)
  regs%(3) = addr(info$)
  regs%(4) = addr(stat%)
  regs%(5) = 0
  regs%(6) = addr(pid%)
  flags% = os($0087, addr(regs%()), addr(regs%()))
  print "flags", hex$(flags%);"H"
  print "UL", flags% and $1
  print "EQ", flags% and $40
  print "SL", flags% and $80
  errno% = regs%(1) and $FF00
  print "error", errno%, err$(errno%)
  if errno% = 0
   regs%(2) = pid%
   regs%(1) = $0600
   os($0088, addr(regs%()), addr(regs%()))
  endif
  rem pause 0
endp

Alan

From: brendan@informatik.uni-bremen.de (Brendan W. Breede)
Subject: Re: Help: gCLOCK
Date: Sat, 30 Nov 1996 08:40:34 GMT

In article <memo.961129171744.15599A@dircon.co.uk> steveg@dircon.co.uk (Steve
Godfrey) wrote:

>0 - small digital
>1 - medium
>2 - large analog
>3 - medium2 (follows system setting)
>4 - extra large analog
>5 - formatted
>6 - siena/s3c medium (follows system setting on s3c)
>7 - s3c large

Even better, Steve - just, where's the small digital 3a one gone?
Type 0 gives me a Series 3 one. And how can I force the medium digital
ones, i.e. type 1/3/6 _not_ following the system setting?

I think, _then_ we have all together ;-)

I suppose for type 5 I have to add parameters to the call like in
gCLOCK, though I haven't tested this yet.

BTW, is there an 'autotype' border style which gives me the thin one
for 3c's/Siena's and the thick one for 3a's?

And do you know whether it is 'legal' to check for the machine the
program is running on by the rom version number, i.e.:

  1.* - Series 3
  2.* - Workabout
  3.* - Series 3a
  4.* - Siena
  5.* - Series 3c

Cheers,
____________________________________\____________________Brendan W. Breede
					  \
brendan@informatik.uni-bremen.de              \
http://www.informatik.uni-bremen.de/~brendan/  \

From: stevegodfrey@dircon.co.uk (Stephen Godfrey)
Subject: Re: Help: gCLOCK
Date: 30 Nov 1996 17:06:52 GMT

In article <329fe8da.3650142@news>, brendan@informatik.uni-bremen.de 
(Brendan W. Breede) wrote:

> Even better, Steve - just, where's the small digital 3a one gone?
> Type 0 gives me a Series 3 one. And how can I force the medium digital
> ones, i.e. type 1/3/6 _not_ following the system setting?

To force type 3 or 5 regardless of the system setting, OR the flags with:

0x40 for analog
0x80 for digital

> BTW, is there an 'autotype' border style which gives me the thin one
> for 3c's/Siena's and the thick one for 3a's?

Nope! Sorry
 
> And do you know whether it is 'legal' to check for the machine the
> program is running on by the rom version number, i.e.:
> 
>   1.* - Series 3
>   2.* - Workabout
>   3.* - Series 3a
>   4.* - Siena
>   5.* - Series 3c

I think it's probably the best way of checking the machine type, don't 
think it'll cause any problems

Cheers
Steve


From: Shiftc <bob@earthlink.net>
Subject: Re: Looking for some programming advice - OPL
Date: Sat, 30 Nov 1996 06:26:12 +0000

Kevin Jones wrote:
 
> fil@mojo.europe.dg.com "Phil Davidson" writes: 
> > Any advice on how to best implement a registration function for a
> > shareware application.
> > A method whereby I can issue a registration code to activate specific
> > functionality!?

> Hey, just what I would like to know, too!

One idea is to take the persons name. Encrypt it with the psions os call 
using a password you and the program know. Then take a CRC from this. 
Also available from an OS call. This will give you a unique number. 

Make the user enter their name exactly as you did to get the CRC and also 
enter the CRC you returned. Then make your program save a file with the 
owners name and the CRC. At any time your prog can check the users name 
for an 'about' dialog and recheck the CRC is valid for that name. 

If the user passes the registered prog on. His name will show on the 
dialog. If he changes it the CRC will be wrong.

There are many ways but that is how I would do it. 

Bob Munson

From: wmagnus@ibm.net (Warren Magnus)
Subject: Siena OPL Excentricities
Date: Sat, 30 Nov 1996 09:18:43 -0500

Just got the Siena 2 days ago and love this teeny thing. However, I have
discovered that when using the OPL INPUT command, that the Siena does not
recognize the decimal point on the numeric keypad and the period from the
main keyboard must be used. Does anyone have any suggestions or should I
just hack together my own input routine to call when the need arises?
-- 
Warren Magnus, DO
wmagnus@ibm.net


From: Jochen Siegenthaler <jochen.siegenthaler@alcatel.ch>
Subject: Re: HELP with OPL to recieve ASCII characters from com port
Date: Thu, 05 Dec 1996 11:28:42 +0100

Andy Jefferies wrote:

> This module is first sent a command via the comms port to request that
> it return information to the Psion ( Not too difficult ) 

Easy: LOPEN the Com port and then LPRINT to it.

> then the Psion
> has to wait for a reply (Device not responding ? Timeout ?). The reply
> from the aquisition device will be in ASCII but although the response
> may vary in length it will allways begin with # (hash) and end with !
> (exclamation).

If the data ends in any combination of CR+LF then use the standard ASCII
receive routine supplied in the OPL programming manual.

If there is no CR+LF and you do not know the length of the data being
received (any length byte used?) then you can use the routine that
johnshoy@os2bbs.com supplied.

Jochen
--
 Jochen Siegenthaler (Alcatel Telecom, Switzerland)
 mailto:jochen.siegenthaler@alcatel.ch
 http://www.alcatel.ch/ (now!)
 http://ourworld.compuserve.com/homepages/Jochen_Siegenthaler/ (private
page)

From: johnshoy@os2bbs.com
Subject: Re: HELP with OPL to recieve ASCII characters from com port
Date: 4 Dec 1996 22:56:50 GMT

In <GX1tUBA3sepyEwY0@phytolex.demon.co.uk>, Andy Jefferies <Andy_J@phytolex.demon.co.uk> writes:
>HELP!
>
>I'm trying to learn OPL on a series 3a. The current objective I have is
>to communicate with a data aquisition / control module that uses RS232.
>This module is first sent a command via the comms port to request that
>it return information to the Psion ( Not too difficult ) then the Psion
>has to wait for a reply (Device not responding ? Timeout ?). The reply
>from the aquisition device will be in ASCII but although the response
>may vary in length it will allways begin with # (hash) and end with !
>(exclamation). 
>
>
>Any Ideas on how I should tackle the recieve routine ??
>port settings 9600,8,1,N 

Andy,

Here is some code I wrote to "waitfor" a string to appear on the serial port.
It's actually a utility to be used with the "shell3a" command line shell for the
Psion.  I have written a "send", which when used with the "waitfor" command
shown here (and the built in scripting ala batch files in shell3a) might do much
of the job you're trying to do.

My code has some additional complexity due to trying to match the desired pattern
against the incoming stream, and being able to resynch after a mis-match without
actually having to back up.  Probably hard to figure out what's going on in that part
of the code without consulting any good algorithm book on the Knuth-Morris-Pratt
algooorithm.  (Or you can just gut that part of the code out and just look at the
part you really wanted anyhow).

I await your questions!  Good luck.

Mike Johnshoy

rem shell3a external command - waitfor.opl
rem Wait for string to arrive on serial port.
rem Based on Knuth-Morris-Pratt algorithm
rem by: Mike Johnshoy (johnshoy@os2bbs.com)
rem October 1996

rem Usage: waitfor "string"

PROC waitfor%:(args%)
local hnd%,len%,char$(1)
local pattern$(255),recover%(255)
local patlen%
local pos%,match%

rem check for argument
if args%<>2  rem need exactly one filename to send
	print "Usage: waitfor <string>"
	return
else  rem get pattern to waitfor
	pattern$=peek$(argv%(2))
endif
patlen%=len(pattern$)

rem check to see if serial port open already (possibly by 'mode' command)
trap lopen "TTY:A"
if err=0 rem port just opened, and OK
elseif err=-113  rem port was already opened
elseif err=-41  rem no serial port
	print "Error: unable to open serial port"
	return
else  rem unknown error
	raise err
	return
endif

rem create partial match table
pos%=2 : match%=1
recover%(1)=0
while pos%<=patlen%
	if mid$(pattern$,pos%,1)=mid$(pattern$,match%,1)
		recover%(pos%)=match%
		match%=match%+1
	else
		recover%(pos%)=0
		match%=1
	endif
	pos%=pos%+1
endwh

rem pattern search, using partial match table created above
hnd%=-1 : len%=1
IOREAD(hnd%,uadd(addr(char$),1),len%) rem get a char from serial port
POKEB addr(char$),1
match%=1  rem pointer to next character in pattern to test
while 1  rem keep waiting for a match
	if KEY=27 : break : endif rem quit if 'Esc' key pressed
	if mid$(pattern$,match%,1)=char$
		if match%=patlen%  rem just matched last char in pattern
			return  rem COMPLETE MATCH!
		else  rem get next charcter to test
			IOREAD(hnd%,uadd(addr(char$),1),len%) rem get a char from serial port
			POKEB addr(char$),1
			match%=match%+1  rem prepare to test against next char in pattern
		endif
	else  rem recover from mismatch
		if match%=1
			IOREAD(hnd%,uadd(addr(char$),1),len%) rem get a char from serial port
			POKEB addr(char$),1
		else
			match%=recover%(match%-1)+1
		endif
	endif
endwh
ENDP


From: Steve Boswell <stevieb@x-file.cix.co.uk>
Subject: Re: Wait for Key or refresh screen...
Date: 05 Dec 96 15:57:48 +0000

>time I'd like to scan for a key pressed (menu key).  The problem is if I do
>it using a do loop slows down all other OPL programs terribly.  Is there a
>way to better do this?

What are you doing in your do loop?
Try this

    LOCAL K%(6),Statim&, NowTim&
    StaTim& = DATETOSECS(YEAR,MONTH,DAY,HOUR,MINUTE,SECOND)
loopy::
    WHILE NOT TESTEVENT             REM Wait for an event
	NowTim& = DATETOSECS(YEAR,MONTH,DAY,HOUR,MINUTE,SECOND)
	IF NowTim& - StaTim& > 60   REM Has a Minute Gone by?
	    REM Do some stuff here and update your screen
	    StaTim& = NowTim&
	ENDIF
    ENDWH
    GETEVENT K%()
    IF K%(1) = 290 REM Menukey
	REM do your menu stuff here
    ENDIF
    GOTO loopy::

I don't know what the effect of all those DATETOSECS calls will be on
system performance, you would probably be better off setting up a timer
event (I've got some sample code for that here somewhere if you want it)
 __
(_                              /      stevieb@x-file.cix.co.uk
__)teve Boswell [ENTP]         /  http://www.compulink.co.uk/~x-file

From: alanc@donor2.demon.co.uk (Alan Clifford)
Subject: Wait for Key or refresh screen...
Date: 01 Dec 96 17:11:17 

Hello "Eric

Replying to a message of "Eric Nichols"  to All:

 "N> This may seem a bit basic for some.  I'm writing an opl program that
 "N> will update the screen every minute with new calculated data.  During
 "N> this wait time I'd like to scan for a key pressed (menu key).  The
 "N> problem is if I do it using a do loop slows down all other OPL
 "N> programs terribly.  Is there a way to better do this? Any ideas would
 "N> help!  I've been writing some simple programs on my home page.  If
 "N> anyone has any tips I'd be glad to post them with an example program!
 "N> many thanks

I'm doing this with my current project with the keyboard, a timer and the
serial port. You need to do it asychronously - it's all in the "devices"
Psionics file.  Here's the basics of what you need to do, in the style that I'm
doing it (whether that is correct or not ....)

PROC timer:
 rem Psion...Esc to end
 global timstat%, timhdl%
 local tdelay1&
 global keystat%, keyval%(6)
 
 IOOPEN (timhdl%,"TIM:", -1)

 tdelay1& = 100  rem 10 tenths sec
 
 IOC(timhdl%,1,timstat%, tdelay1&, tdelay1&) rem set up timer
 IOC(-2,1,keystat%, keyval%(),keyval%()) rem set up key read
 
 while 1
  print "waiting - Psion...Esc to end"
  iowait
  if timstat% >= 0
   rem set up timer again
   IOC(timhdl%,1,timstat%, tdelay1&, tdelay1&)
   print "timer 10 secs"
   rem call a function here
  endif
  if keystat% >= 0
   print "keyboard", chr$(keyval%(1))
   rem call a function here
   rem set up again
   IOC(-2,1,keystat%, keyval%(),keyval%()) rem set up key read
  endif
 endwh
ENDP

Alan

From: ajai@nwt.com (Ajai Khattri)
Subject: Re: Bitmaps and Sprites
Date: Mon, 02 Dec 1996 21:49:20 GMT

On Thu, 28 Nov 96 12:23:25 GMT, Kevin Jones <Kev@abrdg.demon.co.uk>,
did thus say:

|1)  id%=gLOADBIT(name$,write%,i%)  [page 187 of programming manual]
|
|Can anybody explain how to use the i% parameter?  Its a neat idea to put ALL
|of the bitmaps of an application into one file, and retrieve them as needed.
|What's the file format required for multiple bitmaps...?

The last i% in the GLOADBIT construct specifies which bitmap in the
file to load. Normally a black and grey bitmap actually consists of
two bitmaps in the file -- black (i% = 0) followed by grey (i% = 1).
Most bitmap editors for the 3a produce a dual-bitmap PIC file. If you
want to put more than two files together in one PIC file then you will
need to use WSPCX which is a DOS program available on the net for free
(e.g. ftp://ftp.nwt.com/s3a/developer/wspcx.zip). Multiple-bitmap
files are just big PIC files.

|If I use one file of, say, 3 bitmaps, how could I extract these 3 bitmaps
|into 3 sprites?  Must the bitmap$() array [taken from example on pages
|124/124 of programming manual] array contain only names of bitmap FILES,
|or can I realte them to bitmaps held in memory?

The APPENDSPRITE call used to create the sprite in memory requires
filenames (which implies one frame per PIC file). I have created
animated sprites using a set of 10 black bitmap files and a set of 10
grey bitmap files. Once loaded into memory, the sprite can be
displayed at will using the DRAWSPRITE command. The sprite frames once
loaded are retained in memory. I think there is a system call that
might be able to load multiple bitmaps from the same file. If you want
I can send you example code.

|I understand using bitmap$(3) for inverting black pixels and using bitmap$(6)
|for inverting grey pixels.  How do I use the other elements of the arrays
|to purely SET or purely CLEAR bits?  I've played around a bit, but with
|no success.

I have used only the SET arrays for the black and grey planes -- the
rest can be ignored. This works fine for most animations.

|If code is distributed to other machines, it would be nice if EVERYTHING was
|contained within one .OPA file (or .OPD file)  Is it possible to effectively
|'attatch' or 'include' a bitmap file with an executable piece of software
|to produce one distributaable file.....?!?

Normally you can specify an icon between APP and ENDA statements with
an ICON statement (see page 111 of the Programming Manual). One clever
trick is to append the bitmaps to the icon file (which itself is a
dual bitmap file). I have done this in C and a similar technique can
be employed in OPL.

Cheers,
Aj. (ajai@nwt.com)
New World Technologies - `the Psion house'
(800) 886-4967 | +1 (212) 941-4633 | http://www.nwt.com


From: kdw@dsbc.icl.co.uk (Keith Walker)
Subject: Re: Development environment
Date: 12 Dec 1996 21:34:04 GMT

Mike Meyer (bouncenews@contessa.phone.net) wrote:

: If it's just the includes, then CPOC ought to be enough to finish the
: job. I'll certainly add that to the list of things to check on.

When my brother contacted Psion about using the Psion include files as
part of CPOC they had no objections.

Hopefully CPOC will make some progress over the Christmas/New Year
period as my brother and I will be able to get together to do some
serious development work on it.

	Keith
--
Keith Walker, Fujitsu ICL, Lovelace Rd., Bracknell, Berkshire, UK     RG12 8SN
Email: kdw@oasis.icl.co.uk; Phone: +44 1344 472209 ; Fax: +44 1344 472987


From: pfund3@uni2a.unige.ch (Daniel Pfund)
Subject: Re: Assembly programming on Psion - Help Please
Date: 16 Dec 96 15:02:40 +0200

In article <martin-1512961645370001@roget.demon.co.uk>, martin@roget.demon.co.uk (Martin Kendall) writes:
> Has anyone had any luck getting hold of the book "Machine Code programming
> on the Psion Series 3a" by John Farrant - as mentioned in the FAQ.

It has been discussed some time ago that the book was crap.
It's not worth it. Buy a general ASM book, you'll be better off to learn
ASM. If you need Psion stuff... call/mail/fax Psion until you get an
answer :-(

Regards,
Daniel Pfund
   http://www.geocities.com/SiliconValley/8130/
Find the Psion Series3(a) FAQ and everything you ever wanted
to know about those palmtops on my pages!  Be there or be []

