Re: Screen contrast under program control?
>The title says it all! Is is possible to control screen contrast
>from a program. I would like to fade in and fade out a 
>title screen on my series 3.

>Richard

The following program can alter the contrast for you.
 
PROC contrast:
  local ax%,bx%,cx%,dx%,si%,di%   : rem keep together
  
  ax%=$1201
  os($8e,addr(ax%))
ENDP
 
set ax% to $12ff to decrease the contrast, and to $1201
to increase the contrast.
 
You can also read the current contrast setting using:
 
c%=call($138e)
 
Steve Godfrey
Psion PLC


Subject: Re: Findfeild OPL BUG ?

> And yes, I do know about the flags parameter
> being wrong in the user manual. Here's a quicky program to show the 
problem:

Ah but do you know the other problems ?

You may experience a number of problems using FINDFIELD when the command 
fails to find a match on searching backwards. You are advised therefore 
not to use FINDFIELD when this condition could occur. This problem 
applies to the Series 3a only.


   On failing to find when searching backwards, FINDFIELD discards the 
first record in its internal buffer, so that a call to FIRST always 
causes all fields to be empty (in the case of strings) or zero (in the 
case of numeric fields).

   On failing to find when searching backwards, FINDFIELD does not, as 
expected, return 0. Instead it positions to the first record and returns 
1.

   FINDFIELD does a FIND in some cases.

Workaround
Before each call to FINDFIELD you should have the following line:
POKEB PEEKW($1C)+7,0

Regards Dave@Psion


Article: 16315 of comp.sys.psion
Subject: Re: Translating large OPL files
> Has anyone seen a translator for the Psion that can handle files > 40k like
> s3atran for the PC?
>

The basic problem here is not with the translator itself but with the
Psion Word application (Program and Word are the same application).
Word can only handle 40K of text and therefore because the translator
is normally run from the Program application you cannot create large
OPO modules.

If you want a Psion solution then there are two options:

- Break your program up into source files < 40K and use the OPL LOADM
  command to load the resultant OPO files into the main module.

- I have written a shareware preprocessor called OPP, which you could
  use.

OPP is a preprocessor for OPL, much like a C preprocessor. OPP runs on
the Psion and provides similar facilities to S3ATRAN such as #define,
#ifdef. Using OPP you can write the following OPL code on the Psion
and translate it directly on the Psion via OPP:

      #define ARRAY_SIZE        10
      #define FN(x)             (3*x**2+2*x+1)

      /* Here is the main procedure */

      PROC main:
	  local x%, y%(ARRAY_SIZE)
	  #ifdef DEBUG      /* print debug info if required */
	    print "In main"
	  #endif
	  while x%<ARRAY_SIZE
	    x%=x%+1
	    y%(x%)=FN(x%)
	  endwh
      ENDP

OPP also allows the #include directive so you can include a number of
files into another file. Using the #include directive you can work
around the 40K limit of Word and could build very large single file
OPO modules on the Psion. To do this create a small OPL file with a
number of #include statements and then use OPP to translate the
separate OPL files into one large OPO file.

Version 1.0 of OPP is available via ftp from src.doc.ic.ac.uk:

/pub/packages/psion/icdoc/comp.binaries.psion/volume95/Jun/950619.12.gz
/pub/packages/psion/icdoc/comp.binaries.psion/volume95/Jun/950619.13.gz

I am working on version 1.1 at the moment which will add support to OPL
for the following:

- Multi-dimensional arrays
- Create procedure libraries (put all your useful PROCs in a file and
  OPP will only include the ones that have actually been called)
- Support for C style operators ++, --, +=, -=, *=, /=

+---------------+-----------------------------------+---------------+
| Andy Clarkson | Home : 100661.2440@compuserve.com | Cambridge, UK |
|               | Work : andy@smallworld.co.uk      |               |
+---------------+-----------------------------------+---------------+


Article: 16441 of comp.sys.psion
Subject: Re: OPL Questions!!!
> This is an update to a previous posting about the PSION Workabout, but
> since there were no responses, we thought we would make it more generic
> to see if anyone had any general information.
> 
> We need to know if:
> 
> 1) Anyone can respond showing how to read an ASCII file using OPL...
> 
> 2) There are any sample programs available that will show how to read
> an ASCII file using OPL...
> 
> Any help would be greatly appreciated. Thanks!!!!!
> 
> 

REM chopped out of a larger program, opening an ASCII file named in Name$

PROC Scanin:(Name$)
	Local Line$(132),I%,J%,Hand%,Lp%,K%
	K%=Addr(Line$)
	I%=IOOPEN(Hand%,Name$,$420)
	if I%=0
		do
		J%=MyRead%:(Hand%,K%)
		if J%<=0
			REM an error happened, or zero length line
			Continue  
		endif
		rem we now have a line of text
		rem processing stuff here


		until J%<0 
		if J%<>-36 and J%<0 
			REM error other than EOF or zero length
			ALERT (ERR$(J%))
		endif
		IOCLOSE(Hand%)
	ENDIF
ENDP

REM dunno why a procedure but here it is.

PROC MyRead%:(Hand%,K%)
	Local J%
	J%=IOREAD(Hand%,K%+1,132)
	PokeB K%,J%
	Return J%
ENDP

---------------------------------  
-- Mike James G6IXE            --  
-- Using an Acorn RISC PC 600  --  My other Computer's a ... 6800 .. 6809 ..
-- a British, ARM Powered      --  ZX81 .. Jupiter Ace .. BBC B .. A310 ..
-- Non-Intel, 32 bit machine   --  A3010 .. Psion Series 3 ..
---------------------------------
Oh No!  -- Lemming #34 --


Article: 21515 of comp.sys.psion
Subject: Additional Source of Files for the Psion
Message-ID: <DKD7Mz.9sI@cix.compulink.co.uk>
Organization: Datalink BBS for PSION (01202) 660838 INT +44 1202 660838
Date: Fri, 29 Dec 1995 20:30:35 GMT
X-News-Software: Ameol

The DATALINK BBS in the UK has a large selection of files, the BBS can be 
accessed on UK (01202) 660838, INT +44 1202 660838.

Article: 21786 of comp.sys.psion
Subject: OPL: tell another PID to exit. HOW ?
I have the following:

	CALL( $0187 , addr(pgmnam$)+1, addr(cmd$), 0,0, addr(pid%) )

This gets the program and filename started

	CALL ( $0688 , pid% )

This seems to attach to the newly created process/program.

In my case, i call up a text viewer/editor with a supplied filename. And this
works.


HOWEVER:

IF, from the text editor, instead of [PSION]-X to exit and return to calling
program, I simply use the buttons to get back to my program, the editing
session is not terminated and the text file remains opened/locked and cannot be
edited again not can it be deleted. Only the "Exit all apps" does the trick.

QUESTION:

Does anyone have a code example of sending an "EXIT" message to another PID ?


Article: 21933 of comp.sys.psion
Subject: Re: How to print *.PIC files?

If you have access to a PC the EASIEST way is to capture the screen you 
are interested in by first displaying it, then typing 
Control-Shift-Psion-S together, the screenshot is then stored on the 3a's 
internal disk (root directory) as "Screen.pic". Copy this to your PC and 
using "WSPCX.EXE" (available through CIX,CIS) type the following on the 
DOS command line:

WSPCX Screen -w

This will produce a PCX version of the PIC file which you can now 
import/paste into any DTP package on a PC.


Hope this helps...Regards werewolf


Article: 21996 of comp.sys.psion
Subject: Re: Trap shutoff?
Arne Anka <mats.sparr@mailbox.swipnet.se> wrote:

>Is it possible to write an OPL (OPA) that is running in the
>background and goes active and does some action when i
>turn my psion off?

Yes, capture the OFF key with the following code:

IF CALL($C58D, 8195, 3592) AND 255
	ALERT("Error: can not capture OFF key")
	STOP
ENDIF

In your event-loop an event with a keycode 8195 is generated:

LOCAL   sysmsg%, keycode%, keymod%
WHILE 1
	IOA(-1,14,sysmsg%,keycode%,#0) rem wait for event
	IOWAIT
	...
	IF sysmsg <> -46
		...
		IF keycode% = 8195
			doSomething:
		ENDIF
		...
	ENFIF
	...
ENDWH

Article: 22645 of comp.sys.psion
Subject: Re: Compressing .wdr files?
> I sacrificed my spare time writing a printer driver for the Epson Stylus 800+
> (anyone?). The driver has about the same capabilities as a postscript
> printer like scalable fonts, but the wdrkit produced a huge file.
> 
> In the wdrkit documentation there is a mention of compressing .wdr files
> with 3rd party software. Does anybody know of such software?
SIBO C SDK have an utility (RCHUF.EXE) to compress resource files (.WDR is one
of them). File can be compressed using either LZW algorithm (2 types, HWIM
recommended) or ZIP. For ZIP compression you need to pass Huffman tree file as
parameter - R_.HFT from your Psion ROM is what you need (but I didn't try to
use ZIP compression).

Regards,
Konstantin
--------------------------------------------------------
Konstantin I. Saliy             |e-mail:  <kis@ipmce.ru>
Institute of Precise Mechanics  |Leninsky prospekt, 51  
	and Computer Equipment, |Moscow, Russia, 117914 
    Russian Academy of Science  |(095)132-9277          
--------------------------------------------------------

Article: 22803 of comp.sys.psion
Subject: USING THE CACHE - some thoughts

This may be painfully obvious to some people, since its all in the manual but
here are some Hints Tips and thoughts regarding using the CACHE in OPL.

1) Just Having a big cache doesn't always help.
2) After CACHE  x,y use CACHE OFF and then switch it on just prior to your
	program calling its most often used procedures. Switch it OFF 
	afterwards so the heavily used procs. are held in the cache.
	(Make sure this isn't in a loop, otherwise check for the NON-existence
	of the cache prior to switching it on)

  This made a significant difference in the execution time as opposed to
  just leaving the cache on.

I am developing a large OPL application. I have a main module and a module
of library routines that are called in various places. Now Ideally I would like
all of the library routines to have cache proiority over the others.
This makes it hard for me to use CACHETIDY as it will remove my library 
routines.

I would like a simple way to nominate either individual procs. or all of the 
procs. in a module, to remain in the cache.

Eg 
proc cacheLD ( module$ )
	CACHE x,y
	TRAP LOADM module$
	...
	put all procs in the cache
	...
	CACHE OFF
endp

I suspect this is more difficult than it first appears. I will investigate 
later (speed optimisation is not a priority - I'd rather my program works!)
but I wonder if the CACHE RECORDS (ie the information in the CACHE dataspace
NOT what is returned by CACHEREC ) is byte for byte the same information
as that at the start of each .OPO that tells the interpreter where to find
the procedure.Is the cache simply a doubly linked list containing this
information?

Also I wrote a profiler (using CACHREC ) that counted the number of times
each procedure was called. It required using "search and replace"
on every "return" and "endp" statement to insert a call to my profile
function. I just used the cache to get the current procedure name.

With a suitable preprocessor it would be possible to write a program that
modifies  the OPL and inserts a call to some kind of profiling function
at the start of every procedure. The results could then be used to fully 
optimise the cache.

A function to remove specified procedures from the cache would also be useful
if a program UNLOADs modules.

Andy L.
--
/-=oOo=--=oOo=--=oOo=--=oOo=--=oOo=--=oOo=--=oOo=--=oOo=--=oOo=--=oOo=-\
$             Andrew Lord <Andrew_Lord@tertio.co.uk>                   %
% This post is my own opinion and not necessarily that of my employers $
$         Network Systems Management Applications Developer.           %
\-=oOo=--=oOo=--=oOo=--=oOo=--=oOo=--=oOo=--=oOo=--=oOo=--=oOo=--=oOo=-/

Article: 22963 of comp.sys.psion
Subject: Is this the first Psion demo??

After getting my Psion last week, I decided to write a simple demo on it,
a friend suggested that it might be the first Psion demo, which, if true,
would be very strange given the excellent graphics and sound on the Psion.

I have included the very short source code here, because it is just that,
very short.  It simulates infinate sprites moving in a circle, give it
a few minutes until the spiral grows off the screen then it will speed up
and give a hypnotic effect.  You can then leave it running and any time
you feel like relaxing/getting spaced out, just run the app!

All comments are welcomed.

Source code follows:

PROC demo:
	rem Ian Clarke's first Psion Demo
	rem ***Infinate Spiral***
	local id%(7),j%,i%,p%
	j%=1
	while j%<8
		id%(j%)=gcreate(0,0,480,159,0)
		j%=j%+1
	endwh
	gorder 1,9
	do
		j%=(i%-7*(i%/7))+1
		guse id%(j%)
		
		gvisible off
		gorder id%(j%),1
		if i%<2000
			gat 180+(cos(rad(sqr(i%)*64))*i%/8+50),50+sin(rad(sqr(i%)*64))*i%/16+50
			gprint "&"
		endif
		gvisible on
		i%=i%+1
	until key
ENDP

:End of source code

Ian

-- 
|IAN CLARKE        I.Clarke@sms.ed.ac.uk "They couldn't hit an elephant|
|                  iic@dcs.ed.ac.uk      at this dist.."  - Last words |
|I.Clarke@ed.ac.uk ianc@aisb.ed.ac.uk    of General M Howard, 1918     |

Article: 22988 of comp.sys.psion
Subject: Re: Daylight savings time
Pierre Chum (pierre@unix.infoserve.net) wrote:
: I was showing off (yes that's what we do with our
: Psions) the other day the World function when I ran
: into a New Zealander who wanted to know what time
: it was at home.  (I'm in Vancouver)  To my surprise
: he said I was an hour off due to Daylight savings time
: down there.  When I checked the DST function  I
: noticed there are multiple settings.  Could someone
: tell me when the different zones change their DST?

I have a list, taken from a previous posting about this, as follows:

UK has daylight saving from the last Sunday in March to the first Sunday
after (or actually) October 28th.

Europe (the rest of) has daylight saving from the last Sunday in March to
the first Sunday in September.

Northern hemisphere (the rest of) has daylight saving from the first
Sunday in April to the last Sunday in October.

Southern Hemisphere has daylight saving from the Sunday before (or
including) October 24th to the Sunday before (or including) 21st March.

Of course there are exceptions, like some Australian states don't have
it at all. Also, the UK broke the rules this year in preparation for
harmanosiation with the rest of Europe. And individual countries can
always change the rules for themselves on a year-by-year basis. So,
caveat emptor.

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

Article: 23321 of comp.sys.psion
Subject: Re: [DEV] "Incremental" dialog ? [1/2]
>Thanks for answers, it seems that I would need to use the C SDK.
>
>> see that the OPL functions give you vanilla functions, but that there 
is a 
>> WHOLE LOT MORE in a PSION than what OPL gives you. And a lot of those 
functions
>> ~can~ be accessed through OPL if you know what you are doing.
>
>But coud anyone tell me, for that specific item (Dynamic Choice List), 
how
>could I access it through the OPL ?
>I'm afraid it's the only thing I'm plannig to do needing the SDK, so I 
would
>like not to spend some 'big bucks' for documentation.
>
/* 
    Example OPL program which replaces choice list in a dialog
    with a VASTR array allowing more choice items than the normal
    list (limited to 254 items - this example creates a choice
    list with 360 items).

    A related OPL program FIXLIST.OPL uses the VAFIX class of
    array to speed up the choice list with a penalty of
    increased memory use.

    This file should be accompanied by VARRAY.TXT which describes
    some of the concepts used here in a little more detail.

*/

#define DatDialogPtr            $36

#define E_GEN_NOMEMORY          -10

#define SE_CHLIST_NSEL          1
#define SE_CHLIST_DATA          2
#define SE_CHLIST_RETAIN        4

#define C_VASTR                 6

#define O_VA_INIT               17
#define O_VA_APPEND             7

#define O_WN_SET                10


/*  MAIN: is our top level procedure  */

PROC main:

	GLOBAL          ret%                              /*  General 
return  */

	ret% = Choice%:    

	IF ret% < 0
		PRINT "Error was", ret%
	ELSE
		PRINT "You chose item", ret%
	ENDIF
	GET

ENDP


/*  CHOICE%: replaces the choice list and displays the dialog  */

PROC Choice%:

	GLOBAL          datdlg%                      /*  DatDialogPtr 
static  */
	GLOBAL          vastr%                        /*  The C_VASTR 
object  */
	GLOBAL          set%(3)                      /*  SE_CHLIST 
structure  */
	GLOBAL          pset%                          /*  Pointer to 
set%()  */

	LOCAL           choice%                /*  Live variable for 
dCHOICE  */
	LOCAL           lgnsel%              /*  set.nsel in SE_CHLIST 
'set'  */
	LOCAL           index%                  /*  Index of the choice 
list  */

	index%  = 1                             /*  Index of the dialog 
item  */
	pset%   = ADDR(set%())          /*  pset% points to SE_CHLIST 
struct  */

	lgnsel%  = 0                         /*  set.nsel in SE_CHLIST 
'set'  */

	set%(1)  = (SE_CHLIST_DATA) OR (SE_CHLIST_NSEL) OR 
(SE_CHLIST_RETAIN)
	set%(3)  = lgnsel%
	
	PRINT "Generating list, wait a short time"
	ret% = Array%:
	IF ret% < 0
		RETURN ret%
	ENDIF

	dINIT "Test dialog"                              /*  Init the 
dialog  */
	dCHOICE choice%, "Date", "dummy"       /*  Create a choice list 
with
							       a dummy 
entry  */

	datdlg%  = PEEKW(DatDialogPtr)  /*  datdlg% points to current 
dialog  */
	set%(2)  = vastr%                              /*  set.data = 
varray  */
	
	ret% = ENTERSEND0(datdlg%, O_WN_SET, #index%, #pset%)

/*  WN_SET is a method provided by the DLGBOX class and is used to
    set the data element in the property of the control associated
    with the dialog box item.
*/
	IF (ret% <> 0)                                  /*  Return any 
error  */
		RETURN ret%
	ENDIF

	IF (DIALOG > 0)                                   /*  Run the 
dialog  */
		lgnsel% = choice%
		RETURN lgnsel%                  /*  Return the option 
chosen  */
	ENDIF

ENDP


/*  ARRAY%: creates the array and fills it with example data  */

PROC Array%:

	LOCAL           yea%                                    /*  The 
year  */
	LOCAL           mon%                                   /*  The 
month  */
	LOCAL           buf$(10)                     /*  The built-up 
string  */
	LOCAL           pbuf%                            /*  Pointer to 
buf$  */
	LOCAL           gran%                    /*  Granularity for 
VA_INIT  */
	LOCAL           ohand%               /*  Category handle of 
OLIB.DYL  */

	gran% = 16                                     /*  Granularity is 
16  */
	
	ret% = FINDLIB(ohand%, "OLIB.DYL")  /*  Find category handle of OLIB  */
	IF (ret% <> 0)
		  RETURN ret%                        /*  Return error  */
	ENDIF

	vastr% = NEWOBJH(ohand%, C_VASTR)  /*  Create an instance of 
C_VASTR  */
	IF (vastr% = 0)
		RETURN E_GEN_NOMEMORY                         /*  Return 
OOM  */
	ELSE
		ret% = ENTERSEND0(vastr%, O_VA_INIT, #gran%)  /*  Init 
array  */
		IF (ret% <> 0)
			RETURN ret%                     /*  Return any 
error  */
		ENDIF
	ENDIF

	yea% = 1970                                        /*  Start at 
1970  */
	mon% = 1                                        /*  Start at 
January  */

/*  
    The following loops round and round adding all the month & year
    combinations between Jan 1970 and Dec 2000. It is a convenient
    way of generating a very long list. The strings are then added
    to the array using VA_APPEND.
*/
	WHILE (yea% <= 2000)
		WHILE (mon% <= 12)
			buf$ = MONTH$(mon%) + CHR$(32) + GEN$(yea%, 4) + 
CHR$(0)
			pbuf% = UADD(ADDR(buf$), 1)         /*  Skip the 
LCB  */
			ret% = ENTERSEND0(vastr%, O_VA_APPEND, #pbuf%)

/*
    VA_APPEND is a method provided by the (abstract) class
    VAROOT. It appends the records pointed to by, in this case 'pbuf%',
    to the end of the array.
*/
			IF (ret% <> 0)
				RETURN ret%             /*  Return any 
error  */
			ENDIF
			mon% = mon% + 1                 /*  Reset to 
January  */
		ENDWH
		yea% = yea% + 1                       /*  Increment the 
year  */
		mon% = 1                             /*  Increment the 
month  */
	ENDWH
	RETURN 0                                                /*  No 
error  */
ENDP

/*
Long choice lists in OPL

Choice lists in OPL dialogs are limited to a maximum of 255 
items. For some applications this may be considered a problem 
and there is a mechanism by which this limit may be 
circumvented. Consider the following from the SIBO C SDK 
Introduction to HWIF:

	Longer choice lists

In some cases, the list of choices presented in a particular 
choice list may be too long for a choice list to be conveniently 
defined simply by one call to

uAddChoiceList.

The three functions uBeginDCL, uGrowDCL, and uAddDCL exist to help 
out with these so-called dynamic choice lists (the name reflects 
the fact that the contents of the choice list are built up over a 
few lines of code, rather than just being defined statically; in 
some cases, the contents in the list may change between 
different invocations of the dialog, to reflect changing run-time 
circumstances).

For example, the following routine builds up a choice list 
whose contents are the twelve month names:

LOCAL_C INT AddMonthChoiceList(UWORD *pmonno)
    {
    H_DI_CHOICE ch;
    TEXT mon[32];
    INT i;

    if (uBeginDCL(&ch))
	return(-1);            /* report failure to caller */
    for (i=0; i<12; i++)
	{
	p_nmmon(&mon[0],i);
	if (uGrowDCL(&ch,&mon[0]))
	    return(-1);        /* report failure to caller */
	}
    return(uAddDCL("Month",pmonno,&ch));
    }

Alternatively, the function hSetVarrayInChlist can be used to 
build up a choice list, especially if the list might contain more 
than 255 items.



For example, by modifying the above code, the same effect can 
be achieved as shown below:

#define C_VASTR 6
#define O_VA_APPEND 7
#define OLIB_CAT 1

LOCAL_C INT AddMonthChoiceList(INT item_no,INT *pmonno)
    {
    UWORD used = 0;
    VOID  *pvarray;
    TEXT  mon[32];
    INT   i;
    
    
    if (uAddChoiceList("month",&used,NULL))
	return(-1);            /* failure */
    pvarray = p_new(OLIB_CAT,C_VASTR);
    for (i = 0; i < 12; i++)
	{
	p_nmmon(&mon[0],i);
	p_send3(pvarray,O_VA_APPEND,&mon[0]);
	}
    
hSetVarrayInChlist(item_no,(*pmonno),pvarray):
    }

Note that error handling in this code is incomplete.

It is entirely possible to emulate this fucntionality in an OPL 
program and the two OPL programs which accompany this 
documentation provide guidance on exactly how this may be 
done. The OPL programs are called STRLIST.OPL and 
FLATLIST.OPL and their names reflect a subtle variation in 
the way they operate. The OPL code is extensively commented 
and should be read with the following in mind. The basic 
process is straightforward:

*       Create an array which contains the a variable number of 
	records representing the data of our choice list. We use one 
	of two subclasses of the OLIB class VAROOT: VASTR or 
	VAFLAT. In the case of a VASTR array, our records are of 
	variable length. In the case of a VAFLAT array, the records 
	are of a fixed length. Both approaches have their 
	advantages and disadvantages. Assuming they contain the 
	same 'live' data, VASTR arrays use less memory than 
	VAFLAT arrays. However, VAFLAT arrays can be 
	navigated more swiftly than VASTR arrays - this is 
	particularly noticeable when pressing <Tab> to pop-out 
	the choice list while in a dialog. Consider the following 
	(taken from the SIBO SDK OLIB Reference):



	Usage summary
	
	VAROOT and VAFIX are abstract classes. VAROOT defines a 
	relatively large number of deferred methods in order to 
	promote polymorphism between the directly usable classes.
	
	The VASTR class is used to create arrays of variable length 
	text records, stored as zero terminated strings. The storage 
	overhead per string is only one byte, so it is particularly 
	suitable for storing short strings, of up to, say, several tens 
	of bytes, or for strings with a wide variation in size (such as 
	file names, which can be any length up to 128 bytes, but are 
	usually much shorter). Since the whole array is stored in a 
	single allocated cell, the VASTR class is most suitable for 
	arrays that contain:
		*       a small number of records
		*       a moderately large, but fixed maximum, number
			of records (for which the maximum capacity can
			be allocated in advance)
	Because of its suitability for storing file names, the VASTR 
	class is used, for example, to store directory listings. In 
	general, however, the VASTR class not particularly suitable for 
	arrays which can dynamically grow to a very large size. 

	The resulting repeated calls to p_realloc are likely to cause 
	heap fragmentation and seriously reduce the effective use 
	of memory.

	The VAFLAT class is used to create arrays of fixed length 
	records, where the whole array is stored in a single 
	allocated cell. The preferred usage is as for the VASTR class.

*       Create a dialog which contains the desired components but 
	don't run it yet. This is done using the dINIT "title", 
	dCHOICE..., commands.

*       Call the O_WN_SET method of the DLGBOX class to alter 
	the data elements used by the dCHOICE. This is clearly 
	marked in the code. Consider the following excerpts (taken 
	from the SIBO SDK Object Oriented Programming Guide):
	
	WN_SET  Set item by index

	VOID wn_set(INT index, VOID *par);

	Set one or more data elements in the property of the control 
	associated with the dialog box item with index number 
	index, by sending a WN_SET message to the control.

	The parameter par is assumed to be a pointer to a struct that 
	specifies the data to be set. The type of struct that is 
	expected depends on the class of the control that is being 
	set; the various structs are described in the following 
	Dialog Controls chapter.

	Setting
	
	A choice list is set by passing a pointer to an SE_CHLIST struct 
	to the wn_set method

	typedef struct
	   {
	    UWORD set_flags;    /* which fields are significant */
	    PR_VAROOT *data;    /* pointer to array containing data */
	    UWORD nsel;         /* index of current item */
	    } SE_CHLIST;

	The property to be set is indicated by ORing one or more of 
	the following flags into the flags field of the above struct.
	
	SE_CHLIST_NSEL  the index of the current item is to be set.

	SE_CHLIST_DATA  the data is to be replaced. The replacement
			data is a string array - see variable arrays
			in the OLIB Reference manual.

	SE_CHLIST_RETAIN        data should not be destroyed on
				destruction of the choice list
				control - once set this flag cannot
				be cleared.

	The content of a choice list can be set dynamically, say, 
	from the dialog's dl_dyn_init method. However, changing the 
	content of a choice list once the dialog has become visible 
	is not recommended, since the width of the dialog box is set 
	on initialisation. If the choice list content must be replaced, 
	then care should be taken to ensure that the text does not 
	become too wide for the dialog box to display.

*       Run the dialog. This is done using the standard DIALOG 
	function.

While viewing the OPL code, bear the following in mind:

*       DatDialogPtr is a magic static always at location 0x36. 
	System user interface library code may assume that this 
	location contains a pointer to the current dialog structure. 
	Otherwise it is free for use by application code. Hence, this 
	value will almost certainly be NULL until dINIT is 
	complete.

*       Note the use of ENTERSEND0() to ensure error values are 
	returned appropriately (given that many of the functions 
	call p_leave() rather than return an error). Using the 
	SEND function may result in your application panicing 
	unexcpectedly if an error arises.

*       Note the extensive use of '#' as a prefix to variable names. 
	This is done to tell OPL that the following expression is the 
	address to be used - not a variable whose address is to be 
	taken.

*       Note the use of UADD to skip the leading count byte of an 
	OPL string. This ensures that we do not cause any 'Integer 
	overflow' errors.
*/

All the best

Ali


Article: 25702 of comp.sys.psion
Subject: Re: Filesize in OPL
>I'm trying to work out how to determine the size of files from within OPL
>- can anyone help?? - I've tried the Psionics files, but don't really
>understand what I need to do to with the relevant system call to make it
>work.
>
>Any help much appreciated.

Try this:

proc fsize&:(file$)
	local locfile$(129),buf&(4)
	locfile$=file$+chr$(0)
	p%=uadd(addr($),1)
	call($887,uadd(addr(locfile$),1),addr(buf&()))
	return buf&(2)
endp

Bjrn Ekstrm
bekstrom@bastad.se



Article: 26167 of comp.sys.psion
Subject: Re: Does 29 february 2000 exist, or not ?
Ian Boys <boys@atuk.aspentec.com> wrote:
>>>: The complete Easter algorithm takes 5 700 000 years to complete.
[...]

Okay, I've totally forgotten the arithmetic involved. Work it out for
yourself:

PROC easter:
	local year&,month%,day%
	local b&,c%,a%,f&,d&,e%,g&,h%
	local m%,n%,j%,k%,r%,p%,pp%
	
	Dinit "Easter finder"
	year&=year
	Dlong year&,"Year",1,&7FFFFFFF
	if dialog=0 :stop :endif
	a%=rem%:(year&,19)
	b&=year&/100
	c%=year&-b&*100
	f&=3*b&+75
	d&=f&/4
	e%=f&-d&*4
	g&=(8*b&+88)/25
	h%=rem%:(19*a%+d&-g&,30)
	m%=(a%+11*h%)/319
	n%=300-60*e%+c%
	j%=n%/4
	k%=n%-j%*4
	r%=rem%:(&2*j%-k%-h%+m%,7)
	p%=h%-m%+r%+110
	month%=p%/30
	pp%=h%-m%+r%
	print "Easter Sunday is",
	if pp%<10
		print pp%+22,"March",
	else
		print pp%-9,"April",
	endif
	print year&
	busy "Press ESC to quit"
	while get<>27 :endwh
ENDP

PROC rem%:(n&,r%)
	local q&
	
	q&=n&/r%
	return n&-r%*q&
ENDP
-- 
Clive D.W. Feather                       | If you lie to the compiler,
cdwf@cityscape.co.uk   (work, preferred) | it will get its revenge.
clive@stdc.demon.co.uk (home)            |   - Henry Spencer

Article: 26186 of comp.sys.psion
Subject: OPL debugger & OPP 1.4F
For those who write OPL programs...

A new utility called OPPDBG is now available. OPPDBG is a run-time OPL
source level debugger for the Psion 3a Computer. It may be used when
developing applications on the Psion 3a in the OPL language.
 
Ordinarily when debugging OPL applications it is necessary to add
PRINT statements within the source code to find out what code is being
executed and the values of variables. This can be a time consuming and
error prone process since it often requires the code to be
retranslated many times in order to pinpoint where a problem is
occurring.

Using the debugger you can:

	- see exactly which lines of code are being executed
	- control the execution of the program
	- single step through each line of code
	- set breakpoints so the program halts at a given line
	- examine and set all local variables
	- examine and set any memory location in the running program

OPPDBG is currently available from my homepage. I will distribute it
more widely (including comp.sys.psion) in a few days time, once I am
satisfied that there are no major problems.

A pre-requisite for the debugger is the OPP utility (an OPL
preprocessor). A new version of OPP (version 1.4F) is also now
available from my homepage.

+---------------+-------------------------------------------------------+
| Andy Clarkson | Home : 100661.2440@compuserve.com                     |
| Cambridge, UK | Work : andy@smallworld.co.uk                          |
|               | WWW  : http://ourworld.compuserve.com/homepages/andyc |
+---------------+-------------------------------------------------------+

Article: 26459 of comp.sys.psion
Subject: Re: HELP WANTED
Rudi Weyn (gemini@glo.be) wrote:
: Hello,
: 
: When you make a choicelist in OPL you see see a left and right arrow
: at the beginning and end of the choice you can make.
: How can I print these arrows in my own text, I can't find the ASCII
: code.
: Thanks in advance
: Scotty

The following characters are all arrows of one form or another, in Font
5 (not all fonts have all the arrows).

0       newline symbol
9       right
10      down
13      down
16      right
17      left
24      up
25      down
26      right
27      left
28      right
30      up

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


Article: 26902 of comp.sys.psion
Subject: Re: Agenda extra day Feb 29 2000
>My PSION Agenda indicates a leap day Feb 29th 2000.
>
>February is to have a leap day in 2000 as figured
>in the usual fashion of every fourth year.
>
>There is apparently NOT to be a leap year in 2000.
>In years where there is to be a leap year and the year
>is evenly divisibl by 400, the leap day will NOT BE OBSERVED
>in order that the calendar does not get too far out of whack.

I'm afraid you don't need to buy a new agenda or such, since
as mentioned earlier in this group, Feb 29th 2000 *does* exist!
The rule with the leap year is:
  1.) TRUE, if year can be divided by 4 without remainder, but...
  2.) FALSE, if year can be divided by 100 witout remainder, but...
  3.) TRUE again, if year can be devided by 400 without remainder.
So, 'cause of 3.) 2000 *is* in fact a leap year.


_______________________________________\______________________Brendan W. Breede
					\
snailmail: D-28325 Bremen                \
	   Graubuendener Strasse 77       \
fax/voice: +49-421-400104                  \
email:     brendan@informatik.uni-bremen.de \


Article: 26915 of comp.sys.psion
Subject: Re: Error handling in OPL, Help please
Just to tidy this thread up, the line I've adopted is

	TRAP gUSE gIDENTITY

This is a totally redundant line that must succeed, since gIDENTITY
is the window currently in use. Thus the line has no effect on any
thing, but has the glorious effect of setting ERR to zero.

Thanks to all who thought about this.

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

Article: 27244 of comp.sys.psion
Subject: Q: Scripting on Psion?
Hello Garland!

Replying to a message of Garland Sharratt to All:

 GS> Does anyone know if there is a scripting language available for the
 GS> 3a? It would allow a script to invoke/do anything that a user could
 GS> do from the keyboard.  My immediate application is to open up the
 GS> dozen or so Word files I like to have open, after I have to close
 GS> them for backing up.

I have an OPL program, called Restart1.OPL

start: is used to start normal applications, starta: is used to start OPA
applications/OPL code.

It should be relatively easy for you to patch this to launch what you want...
the first start: line starts a word processor file. rom::word.app refers to the
word program in the rom, loc::m:\tree\general\scratch.wrd refers to the file.
"Scratch" is the name of the icon for the file to appear under.

To open just a normal file under the Word icon, as comes on a normal Psion,
called for example "Zing", use "loc::m:\wrd\zing.wrd","Word"

You can delete any of the other lines in the restart procedure, that start up
my other data, agenda and Macro System files.

PROC restart:
 start:( "rom::word.app", "loc::m:\tree\general\scratch.wrd", "Scratch")
 start:( "rom::data.app", "loc::m:\tree\general\phonebk.mor", "General")
rem start:( "rom::data.app", "loc::m:\tree\general\notes.mor", "General")
 start:( "rom::agenda.app", "loc::m:\tree\general\agenda.mor", "General")
 start:( "rom::agenda.app", "loc::m:\sch\homework.mor", "School")
 starta:( "rom::sys$prgo.img", "loc::m:\macro\macro.mdb", "Macro",
"loc::m:\app\macro.opa")
ENDP

PROC start:(app$,dfn$,list$)

resume:(launch%:(upper$(app$),"O"+list$+chr$(0)+".MOR"+chr$(0)+upper$(dfn$)+chr
(0)))
ENDP

PROC starta:(app$,dfn$,list$,afn$)

resume:(launch%:(upper$(app$),"O"+list$+chr$(0)+".MOR"+chr$(0)+upper$(dfn$)+chr
(0)+afn$+chr$(0)))
ENDP

PROC launch%:(app$,arg$)
    LOCAL name$(128)
    LOCAL cmdl$(128)
    LOCAL pid%, ret%
    name$=app$+CHR$(0)
    cmdl$=arg$+CHR$(0)
    ret%=CALL($0187,UADD(addr(name$),1),addr(cmdl$),0,0,addr(pid%))
    IF ret%<0
      ALERT(app$+" process failed",err$(ret%))
      RETURN 0
    ENDIF
    RETURN pid%
ENDP

PROC resume:(pid%)
    CALL($0688,pid%,0,0,0,0)
ENDP
-- 
+ Fidonet : Ben Clifford 2:440/4.2
+ Internet: benc@donor2.demon.co.uk


Article: 27639 of comp.sys.psion
Subject: How to detect HELP while in a MENU?
Hello Simon

Replying to a message of Simon Ford to All:

 >> Ali Manson showed me how to do it with dialogs.  I've sent you an email
 >> of the solution he posted for me.   Alan

 SF> How about posting it for the rest of us.? 


Area: Saved Messages

Date : Sep 10 '95, 19:32                                                   Loc 
From : ALasdair Manson                                        2:440/4.99
To   : All                                 
Subj : Re: OPL                                                               
-------------------------------------------------------------------------------


-=> Note:
Moved (from: COMP.SYS.PSION) by Alan Clifford using timEd.

From: alim@psioninc.com (ALasdair Manson)

In article <51c14c0@donor2.demon.co.uk>, alanc@donor2.demon.co.uk says...
>
>Hello all
>
>I have a dialog set up in an OPL program.  The ESC key completes the 
dialog as
>it should with zero and the enter key returns the line number. However, 
the
>HELP key also completes the dialog and, unfortunately, also returns zero. 
 Is
>it possible to either, prevent the help key from completing the dialog 
or,
>better still, detect whether the ESC key or the HELP key completed the 
dialog?
>
>Alan
>
Try the following code which will only work on a 3a (i.e. not the older 
Series 3):

#define O_GT_LAST_KEY  23

/*  This method gets the last key processed by the system
    on behalf of the application  */


PROC main:

	LOCAL   gate%  /*  Handle of the gate object  */
	LOCAL   c%  /*  Live variable fo rthe dCHOICE  */
	LOCAL   k%  /*  Variable to receive the key  */
	LOCAL   mods%  /*  Variable to receive modifiers  */
	LOCAL   pmods%  /*  Pointer to above  */

	dINIT "Test dialog"
	dCHOICE c%, "Choice", "No, Yes, Maybe"
	DIALOG  /*  Run the dialog  */

	gate% = PEEKW($38)  /*  Find the handle of the GATE object  */
	pmods% = ADDR(mods%)  /*  Point pmods% to the right place  */
	k% = ENTERSEND(gate%, O_GT_LAST_KEY, #pmods%)  /*  Send the 
message  */

	PRINT "Key was   =", k%
	PRINT "Mods were =", mods%
	GET

ENDP

The comments should be straightforward. The only other thing you need to 
know is that the modifiers written to 'pmods%' will be:

2 for <Shift>
4 for <Control>
8 for <Psion>

and these can be combined (i.e. <Psion><Shift><Help> will return 291 in k% 
and 10 in mods%)

Hope this helps

Ali


Alan
-- 
+ Fidonet : Alan Clifford 2:440/4.6
+ Internet: alanc@donor2.demon.co.uk


Article: 27779 of comp.sys.psion
Subject: Re: File Selector Boxes In OPl
> Does anyone know what parameters you need to send the > 'dFile' 
function in OPL to 
> get it to display the '(Tagged files)' String in the file > name ?
**********************************************************
The following text is copied straight from the Windows help file that is 
supplied with ODE.
**********************************************************
Defines a filename edit box, to go in a dialog. 

dFILE var edstrng$,prompt$,feditin%

A 'Disk' selector is automatically added on the line below.

The prompt (prompt$) will be displayed on the left side of the line.

The type of file editor, and the kind of input allowed is controlled by 
feditin%. You can add together any of the following values:


value   meaning
1       use an edit box, not a selector
2       allow directory names
4       directory names only
8       disallow existing files
16      query existing files
32      allow null string input

The first item on the list is the most crucial. If you add 1 into 
feditin%, you will see a file edit box, as when creating a new file. If 
you do not add 1, you will see the 'matching file' selector, used when 
choosing an existing file.

If performing a 'copy to' operation, you might use 1+2+16, to specify a 
file edit box, in which you can type the name of a directory to copy to, 
and which will produce a query if you type the name of an existing file.

If asking for the name of a directory to remove, you might use 4, to 
allow an existing directory name only.

'Query existing' is ignored if 'disallow existing' is set. These two, as 
well as 'allow null string input', only work with file edit boxes, not 
'matching file' selectors.

The string the user types in the dialog is held in edstrng$. Its initial 
contents always control the initial drive and directory used. For a file 
edit box, any filename part of edstrng$ is shown. 

For a 'matching file' selector, you can use wildcards in the filename 
part (such as *.tmp) to control which filenames are matched. To do this, 
you must add 128 to feditin%.

128 also allows wildcard specifications to be entered (returned in 
edstrng$), for both 'matching' and 'new file' selectors.

If edstrng$ does not contain any drive or directory information, the path 
as set by SETPATH is used. If SETPATH has not been used, the \OPD 
directory on the default drive (usually M:, 'Internal') is used.

With a matching file selector (as opposed to an edit box) the value 8 
restricts the selection to files which match the filename/extension in 
edstrng$.

Matching file selectors can also use 64, in which case files with the 
same extension as that in edstrng$ are shown without this extension. Many 
Series 3a file selectors are like this.

You can always press Tab to produce the full file selector with a dFILE 
item.

edstrng$ must be declared to be at least 128 bytes long, or an error will 
be raised.

Note
The "var" in the syntax statement is not a parameter, it merely indicates 
that the following argument must be a LOCAL or GLOBAL variable. This is 
because it will end up containing the value that the user enters

Hope this was of some help
Richard

Article: 27928 of comp.sys.psion
Subject: Re: Sprites in OPL
Ok, heres how i'm doing it at the moment :)

i%=gLOADBIT("brick")
gUSE window%
gAT 100,100
gCOPY i%,0,0,16,16,3
gCLOSE i%

Which means that i can plot more than one sprite in window% by just loading
them and plotting them to that window by giving hte co-ords. Simple when
you look at it, but the n i was looking at the example in the programming
guide which threw me off and had me going down the wrong track as usual!

My next problem is trying to find an equivalent of the data statement...

~graham
------------
Graham Boyd, ETL/RNO/TD
Ericsson Limited, Guildford (UK)
Tel: (01483) 305822 
graham.boyd@guildford.ericsson.se


Article: 28190 of comp.sys.psion
Subject: Fixed decimal places in OPL?
Hello Mitch

Replying to a message of Mitch Feinberg to All:

 MF> I wrote a small program in the OPL language to calculate all sorts of
 MF> wonderful billing headaches (TVA, social security withholding, and on
 MF> and on and on) but I need to limit the format to two decimal places
 MF> (with 5/4 rounding). I assume there's a special function I need to
 MF> type in but the user manual doesn't have it. Could someone please
 MF> send me the function by e-mail (or here if you prefer)?

 x = 3.4999999
 x = x * 100
 x = x + .5
 x = int(x)
 x = x/100

Alan
-- 
+ Fidonet : Alan Clifford 2:440/4.6
+ Internet: alanc@donor2.demon.co.uk


Article: 29009 of comp.sys.psion
Subject: Re: Start "Word" from OPL
Heres a snippet of code I picked up from somewhere (this group probably).
I haven't actually used it so can't speak for its reliability but it
looks safe enough. It Opens the file \wrd\memo.wrd or creates it if it
doesn't exist.

PROC Memo:
    LOCAL Temp$(128)
    Temp$="LOC::M:\WRD\MEMO.WRD"
    IF EXIST (Temp$) : Word:("O",Temp$)
    ELSE : Word:("C",Temp$) : ENDIF
ENDP

PROC Word:(Cbyte$,FW$)
    LOCAL PgName$(40),Pid%,Ret%,Temp$(128)
    PgName$="ROM::WORD.APP"+CHR$(0)
    Temp$=CByte$+"Word"+CHR$(0)+".WRD"+CHR$(0)+FW$+CHR$(0)
    Ret%=CALL($0187,ADDR(Pgname$)+1,ADDR(Temp$),0,0,ADDR(Pid%))
    IF Ret%<0 : dERROR:(ERR$(Ret%),"")
    ELSE : CALL($0688,Pid%) : ENDIF
ENDP

> Can the task then be switched from the OPL program to Word.
The statement CALL($0688,pid%) does exactly that.

-- 
\   \/   / --------------------------------------+----------------------------+
 \/\/\/\/  Wally Wright, Ceemore Ltd, Maidenhead | wally@ceemore.demon.co.uk  |
-------------------------------------------------| 101367.2040@compuserve.com |
"Pieces of nine, pieces of nine" - parroty error +----------------------------+

Article: 29141 of comp.sys.psion
Subject: Renaming calc memories in OPL
Hello Robert!

Replying to a message of Robert Stonehouse to All:

 RS> I am writing a prog to draw polar graphs (to help with 'A' level
 RS> further maths.)
 RS> Because the equation is entered in terms of X, one of the calculator
 RS> memories needs to be called X. I need a way to read and write the
 RS> NAMES of the calc memories from OPL. e.g. M9 can be called Vat 

From playing around with CMDP, there appear to be several environment
variables, titled (on my Psion)

M$0M0
M$1AVOGAD
M$2VAT
M$3G
M$4M4
M$5M5
...
M$9M9

with my M1 renamed to Avogad, M2 renamed to VAT and M3 renamed to G.

Check out Psionics. There are a variety of functions which will allow you to
create, modify and delete environment variables.

I suppose, to rename M5 to ZOOM, one must delete M$5M5 and create M$5ZOOM.


Article: 29143 of comp.sys.psion
Subject: Re: Need FAST sort routine for DBF files
In article <1996May9.141150.1@ugun2a>, Daniel Pfund
<pfund3@uni2a.unige.ch> writes
>
>I would need a very fast (fastest?) sort routine in OPL (or eventually
>assembler if you must) for a database.
>
For the actual sorting, use a heap, butterfly or "Quicksort" sort, to 
sort an index to the records, then use the sorted index to copy the file 
to a new location. 

Quicksort is like this (it is recursive)

Input - a sequence S of n element a(1), a(2).....a(n)  (the keys).

Output - S in sorted order

Procedure QUICKSORT(S)
   If S contains at most one element, return S
   else begin
      choose an element a randomly from S
      Partition S into S1 (all elements less than a)
		       S2 (all elements equal to a)
		       S3 (all elements greater than a)
      return QUICKSORT(S1) followed by S2 followed by QUICKSORT(S3)
   end
endproc

Note, S2 can be empty, as may happen if a is chose as an average of say 
the first and last values. This is faster than generating a random 
number.

The partition can be done in situ. Step up from the beginning to find 
the first value of s[i] > a and step down from the end to find the last 
value < a. Swap them over. Continue the process of bringing the two 
indexes into the middle, swapping pairs over, until the two indexes 
meet. 

Although I have written that the whole array is passed, in practise one 
would pass the first and last indexes, and make the actual array S 
globally available.

As a minor refinement, I would read through the file, and skip the first 
string, leaving the keys on the file (i.e. not read them into memory for 
sorting). Simply sort the tail end. Then merge the sorted tail end keys, 
with the skipped string of sorted records left on the original. (A 
string is a sorted list of keys). This wrinkle will save considerable 
sorting time in the case where new and changed records are being sorted 
into an already sorted file without changing the sort order. I would 
expect this to be common.

Ian Hobson
Its spell checking Gym, but knot as we no it.


Article: 29390 of comp.sys.psion
Subject: Assembler Programming
[I seem to have lost the original article that this was a reply to.]

[Reordered by me]

>That last remark sort of hit the whole point of my initial question. Where
>do I get this info from?
[...]
>I not looking for a way to program against the norm, but if you wirte
>assembler, it seems to me that in order to know what to do, and what not to
>do, you must have a more detailed knowlegde of what goes on.

Okay. Much of the information you need is in the SDK, though the version
I have still seems to contain gaps. But it's a good start.

My Psionics Files contain a lot of the material, condensed into
reference sections. I'm not in the business of writing tutorial
material. However, given them and some common sense, you can experiment.

>>> Things like how the OS loads the segment regs,
>>None of your business - it may even change them on the fly.
>>> how to access more than one segment,
>>Use the relevant system calls.
>>> regs not to work with (up to now the ES seems to be out of bounds).
>>Don't touch any segment register unless you know exactly what you're
>>doing.
>Reading the other postings, I also gathered that the C compiler
>must be the Topspeed, and one of the reasons was the way the ES register is
>treated. So I thought that maybe I could use a program like A86 to generate
>code, or even have a go at writing my own assembler. 

Okay, I'm going to take the time to go into this in some detail. You may
be aware of parts of it, but perhaps other readers aren't.

The 8086 can address up to 1Mb of memory - this requires 20-bit
addresses. Instead of having 20-bit wide address registers, the 8086
constructs addresses out of two parts: a segment register and an offset
value, each 16-bits wide. These are combined using the formula:

    address = segment * 16 + offset

The segment register is one of CS, DS, ES, or SS - which one it is
depends on the particular opcode used in the instruction - and the
offset may be a constant or may be taken from a general register like
DX.

Now we get to the essential difference between SIBO and systems like
MSDOS and Windows. MSDOS never touches the segment registers directly.
Instead, once a program has started, it can make any changes to them it
likes, and can use (say) ES as just another general register. SIBO, on
the other hand, is different.

One of the basic features of SIBO is that it moves segments around in
memory as it feels is necessary. At any time the hardware may generate
an interrupt and return control to the kernel. The kernel might then
switch control to another process, which (say) does something with the
filing system. As a result, it becomes necessary to move a segment, such
as the stack of a process, from one place to another. For example,
suppose a segment is moved by 80 bytes; since 80 = 16 * 5, the segment
register that points to the start of that segment will be adjusted by 5.

This leads to some basic programming rules for the Psion.
(1) Any object in memory may move at any time. Therefore any saved
address may become invalid without warning.
(2) When an object is moved, any segment register pointing to anywhere
in that object will be adjusted accordingly. Thus, as far as your
program is concerned, if the object was at DS+43, it will remain at
DS+43, but DS may change. Combined with rule 1, this means that you
should save the value 43 as representing the address, not DS+43.
(3) Segment registers containing junk might look like they point into an
object, and so may change at any time. In particular, ES may be altered
by the operating system without warning. Many compilers assume they are
running on MSDOS, and so can use ES as a scratch register. This is a
recipe for disaster on the Psion.
(4) The only safe place to get a value to put in a segment register is
from another segment register. Furthermore, do the relevant moves and
calculations with interrupts disabled. For example:

    DI
    PUSH DS
    POP BX
    ADD BX,5
    PUSH BX
    POP ES
    EI

(5) One exception is that the system call GenDataSegment sets ES to the
start of the kernel data segment. It is then possible to wander through
kernel data structures to find the locations of other objects, and then
set segment registers to them.

Hope this lot helps explain.

-- 
Clive D.W. Feather                       | If you lie to the compiler,
clive@demon.net        (work, preferred) | it will get its revenge.
clive@stdc.demon.co.uk (home)            |   - Henry Spencer

Article: 29826 of comp.sys.psion
Subject: Re: Compile large sources
In article <4nu2uh$g4p@sun3.uni-essen.de> sg0026@aixrs1.hrz.uni-essen.de (Frank Borally) writes:
> How can i compile larger sources? I've wrote a program containing much 
> data, the source is about 45k big... when I copy it onto my Psion 3a 
> (512k) and try to load it into the OPL editor I get an 'overflow' message 
> and the task disappears. Same problem with word...
>

You have a few ways of getting around the 40K limit in Program/Word:

	- Keep your code on a PC and translate it on the PC using S3ATRAN

	- Break your code into separate files and then either:

		o Translate each separately and use the standard OPL
		command LOADM to load each separate module from the main
		module at run-time. This is easy but means the final
		application consists of multiple files which are harder
		to deal with at installation than a single file.

		o Use an OPL preprocessor utility of mine called OPP which
		allows you to #include multiple files, i.e. at the end of
		the main source file you are translating, you add:

			#include "file2.opl"  
			#include "file3.opl"  
			#include "file4.opl"  

Naturally, since I write OPP I use that method. One of my OPL programs
currently consists of over 135K of source which OPP can handle very
nicely, building one large 82K OPA file. OPP also has a few other features
which greatly enhance OPL programming.

+---------------+-------------------------------------------------------+
| Andy Clarkson | Home : 100661.2440@compuserve.com                     |
| Cambridge, UK | Work : andy@smallworld.co.uk                          |
|               | WWW  : http://ourworld.compuserve.com/homepages/andyc |
+---------------+-------------------------------------------------------+

Article: 29885 of comp.sys.psion
Subject: Re: Assembler Programming
On Tue, 14 May 1996 04:45:31 GMT, clive@stdc.demon.co.uk (Clive D.W. Feather)
wrote:

>My Psionics Files contain a lot of the material, condensed into
>reference sections.
Sorry, but when Psionics files will be finished ;-) ?

>In particular, ES may be altered
>by the operating system without warning.
It is not so true. ES register may be altered by EPOC only in 2 cases:
   1. ES had a value of valid segment and this segment was moved
   2. OS call return something in ES register (as in example you mentioned)
So it is safe to use ES as a valid pointer to segment - you only need to take
care (e.g. disable interrupts) during its changing from memory location (e.g.
from OS internal tables)

>Many compilers assume they are
>running on MSDOS, and so can use ES as a scratch register.
I don't know such compilers, do you?. But many of them may optimize e.g.
strcpy function by implementing it inline, or copy structure using MOVSB
command and of course they don't generate CLI/STI while setting ES value -
only this may cause a problem. If your C program
   a. compiled to small model
   b. doesn't use small pointers
   c. has no structure assignment
   d. you never use libraries from this compiler
I see no reason to alter ES register by any DOS compiler in your code.

>(4) The only safe place to get a value to put in a segment register is
>from another segment register.
... or from documented memory locations or to ROM.

>(5) One exception is that the system call GenDataSegment sets ES to the
>start of the kernel data segment.
And other but not last is PDD entry point :-)

Regards,
Konstantin
--------------------------------------------------------
Konstantin I. Saliy             |e-mail:  <kis@ipmce.ru>
Institute of Precision Mechanics|Leninsky prospekt, 51  
	and Computer Equipment, |Moscow, Russia, 117914 
    Russian Academy of Sciences |(095)132-9277          
--------------------------------------------------------

Article: 30459 of comp.sys.psion
Subject: Re: Using CALL to get file size
/*        The following OPL code shows how one might get certain
	  details of any file from within an OPL program

	 It uses the EPOC System Service: FilStatusGet as described on
	 pp. 39 of both the old EPOC manual and the new one. This is
	 as follows for those without access to the documentation:
	 ----------------------------------------------------------------
	  FilStatusGet

	  AL   -    Zero for synchronous request
	  AL   -    Non-zero for asynchronous request
	  DX   -    If AX is non zero, DX points to status word
	  BX   -    Pointer to name of file or directory
	  CX   -    Pointer to the FileStatusEnt structure

	  Returns:
	       
	       Success
	       NameErr
	       NotExistsErr
	       DirErr

	  ----------------------------------------------------------------
	  The FilStatusEnt structure is essentially the same as the PLIB
	  structure 'P_INFO' which is as follows:

	  typedef struct {
	  unsigned short int version;                 for future expansion
	  unsigned short int status;                           status bits
	  unsigned long int size;                         size of the file
	  unsigned long int modst;        system time of last modification
	  unsigned char spare[4];         spare bytes for future expansion
	  } P_INFO;
	  ----------------------------------------------------------------

#define FileManager  $0087
#define FilStatusGet $0800


PROC fsize&:(f$)

	LOCAL pinfo$(16),ppinfo%,fname$(20),err%,ret&
	LOCAL ax%,bx%,cx%,dx%,si%,di%         /*  variables MUST be in 
this order  */

	ppinfo% = ADDR(pinfo$) + 1                    /*  pinfo$ is 
P_INFO struct  */
	fname$ = f$ + CHR$(0)                    /*  name must be 
zero-terminated  */

	ax% = FilStatusGet
	bx% = ADDR(fname$) + 1          
	cx% = ppinfo%
	dx% = $00
	di% = $00
	si% = $00

	err% = OS(FilManager,ADDR(ax%))
	
	IF (err% AND 1)
		ret& = (ax% AND $FF) - 256
	ELSE
		POKEB ADDR(pinfo$),16
		ret& = PEEKL(ADDR(pinfo$) + 5)
	ENDIF

	RETURN ret&

ENDP

/*

	This program returns the length of a file but, given that
	you now know the P_INFO structure, you can use it to find
	out the status, size or modification date.

*/

Regards,  Dave@Psion

Article: 30494 of comp.sys.psion
Subject: Re: Books about programmimg the 3a...?
boys@news.aspentec.com (Ian Boys) wrote:

try Dave Stafford's Psion rogramming Reference on the Web

http://www.primate.wisc.edu/people/dubois/psion/oplman/psion.html

Tom

Article: 30668 of comp.sys.psion
Subject: Re: Data acquistion on Psion
>Physiology Department <k.boone@ucl.ac.uk> wrote:
>>Does anyone know of any way to use a Psion 3a for data
>>acqusition? Ideally we would like to be able to display the
>>incoming data in 'Oscilloscope' format. Thanks for any advice.
>
>I have read data from a LeCroy digital oscilloscope into my s3a via the
>RS232 serial port.   With a little programming the data acquisition
>could be made completely automatic.
>
>I don't know of any other way to get data into a psion.   A small A-to-D
>converter that fitted directly onto a serial port would be very useful;
>anybody know if such a gadget exists?

I have made a data aquisition application for the Psion 3a. It can convert
data from analog to digital with a resolution of 8 bits, sampling rate
is ca. 1 sample per second, the incoming data can also be displayed in
'oscilloscope format'. Data can be sampled on up to eight channels.

-- 
Bernhard Scheffold
Breisacher Strasse 37                   email: bernhard@popeye.freinet.de
D-79106 Freiburg                        phone: +49 761 288124
Germany

Article: 30679 of comp.sys.psion
Subject: Using OS call to get RAM disk used.
Have been playing aboout with this and getting less success than
I expected. I have an OLP version of the sysmem code, and have been
adding to it. It is quicker to do that, test and get working, and
then turn it back in to macro for macsys.

However the OS call FilStatusDecive   Fn $87  Sub $0A does not 
seem to work. Changing to Sub $0B I get expected results. 

I expect there is a simple bug in my code, but 24hours on, I can't
see it. Can any one else help?

The code looks like this:

PROC sm:
REM SysMem (c) JBSoft 1995
REM with help from Wolgang Schirmer
local l&,a%,s&,p%,d&,buf&(16),status%,dev$(8),x&,x%
local buf%(32)
rem these two calls work OK
s&=abs(call($d8b,0,0,0,0,0)) rem get System memory total
s&=(s&*16)/1024
l&=call($80,0,0,0,0,0) rem get System memory free
l&=(l&*16)/1024
rem this just does not seem to work at all. The answer is always much
rem smaller than it is expected to be
d&=call($c80,0,0,0,0,0) rem get disk space used
d&=(d&*16)/1024
print d&
dev$="LOC::A:"
rem FilDeviceStatus
x%=call($0a87,addr(dev$),addr(buf%()),addr(status%),0,0) rem get disk
space used
print x%, status%
x%=0
do
x%=x%+1
print x%, " - ", buf%(x%)
until x%=16
x%=get
ENDP

The output is X%=-38   status%=0
and buf%(1) to (16) are all zero

-38 appears to be Badname, but I have a LOC::A: and LOC::B: and LOC::M:. 
Whichever I use the result is the same.
-- 
Yours John.

*** May the WebForce be with you! ***

Article: 30696 of comp.sys.psion
Subject: Re: Using OS call to get RAM disk used.
John,

I was faced with exactly the same problem about a week ago (and used
comp.sys.psion to solve it!)...

In OPL, strings are represented as follows:
    Offset 0 contains a one-byte value representing the length of the string
    Offset 1 is where the string actually starts

What you need to do is supply the address of the NULL-terminated string to the
CALL function like this:

    dev$="LOC::A:"+CHR$(0)    :REM null-terminate the string
    call( ..., uadd( addr(dev$),1 ), ... )   :REM add 1 to get to first byte.

You should use the UADD function instead of just saying ADDR(dev$)+1 to avoid
errors you might get adding signed integers (i.e. jump from maximum positive
value to max negative)

Hope this helps,
Lee.
--
  Lee Hollingdale               email : L.A.Hollingdale@durham.ac.uk
  Dept of Computer Science        WWW : http://www.dur.ac.uk/~dcs3lah
  University of Durham          phone : 0191 374 3651/3253 (dept/college)


Article: 30702 of comp.sys.psion
Subject: Re: rdS3Aagn.opl?
Fionn Behrens <fionn@informatik.uni-siegen.de> wrote:
> I wonder If anyone of you has an OPL example for reading the *3a* Agenda.
> The 3a agenda format explanations at psionics refer to C structs,

No it doesn't !

It describes the file as a set of data structures, giving the offsets and
size of each field. The way to handle this in general is:

* Declare a buffer variable large enough to hold the relevant structure.
If the structure is 32 bytes long, then:

    local buffer%(16)
or
    local buffer&(8)

will do (divide by 2 for % names and by 4 for & names).

* Read the structure into memory starting at "addr(buffer%())", say by:

    ioread (handle%, addr(buffer%()), 32)

* Access fields using PEEKB, PEEKW, and PEEKL: to get at a "word" at
offset 12, go:

    peekw(uadd(12,addr(buffer%()))

and to alter a "long" at offset 17 go:

    pokel uadd(17,addr(buffer%())),newval&


[You will find it convenient to store "addr(buffer%())" in a variable.

Clear ?


What the Psionics Files *do* refer to are "C strings". These are strings
that end with a zero byte, unlike OPL strings, which begin with a length
count. The introduction explains how to convert between them.

-- 
Clive D.W. Feather                       | If you lie to the compiler,
clive@demon.net        (work, preferred) | it will get its revenge.
clive@stdc.demon.co.uk (home)            |   - Henry Spencer


Article: 30761 of comp.sys.psion
Subject: Re: Data acquistion on Psion
In message <4p1d3a$cfu@news.ox.ac.uk> Timothy Giles wrote:

> Physiology Department <k.boone@ucl.ac.uk> wrote:
> >Does anyone know of any way to use a Psion 3a for data 
> >acqusition? Ideally we would like to be able to display the 
> >incoming data in 'Oscilloscope' format. Thanks for any advice.
> 
> I have read data from a LeCroy digital oscilloscope into my s3a via the
> RS232 serial port.   With a little programming the data acquisition
> could be made completely automatic.
> 
> I don't know of any other way to get data into a psion.   A small A-to-D
> converter that fitted directly onto a serial port would be very useful;
> anybody know if such a gadget exists?

Have a look in the Xemplar catalogue (01223 724200) or try their
web site (http://www.xemplar.co.uk/) for info on Pocket Lab, a data-
logger that connects to the Psion 3a or Acorn Pocket Book allowing 
on line data-logging. Lots of different sensors available, up to 
three sensors can be used at a time.
If you get stuck, mail me.


-- 
Paul Magnall
Resource Facilities              Xemplar Agents for West Yorkshire

Article: 30843 of comp.sys.psion
Subject: UK Psion BBS - Free - Yes, free - +44 1494 758998
Q.
* Where are there nearly 800 Psion files, for the 3, 3a, and Organiser?
* Where are those files sorted and given good descriptions?
* Where are those files put in sensibly named file areas for ease of
  retrieval?
* Where are there also Psion FAQ's, Emulators, Compilers, Compactors,
  and the Psionics files?
* Where are the latest files in comp.binaries.psion added daily?


* Most importantly, where is all this (and a lot more) free?

A.
Psychotic Mouse BBS - +44 1494 758998 - VFC, 24hrs - the best Psion BBS in
the UK. If you don't believe me, call now. You'll see.

FREQ's of files are allowed, and Psychotic Mouse BBS is the home of PHPS - 
all the files and the catalogue are available from the BBS via e-mail.

Join thousands of others and call now,

+++++   +
  | +-+ +-+ |\ |
 -+ +-+ | | | \|

 John@pmbbs.demon.co.uk
 BBS - 01494 758998 - Over 27 megs of F1 pics, movies and info,
		      almost 800 Psion related files, Oasis stuff
		      and more! Free Usenet and E-mail to all!

Article: 30973 of comp.sys.psion
Subject: Re: How can we calculate a CRC in OPL?
Martin Brousseau (nitram@lpl.univ-aix.fr) wrote:

> I am developing and application using serial communication to a controler
> card and a CRC (checksum) must be attatch to each command before to send it
> via the RS232. The CRC is calculated with an XOR over all caracters in the
> command to be sent. Is anyone have an idea on how to calculate this kind of
> CRC in OPL. There is no XOR operaror in OPL!

Well here's one I made earlier which calculated a checksum on 32 bytes of
EEPROM dowloaded from a satellite receiver.

  REM calculate checksum
  i%=1
  csum%=$5A
  DO
    csum%=(csum% OR eeprom%(i%)) AND (NOT (csum% AND eeprom%(i%)))
    i%=i%+1
  UNTIL i%>31

Boolean logic freaks will understand what it is all about ;-)

| A   B | A OR B | A AND B | NOT (A AND B) | (A OR B) AND (NOT (A AND B)) |
+-------+--------+---------+---------------+------------------------------+
| 0   0 |   0    |    0    |       1       |               0              |
| 0   1 |   1    |    0    |       1       |               1              |
| 1   0 |   1    |    0    |       1       |               1              |
| 1   1 |   1    |    1    |       0       |               0              |

BTW a CRC is a long way from a checksum.

-- 
|- Nick Craig-Wood ---------------------------------- ncw@axis.demon.co.uk -|
|---- Keep those cards and letters coming, and please don't call again -----|


Article: 31012 of comp.sys.psion
Subject: Re: Calling "Home City" via OPL
In article <4phmmu$n6v@linux.nildram.co.uk>, Phil Spencer
<nicko@nildram.co.uk> writes
>Hi,
>
>I would be very grateful if anybody could help me with my problem.  I
>wish to do some sort of call in order to get the name of the home city
>from the Time app for instance (or is it a system variable?).  I am
>totally stuck on this,

Try the following:

Proc home:
   local hnd%, d%,data$(41)
   d%=addr(data$)
   if not ioopen(hnd%,"WLD:",-1)        rem Open the World device
	iow(hnd%,15,#d%,#0)             rem fn 15 = Get Home City
	dinit "Home City"
	dtext "City of:",sz2sc$:(d%)
	dialog
   endif
endp

rem This proc converts zero terminated strings to count prefixed
rem ones as used by OPL. Takes address of string as param.
proc sz2sc$:(s%)
   local d$(31),d%,c%,i%
   d%=addr(d$)
   do
	c%=peekb(uadd(s%,i%))
	i%=i%+1
	pokeb uadd(d%,i%),c%
   until c%=0 or i%=31
   pokeb d%,i%-1
   return d$
endp

I have just discovered that the above will return garbage if you have
updated the city. Because I have an older 3a I had to update all UK
cities for phone day. I suspect that this is a bug in the World device
driver.

Anybody got any advice here (I have Version 3.22F English) ?

If your machine has the updated dialling codes in ROM you'll be OK.
Info for the code came from WLD.TXT which I got from Steve Litchfield's
3Lib. I can mail this to you if you like (or you can contact Steve about
3Lib and get loads of other useful stuff on disk for a modest fee).


Article: 31013 of comp.sys.psion
Subject: Re: How can we calculate a CRC in OPL?
>Hi,

>I am developing and application using serial communication to a controler
>card and a CRC (checksum) must be attatch to each command before to send it via the

Rolf Aeschbacher has written a CRC calculation program which does 
a CCITT-CRC (routines are built into Psion ROM) and also a CRC-32.
You my contact him via 100116.3357@compuserve.com (IIUR), otherwise
find a link to his pages from Mark Goulds page (Link to there is 
on mine)

>RS232. The CRC is calculated with an XOR over all caracters in the command to be sent.
>Is anyone have an idea on how to calculate this kind of CRC in OPL. There is no XOR
>operaror in OPL!I heard about the system call $298b but I don't know how to use it and

PROC XOR%:(a%,b%)
	LOCAL xor&
	xor&=&cbc333
	RETURN USR(ADDR(xor&),a%,b%,0,0)
ENDP

Cheers,
Brendan


_________________________________________\____________________Brendan W. Breede
					  \
D-28325 Bremen                             \
Graubuendener Strasse 77                    \
+49-421-400104 (fax+voice)                   \
brendan@informatik.uni-bremen.de              \
http://www.informatik.uni-bremen.de/~brendan/  \
________________________________________________\______________________________
[ Life is like a Ferrari: too fast - but so what, you can't afford it anyway! ]


Article: 31052 of comp.sys.psion
Subject: Re: Add files or multi-bitmaps or resources?
On Fri, 14 Jun 1996 16:41:58 +0100, Andrew Witbrock
<andrew@cursci.co.uk> you did thus say:

|What I would like to know is.... Is there really a limit to 4 add files?  
|If I put more than four in the list I don't get an error.

If you run edump you can check to see if the file was embedded
properly. (Look at the Add offsets in the output of edump). 

|How do I merge a number of bitmaps into a single bitmap?  Each of my 
|bitmaps has a grey plane too.  Is there some standard application (under 
|DOS) to do this?

Yes, use the WSPCX program that comes with the SDK. Your bitmaps
should be separated into black and grey planes (i.e. a two-colour icon
should be in two separate bitmaps, one for grey and one for black
plane). You will need to create a .PLK file (I think) and then run
WSPCX which will merge them all into one big file. I have done the
same thing myself - I merged bitmaps into the app. icon (remember app.
icon must be first two bitmaps!) then merged other bitmaps after that.
Running WSPCX on its own will list the syntax. (BTW I use Draw28 to
separate grey and black bitmaps since this is easy to do from there).

|How exactly do I find a file in the add file list?

I have some code at home that might be useful to you. Ill have to dig
it out. Drop me some email to remind me!

|Is it possible (or desirable) to construct a resource containing each of 
|my bitmaps and to load the bitmaps from the resource?

Ive never used resource files (yet!) so can't help. Maybe JB or Cade
Roux are reading and can jump in here?

Regards,

--
Aj. (ajai@nwt.com)
New World Technologies - `the Psion house'
"I was a romantic... then I discovered reality..."


Article: 31098 of comp.sys.psion
Subject: Re: Calling "Home City" via OPL
A. Wilson wrote:


>    if not ioopen(hnd%,"WLD:",-1)        rem Open the World device
>         iow(hnd%,15,#d%,#0)             rem fn 15 = Get Home City



> I have just discovered that the above will return garbage if you have
> updated the city. Because I have an older 3a I had to update all UK
> cities for phone day. I suspect that this is a bug in the World device
> driver.

I have version 3.22F - USA.

No problem with getting new or updated cities. However, after having 
obtained the first data with the 15, I repeat the iow with a code of 22 
to get all the details (long, latitude etc). (Make sure that the buffers
are at least 40 bytes long). I also supply an actual buffer address as 
the 3rd argument (which remains unused in my programme).

Hope this helps.

Article: 31206 of comp.sys.psion
Subject: Re: Calling "Home City" via OPL
In article <31C6F29A.6C2C@istar.ca>, Jean-Francois Mezei
<jfmezei@istar.ca> writes
>
>No problem with getting new or updated cities. However, after having 
>obtained the first data with the 15, I repeat the iow with a code of 22 
>to get all the details (long, latitude etc). (Make sure that the buffers
>are at least 40 bytes long). I also supply an actual buffer address as 
>the 3rd argument (which remains unused in my programme).
>
>Hope this helps.

Thanks for the response. Since my first mailing the problem seems to
have gone away. I exited World and renamed world.wld to temp.tmp and
everything started working (albeit with the incorrect STD codes) - hence
my assumption. However, when I renamed it back to world.wld it started
to behave itself. Curious.

P.S. I think you need a buffer of 80 bytes for the 22


Article: 31269 of comp.sys.psion
Subject: Re: ## Unable to compile S3A programs in c (sibo) ##
Broothaers erwin wrote:
> 
>      Question: what must add to a c program (HWIF or OOP) to access
> the full s3a , non S3 comp. mode  (screen res=480x160)?
> 

In HWIF, you need to do the following:

GLDEF_C INT main (VOID)
{
    GLREF_D WORD _UseFullScreen;
    _UseFullScreen = TRUE;
    uCommonInit();

    :
    :
    :
}

for a description of uCommonInit(), see the HWID manual.


Chris.

+--------------------------+------------------------------------------+
| Chris Berry              |             mailto:chris-berry@psion.com |
| Software Engineer, Psion | http://www.geocities.com/TheTropics/4589 |
+--------------------------+------------------------------------------+
|           Any opinions I express are mine, not Psion's              |
+---------------------------------------------------------------------+


Article: 31887 of comp.sys.psion
Subject: Re: Help: need backup shareware
Jin Mai wrote:
> 
> I brought 3 link two year ago. The PC link software comes
> with the 3 link cable doesn't work in Win95. Can anyone
> suggest a shareware or any software that can backup
> the Psion 3a?

I am running the Psion MCLINK software that came with the 3-Link cable with Windows 95, and it runs 
fine. However it needs a bit of manual configuration (as it does in DOS or Win 3.1).

The MCLINK program merely enables the Psion to "see" the PC drives as "REM::" (remote) drives. These 
drives can be used as a backup target. I have set up Drive P on my hard disk using DriveSpace (supplied 
with Win95), and I create a new directory every time I wish to backup my 2MB Psion. I then use the 
"Backup Files" (Psion-Shift-B) menu option to copy whatever I need to drive P. See the 3a manual for 
details on this option.

The MCLINK program has the following properties:
Command Line:
    <drive>:<path>\MCLINK.EXE -p2 -b19200

Note: -p2 means COM2 (use the appropriate value, unspecified means COM1)
      -b19200 means 19,200 baud (default 9,600)

On the "Advanced Program Settings" screen (off the "Program" tab sheet) tick the box marked "Prevent 
MS-DOS-based programs from detecting Windows", and leave the other two boxes unchecked.

The only other thing I've done is to have the program run as minimised, but this is purely cosmetic.

If you cannot get this to work, I suggest your problem lies elsewhere, say the cable, or your COM port 
(driver or hardware), or the (MCLINK) program configuration. Feel free to email me if you cannot get 
this resolved.

Regards
Alan Shanahan


Article: 31896 of comp.sys.psion
Subject: Re: Data acquisition on Psion
>In article <1996Jun4.081144.37172@ucl.ac.uk>, Physiology Department
><mailto:k.boone@ucl.ac.uk> wrote:
>>
>> Does anyone know of any way to use a Psion 3a for data
>> acqusition? Ideally we would like to be able to display the
>> incoming data in 'Oscilloscope' format. Thanks for any advice.
>>
>
I have been using data loggers from Orion (orion@oriongrp@demon.co.uk)
for some time now. They come in a variety of case styles - I use the one in a
35mm film can - it will store 8k data points at intervals of 1 sec to 10 days,
has programmable alarms etc. etc. The interesting bit is that they now have
Psion software available to set them up, offload and display the data (in 'scope
format) + the original PC stuff which is Lotus/Excel compatible.

JohnF

John.Fessey@jet.uk

===============================================================================
    The above article is the personal view of the poster and should not be
       considered as an official comment from the JET Joint Undertaking
===============================================================================


Article: 32106 of comp.sys.psion
Subject: Re: Toggling RS232 control signals on a Psion serial link.
Paul J. Holthuizen wrote:
> 
> LS,
> 
> After spending a friday and the best part of this weekend in trying I
> finally throw the towel in the ring. (is that English)
> 
> Is there anyone out there able to explain to me how I can toggle signals
> like DTR, DSR, RTS or CTS on a serial link connected to a Psion 3a?
> I seem to be missing some relevant information, that might be in the
> OPL/SDK (Which is, of course, hard to get by in Holland. Order it, and
> it will be yours. In about a month)
> What I'm looking for is to toggle at least 2 rs 232 signals
> (independantly), that are going to be used to switch a couple of triacs
> on and off (ok ok, with some extra electronics) The rest of the
> application is working fine, nice menu's etc, nice pulse-width control,
> only - no pulse!
> I mucked around with all the examples in the book, (LOPEN, IOOPEN,
> RSSET), IOW-function number 11, etc, and failed miserably. It should be
> possible from within an OPL program, but HOW?
> I wonder, is there maybe a way to just POKE the stupid signals up and
> down?
> I will be very very glad if someone took the time to at least point me
> in the right direction. Otherwise I might just do some destructive
> hardware testing on my poor 3a (that can't help I'm an ignorant fool).
> Many, Many thanks in advance.

You are looking for the FCTRL serial device driver function (it's
function
number is 11).  Using this function allows you test if CTS, DSR or DCD
are
active.  It also allows you to set the DTR line active or inactive.

To set the DTR line active use:

   LOCAL ctrl%

   ctrl%=$100
   IOW(handle%, 11, ctrl%, #0)

where handle% is the handle of the serial port.  To set it inactive
ctrl% should equal $200 instead of $100.

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


Article: 32132 of comp.sys.psion
Subject: Re: Lat/Long conversion....HELP!!!!!!!!!!!
In article <53dr90$f72@ezekiel.ieunet.ie>, Jim Barrett <Satcom@Douglas-
esl.ie> writes
>
>
>Hi,
>
>I receiving lat/long co-or from a remote GPS receiver via mobile phone.
>I wish to display these co-ordinates on AutoRoute.  My problem is I
>don't know the coversion formula for this.  All my GPS sites will be
>with either in the UK or Ireland.
>
>Example
>
>53 20.8N 6 16.0W --> formula ---> 011600 039200
>
>Any ideas anyone?
>
>Thanks for reading this, regards,
>Jim
>
Hi Jim,

I have two programs for conversion between Lat/Long and UK Ordnance
Survey Grid (which I assume 011600 039200 is). One for OSGB36 Datum and
another for WGS84 Datum.

They cover the whole of the Mainland England for Grid==> Lat/Long
conversions and this would cover Ireland, but are limited between 6dW
and 6dE for Lat/Long==> Grid. This limitation is a bit artificial as it
is to ensure that the result does not go outside the Grid, but it
exists.

They were never intended for use outside the UK Mainland, but you are
welcome to try them.

Alternatively, you can find the formulae in OS Booklet 'Transverse
Mercator Projection, Constants, Formulae and Methods'. To do the WGS84
Transformation you will also need Geodetic Information Papers Nos 1 & 2,
also published by OS.

The email address for Ordnance Survey is: custinfo@ordsvy.govt.uk.

Tim.
Specialist Systems Ltd.                 Tel/Fax: +44 (0) 1276 33706
32 Fernhill Lane
Camberley
Surrey. GU17 9HA.


Article: 24 of comp.sys.psion.programmer
Subject: Re: Cut n Paste
As I recall, the inter-application cut and paste works in a non 
"intuitive" way.

Your application sends to the other application a message which contains 
the address and size of the buffer inside your process which contains 
the copied data.

The application then uses a system call to copy the data from your 
process' memory space into its own memory space and then does what it 
wants with it. 

This is why the 2 applications must be running concurrently (since the 
app with the data must be able to respond to the app wanting the data)

This is documented in the SDK documentation. I am not sure it is 
documented in the OPL manual.


Article: 31 of comp.sys.psion.programmer
Subject: help : How to send an <esc> char via 3-link
Hello Dirk!

Replying to a message of Dirk  to All:

 D> I want to use my psion 3a with a special modem for packet radio (Ham 
 D> Radio Amateur).  The modem needs <esc> characters to accept commands.
 D> Does anyone know how I can send such <esc> characters ???

The standard code for <ESC> is 27. 

In OPL, either LPRINT CHR$(27); if you are using LPRINT, or 

c%=27
ret%=iowrite(h%,addr(c%),1)


Article: 49 of comp.sys.psion.programmer
Subject: Re: ## problems programming in C for psion S3a ##
Alasdair Manson wrote:
> 
> In article <DtnF2w.4B5@ddvictor.dundee.ATTGIS.COM>,
> sandy.barbour@dundee.attgis.COM says...
> 
> >GLREF_D UWORD _UseFullScreen;
> 
> Hello
> 
> In order for the uCommonInit() which ships with HWIF to give you the full
> screen if it can, _UseFullScreen has to be set to true. If it is still true
> after the uCommonInit() then you are all set.
> 
> The source of uCommonInit() ships in \SIBOSDK\HWIFSRC\UHWIF.C so you can see
> exactly what it is doing.
> 
> All the best
> 
> Ali

Hi Ali

Apparently my post was cut short

It should have been :-

#include <p_std.h>
#include <p_date.h>
#include <p_file.h>
#include <wlib.h>
#include <hwif.h>

GLREF_D UWORD _UseFullScreen;

.
.
. Other Stuff
.
.


GLDEF_C VOID main(VOID)
{
    _UseFullScreen = TRUE;
    uCommonInit();
    SpecificInit();
    MainLoop();
}

Can't win them all

Sandy


Article: 59 of comp.sys.psion.programmer
Subject: Re: WSERVER  what is it ?
In article <4s2gac$9up@newsgate.dircon.co.uk>, dolbyn@dircon.co.uk says...

>I periodically get interested in writing an app to transfer 
>files to/from my psion. I know I can use rfm/rcom/psiwin etc, 
>but theres a certain satisfaction in writing things yourself
>The link protocol seems to be a secret (?) but I remember
>something about a dll that you could link to in windows to 
>do the work.  was/is this WSERVER?
>
>I'd rather not have to write any thing on the psion side
>(no flames please) but rather would like to use the built 
>in link software.

Hello.

If you contact your local Psion distributor (in your case that would appear to 
be Psion UK plc who can be emailed as uk-support@psion.com) then you can obtain 
a development kit known as PRC which comes with a DLL and a VBX allowing you to 
integrate a 3a with a C/C++ or VB program for Windows.

The kit is not a secret and it is free of charge.

All the best

Ali


Article: 77 of comp.sys.psion.programmer
Subject: Re: Language detection.
In article <83040367_Beta04_OASIS_NEWS@nest.demon.co.uk>
dbrewood@nest.demon.co.uk (Daron Brewood) wrote:

>Thanks Bren, any ideas which countries correspond to the returned 
>variable?

Taken from the psionics files (they are really worth a look if you
need such information...):

    00  Testing
    01  English - UK
    02  French - France
    03  German - Germany
    04  Spanish
    05  Italian
    06  Swedish
    07  Danish
    08  Norwegian
    09  Finnish
    10  English - USA
    11  French - Switzerland
    12  German - Switzerland
    13  Portuguese
    14  Turkish
    15  Icelandic
    16  Russian
    17  Hungarian
    18  Dutch
    19  Flemish
    20  English - Australia
    21  English - New Zealand
    22  German - Austria
    23  French - Belgium


_________________________________________\____________________Brendan W. Breede
					  \
D-28325 Bremen                             \
Graubuendener Strasse 77                    \
+49-421-400104 (fax+voice)                   \
brendan@informatik.uni-bremen.de              \
http://www.informatik.uni-bremen.de/~brendan/  \
________________________________________________\______________________________
[ Life is like a Ferrari: too fast - but so what, you can't afford it anyway! ]


Article: 103 of comp.sys.psion.programmer
Subject: Re: Reading from Serial Port (NMEA sentances)

> 3. Post a bit of code so we can have a look.

OK wel ive been fiddling and have now got the program working.

for your info heres the code i am now using:

PROC openport:
  LOPEN "TTY:A"
  rsset:(13,0,8,1,4,&0)
ENDP

PROC getnmea$:
  LOCAL ret%,pbuf%,buf$(255),end%,len%
  len%=255
  pBuf%=ADDR(buf$)
  DO
    ret%=IOREAD(-1,UADD(pbuf%,1),len%)
  UNTIL ret%>0
  POKEB pbuf%,len%-1
  RETURN buf$
ENDP

That is the main part of the program as far as reading the data goes, 
the program then calls the getnmea$ procedure, one part of the program 
merely shows the raw data, so its a simple case of a loop woth the 
'PRINT getnmea$:;' command in it

I was wondering, would it be better to not read into a string ?, would 
i be better to use an array ? - the IOREAD command will read upto 16K, 
so i think that might be better, anyhow at least now ive got some 
working code !.


Thanks everyone for your help, it was most appreciated :)


> 4. I reckon I can easily modify the PC program I'm using to 
constantly sling a
> string down the serial line at 4800.  I'll have a look at the 
weekend, with an
> OPL program that just prints out the received data.

cheers, youre such a wonderful person, were so lucky people like you 
read this newsgroup :)

Phill. - no longer a confused OPL programmer !!!!

Article: 104 of comp.sys.psion.programmer
Subject: Re: Reading from Serial Port (NMEA sentances)
> I figured it might be OPL not keeping up but seeing as programs like 
> Mapper and AutoGPS can do it i guess that it can be done, but how??? - 
> any further help would be REALLY appreciated !.

The secret is to throw away most of what's sent, and not try to log 
*everything*! Just sample the bytes that arrive when you actually want to 
look, and even then don't worry if you miss a bit ... 8-))

Steve

Article: 114 of comp.sys.psion.programmer
Subject: Reading from Serial Port (NMEA sentances)
Hello Philip!

Replying to a message of Philip Wood <philip@odinm.demon.co.uk>

 PW> That is the main part of the program as far as reading the data goes, 
 PW> the program then calls the getnmea$ procedure, one part of the
 PW> program  merely shows the raw data, so its a simple case of a loop
 PW> woth the  'PRINT getnmea$:;' command in it

You might find when you start processing the result of getnmea$, you will lose
characters again or get full buffers.

 PW> I was wondering, would it be better to not read into a string ?, would 
 PW> i be better to use an array ? - the IOREAD command will read upto
 PW> 16K,  so i think that might be better, anyhow at least now ive got
 PW> some  working code !.

It doesn't really matter if you read it into a string or an array - both are
just reading into a block of memory. You should choose the one which is
easiest/quickest to process afterwards - probably strings in your case.

A few comments that may speed your code up a little bit:

 PW>   pBuf%=ADDR(buf$)
[...]
 PW>     ret%=IOREAD(-1,UADD(pbuf%,1),len%)

Every time you read a line in from the GPS, you are doing the above
calculations - basically finding the address of buf$, then adding 1 to it with
the UADD.

If you make buf$ and pBuf% a GLOBAL instead of LOCAL, you could then do
pBuf%=ADDR(buf$) just once, at the start of the program, instead of every time
you read in a sentence.

I don't know how much time this will save, but if you want to not loose
characters you don't want to waste processor time when you can avoid it.

Article: 121 of comp.sys.psion.programmer
Subject: Re: Reading from Serial Port (NMEA sentances)
Thus speaketh the one known as Alan Clifford
<alanc@donor2.demon.co.uk> 

 > Hello Philip

 >  PW> OK wel ive been fiddling and have now got the program working.

 >  PW> for your info heres the code i am now using:

 >  PW> PROC openport:
 >  PW>   LOPEN "TTY:A"
 >  PW>   rsset:(13,0,8,1,4,&0)
 >  PW> ENDP

 >  PW> PROC getnmea$:
 >  PW>   LOCAL ret%,pbuf%,buf$(255),end%,len%
 >  PW>   len%=255
 >  PW>   pBuf%=ADDR(buf$)
 >  PW>   DO
 >  PW>     ret%=IOREAD(-1,UADD(pbuf%,1),len%)
 >  PW>   UNTIL ret%>0
 >  PW>   POKEB pbuf%,len%-1
 >  PW>   RETURN buf$
 >  PW> ENDP

 > I'm glad you've got it working.

 > This reads 255 characters at a time doesn't it, as there's no
terminating
 > character?  Isn't there a problem that the end of the 255
characters will be in
 > the middle of one of your strings?

 > Alan

Instead of 
 >  PW>   POKEB pbuf%,len%-1
use
 POKEB pbuf%,ret%

to set the correct string length. If I remember correctly IOREAD
returns the number of bytes read.

Regards,
Andy L.
--
Andrew Leroy Lord <Andrew_Lord@tertio.co.uk>
Network Systems Management Consultant/Applications Developer.
This post is my own opinion and not necessarily that of my employers


Article: 116 of comp.sys.psion.programmer
Subject: ADT libraries for OPL
Hello Stephen!

Replying to a message of Stephen Eaton to All:

 SE> Is there any Advanced Data Type libraries for OPL out there.  e.g.
 SE> Linked lists, stacks etc.

I've never heard of any - people don't seem to use advanced data types in OPL,
seeing as its BASIC :-)

You could have a bash at writing them yourself and making them freely available
:-)

As a start, you could do a stack something like this: (just made up off the top
of my head so I don't know if it works :-)

Proc MakeStack%:(size%)
	local p%
rem Allocate space for stack plus a word at the beginning for the top offset.
	p%=alloc(uadd(size%,2))
rem Set the top offset to 0 (because there is nothing on the stack)
	pokew p%,0
	return p%
EndP

Proc Push:(p%,n%)
rem set the value at offset*2 + 2 to the value to be pushed (n%). 2 is added on
to skip over the top offset at the beginning of the block.
	pokew uadd(p%,(peekw(p%)+1)*2), n%
rem increment the top offset
	pokew p%, peekw(p%)+1
EndP

Proc Pop%:(p%)
rem decrement the top offset
	pokew p%, peekw(p%)-1
rem return the value on the top of the stack
	return peekw(uadd(p%,(peekw(p%)+1)*2)
EndP

Ben


Article: 129 of comp.sys.psion.programmer
Subject: Re: ADT libraries for OPL
seaton@bis.net.au (Stephen Eaton) wrote:

>Is there any Advanced Data Type libraries for OPL out there.  e.g.
>Linked lists, stacks etc.

Well, if you have OPP, it's quite easy to do.  This was the very first
thing I tried when structs were added to opp.  It works, but (as has
been pointed out elsewhere) it might be better to add an extra layer
of memory management that allocates umpteen list cells at once, rather
than individually.  

(To be honest though, I don't care - such efficiency hacks should come
*after* you've got the basic functionality right, and even then, I'd
only bother with them if I really start to have performance problems.
There are too many examples of code where a lot of (pointless) effort
has gone into improving the efficiency of proc A when the *real*
bottleneck is proc B.  And it's all too easy to get the hack mixed up
with the essence...)

I'd hate to do this in "bare" OPL.  Of course, it can be done, but
OPP provides some nice syntax that makes it easier to write and
(even more important) easier to use.

The main program here is really a dummy to convince myself that it
kinda works - the library procedures are the main stuff.  However, I've
not used any of this in earnest, so it's probably dead easy to break.
(And, alas, I've not got round to doing much serious work with OPP
yet, just porting some old OPL to it really.)

In opp, all struct pointers are actually ints.  So once you have an
intlist struct like this, you're most of the way to having an
"anything" list...  and of course, you can use lists to implement
many more ADTs (though it's probably better to do it more directly).

(Naturally, the code here won't make much sense unless you know about
OPP.)

(PS-ish: I tidied up the formatting of the code a little - I never like
editors that insert TABs for me - so apols if I've broken anything as
a result.)

Brian
----
/*
    Using structs to do lists of ints
    copyright Brian Ritchie Sat 24 Feb 1996 01:21:36 
    (But heck, just about anyone could write this)
*/
#define DEBUG
#ifdef DEBUG
    #pragma debug on
#endif

#pragma show_procs

     /* 
	    Each cell in the list has a value 
	    and a pointer to the next cell
     */
     STRUCT int_cell
	  /* int         */ val%
	  /* <int_cell*> */ next%
     ENDS

     /*
	     The top of a list maintains 
	     pointers to the head and tail cells
     */
     STRUCT int_list
		 /* <int_cell*> */ head%
		 /* <int_cell*> */ last%
     ENDS

    /*** MAIN procedure - demonstration ***/
    
     PROC main:
	  local <int_list*>mylist%, <int_list*>myl2%, i%

	  i% = 1
	  mylist% = mkList%:( 2*i% )
	  i%++
	  while i% < 10 and mylist%->last%
	      addlast:( mylist%, 2*i% )
	      i%++
	  endwh

	  print "This is mylist%:"
	  pList:( mylist% ) : get

	  print "Copying mylist% to myl2%..."
	  myl2% = cList%:( mylist% )

	  print "myl2% is"
	  pList:( myl2% ) : get
	  dList:( myl2% )

	  print "Now appending a copy of mylist% to mylist%..."
	  append:( mylist%, cList%:( mylist% ) )
	  pList:( mylist% )
	  dList:( mylist% )

	  print "Press any key to finish" : get
     ENDP

    /*** LIST procedures ***/
    
     LIBPROC mkList%:( n% )
	  /* 
		Create and return a single-element list 
	  */
	  local <int_list*>ptr%
	  ptr% = alloc( SIZEOF(int_list) )
	  if ptr%=0
	       print "mkList%: - alloc failed"
	       return 0
	  endif
	  ptr%->head% = mkcell%:( n% )
	  ptr%->last% = ptr%->head%
	  return ptr%
     ENDP

     LIBPROC dList:(<int_list*>list%)
	  /*
		Delete the list pointed to by list%
	  */
	 if list%->head%
	     dCell:( list%->head% )
	 endif
	 freealloc list%
     ENDP

     LIBPROC cList%:( <int_list*>list% )
		 /* return a fresh copy of list% */
		 local <int_list*>plist%, <int_cell*>pcell%
		 if list% = 0 : return 0 : endif
		 if list%->head% = 0 : return 0 : endif
		 pcell% = list%->head%
		 plist% = mkList%:( pcell%->val% )
		 while pcell%->next%
		     pcell% = pcell%->next%
		     addlast:( plist%, pcell%->val% )
		 endwh
		 return plist%
     ENDP rem cList%

     LIBPROC addlast:( <int_list*>list%, n% )
		 /* add a new cell with value n% to the end of list% */
		 local <int_cell*>tl%
		 tl% = list%->last%
		 tl%->next% = mkcell%:( n% )
		 list%->last% = tl%->next%
     ENDP

     LIBPROC append:( <int_list*>list1%, <int_list*>list2% )
		 /* 
		     append list2 to end of list1
		     
		     WARNING: uses shallow copy
		      - do not do append:( list%, list% )!!
		      - use append:( list%, cList%:( list% ) ) instead
		 */
		 local <int_cell*>elOneEl%
		 elOneEl% = list1%->last%
		 elOneEl%->next% = list2%->head%
		 list1%->last% = list2%->last%
     ENDP

     LIBPROC pList:( <int_list*>list% )
		 /* print (crude repn. of) list% */
		 print "[ ";
		 if list%->head%
		     showcll:( list%->head% )
		 endif
		 print " ]"
     ENDP

    /*** CELL procedures ***/
    /*
	These appear after the LIST procedures, as they're referred there,
	so they're included if the LIST procedures are used.
    */
    
     LIBPROC mkcell%:( n% ) /* create and return a single cell */
	  local <int_cell*>ptr%
	  ptr%=alloc(SIZEOF(int_cell))
	  if ptr%=0
	       print "mkcell%: - alloc failed"
	       return 0
	  endif
	  ptr%->val% = n%
	  ptr%->next% = 0
	  return ptr%
     ENDP

     LIBPROC dCell:(<int_cell*>ptr%) /* destroy cell (iteratively) */
		 local <int_cell*>ncell%, <int_cell*>tcell%
		 tcell% = ptr%
		 while tcell%->next% <> 0
		     ncell% = tcell%->next%
		     freealloc tcell%
		     tcell% = ncell%
		 endwh
	  freealloc tcell%
     ENDP

     LIBPROC showcll:( <int_cell*>ptr% )
		 /* display a cell (and any that follow it) */
	  local <int_cell*>tptr%
	  tptr% = ptr%
	  print tptr%->val%;
	  while tptr%->next% <> 0
	      tptr% = tptr%->next%
	      print ",", tptr%->val%;
	  endwh
     ENDP

#pragma check_procs
#ifdef DEBUG
    #include <oppdbg>
#endif

----
Dr. Brian Ritchie, Systems Engineering Division,
Rutherford Appleton Laboratory, Chilton, DIDCOT, Oxon, UK
WWW URL: http://www.cis.rl.ac.uk/people/br/contact.html



Article: 172 of comp.sys.psion.programmer
Subject: Re: .img file format
Andrew_Lord@tertio.co.uk (Andrew Lord) writes:

>What is the format of .img files.

>I can generate a block of machine code ( either on the Psion or using
>a PC based assembler ) but I want to create an image file from it.

>Anyone, Anyone ?

Hi,

I wrote this little converter for the minix/linux ld86 linker. It
converts the BSD a.out to Psion IMG. I was able to crash the Psion
emulator with a simple image containing the `ret' instruction ;-)

The IMG Format was reverse engeniered by me. So, please comment if anybody
knows details....for instance what do the magic numbers mean?

BTW: Is it true, that the Psion Img format knows no .bss segment? 
(.bss==uninitialzed data segment)

The code compiles on Linux. The Header "bsd-a.out.h" is from
the bin86-0.1 source code distribution by Bruce Evans changed by H.J.Lu.



------------------------------------------------
/*
  Convert ld86 bsd a.out to Psion 3a IMG
  */

#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/mman.h>
#include <stdio.h>

#include "bsd-a.out.h"

short chksum( short *a, int len) {
  short sum = 0;

  for ( ; len > 0 ; len--)
    sum += *a++;
  return sum;
}
  

main( int argc, char *argv[]) {
  
  int a_out_fd;
  struct stat statbuf;
  char *a_out;
  struct exec *header;
  short img_ar[12];
  FILE *img_fd;

  int i;

  if (argc < 3) {
    fprintf( stderr, "usage: %s a.out.file img.file\n", argv[0]);
    exit( 1);
  }
  
  if ((a_out_fd = open( argv[1], O_RDONLY)) < 0) {
    fprintf( stderr, "Couldn't open input file %s\n", argv[1]);
    exit(1);
  }

  if (fstat( a_out_fd, &statbuf) < 0) {
    perror( "fstat");
    exit(1);
  }

  if (( a_out = mmap( NULL, statbuf.st_size, PROT_READ, MAP_SHARED, a_out_fd, 0 )) < 0) {
    perror( "fstat");
    exit(1);
  }


  header = (struct exec *) a_out;

  if (BADMAG( *header)) {
    fprintf( stderr, "Bad Magic\n");
    exit( 1);
  }
  
  printf( "Text %x, Data %x, BSS %x\n",header->a_text, header->a_data, header->a_bss );
  
  a_out += header->a_hdrlen;

  if (NULL == (img_fd = fopen( argv[2] , "w"))) {
    fprintf( stderr, "Couldn't open %s for writing\n");
    exit( 1);
  }
  
  fwrite( "ImageFileType**", 16, 1, img_fd);
  
  img_ar[ 0] = 8207;
  img_ar[ 1] = 64;
  img_ar[ 2] = header->a_text / 16;
  img_ar[ 3] = 0;
  img_ar[ 4] = 1000;  /* Stack Size */
  img_ar[ 5] = header->a_data / 16;
  img_ar[ 6] = 128;
  img_ar[ 7] = header->a_data;
  img_ar[ 8] = chksum( (short *) a_out, header->a_text);
  img_ar[ 9]  = chksum( (short *)(a_out+header->a_text), header->a_data);
  img_ar[ 10] = 128;  /* Start up Priority */
  img_ar[ 11] = 8204; /* Version ?? */

  fwrite( img_ar, 12, 2, img_fd);
  for (i=0 ; i < 12; i++) 
    img_ar[i] = 0;
  fwrite( img_ar, 12, 2, img_fd);
  
  fwrite( a_out, header->a_text, 1, img_fd);
  fwrite( a_out+header->a_text, header->a_data, 1, img_fd);
  fclose( img_fd);
  exit( 0);
}


--
  Dr. Olaf Flebbe                            Phone +49 (0)7071-9457-32
  science + computing gmbh                     FAX +49 (0)7071-9457-27
  Hagellocher Weg 71
  D-72070 Tuebingen  Email: o.flebbe@science-computing.uni-tuebingen.de
 

Article: 174 of comp.sys.psion.programmer
Subject: Re: .img file format
Andrew Lord wrote:
> 
> What is the format of .img files.
> 

After a bit of poking about recently, guided by the output of a Psion SDK utility called Edump highlighted at 
the end of chapter 3 (building a dynamic library) of the OO Programming Guide (oodocs.zip - usual sources), I 
came to the following conclusions about the .img file header, if its of use in your conversion.  (I may be 
wrong too, of course!)
(offsets from start of file)

offset          data
 0-15           (cstr) file signature -- "ImageFileType**"
16-17           (word) image version (only seen $0F $20)
18-19           (word) header length
20-21           (word) code segment length (in 16 byte paragraphs)
22-23           (word) initial IP
24-25           (word) stack size (in 16 byte paras)
26-27           (word) data segment size (in 16 byte paras)
28-29           (word) heap size (in 16 byte paras)
30-31           (word) length of initialised data
32-33           (word) code segment checksum (don't know algorithm!)
34-35           (word) data segment checksum (don't know algorithm!)
36-37           (word) code version number
38-39           (word) start-up process priority

Regards
-- 
Julian Rush
E-mail:    c4science@dial.pipex.com



Article: 180 of comp.sys.psion.programmer
Subject: Re: Problem with IOOPEN
Anthony Walker (tony.walker@zetnet.co.uk) wrote:
[snip]
: 
: BTW, change the string space allocated to your filename variable to 
: 128. This is good practice as Psion filenames can be up to 128 bytes 
: long. but your proggie works with 25.

I spent well over a day experiencing mysterious "errors" because I hadn't 
allocated 128 bytes of string space to a filename!  It was, I think dFILE 
that refused to operate, and it had nothing at all to do with the actual 
length of the filename.

Jay D Mann  <mannj@southern.co.nz>
Christchurch, New Zealand



Article: 192 of comp.sys.psion.programmer
Subject: Re: Communication Port Pins
Mr Gates wrote:
> 
> Hi!!
> 
>         Just out of interest... does anybody out there know what the six pins on
> the Acorn Pocket Book 2's communication port are? Is it possible in OPL to send
> and recieve data through the port? The pins are as follows...
> 
>                 1 2 3
>                 . . .
>                 . . .
>                 4 5 6
> 
>         The port is commonly used for A-Link, and for 3-Fax. (The Pocket Book 2
> and Psion 3a are the same!)
> 
> Thanks, Jason :-)
> 
> --
> -- E-mail sent by Jason Gates
>   _  __  __  __      __ ___   _____________________________________________
>  /_||__)/ __/  \|\ ||_   |   /
> /  ||  \\__/\__/| \||__  |  /...Internet access for all Acorn RISC machines
> ___________________________/ gates.jdrm@argonet.co.uk


The pins are as follows:
1       MSD     Data line       
2       MCLK    Serial clock    
3       Vcc     +5 volt supply  
4       GND     Signal ground   
5       SSD/INT Interrupt line
6       SCK/EXON ?? Don't use           

the actual pin number are:

		 2 4 6
		 . . .
		 . . .
		 1 3 5



The data rate is quite fast (around 1.56M / sec)

You cannot (as far as I know) use the port through opl, I think you need
to write a device driver to control it yourself.

Cheers

Jamie Whitham


Article: 196 of comp.sys.psion.programmer
Subject: Re: Does anyone uses the CPOC-system ?
Tom Knoflook <Tom.Knoflook@hta.nl> wrote in article
<4tivfh$4bs@news.NL.net>...
> I tried the CPOC-system but it complains about missing start-up files.
> It did compile a test-program but the linker can't link without some
> start-up (object-)file.

That is correct.  The README file points out that the current release does
not support building the final .IMG file because of the missing sart-up
file and libraries.
That means that at the moment you are  really limited to using the CPCO
system as a syntax checker.

> If you're using the CPOC-system and it's not to much efford,
> can you please mail me some minimal configuration ?

> I also sent an e-mail to the authors of CPOC but got no response.

I am afraid that your email did not get through.   This may be dues to
recent problems we have had with our corporate x400/Internet gateway.   To
give you some alternatives the full list of email addresses via which you
could get me (but not my brother Keith although I can forward messages) is
as follows:
	d.j.walker@slh0101.wins.icl.co.uk
or      100141.2626@compuserve.com
or      itimpi@msn.com

I have (temporarily at least) got internet news access as well, so you can
also post messages here.

> I understood that I could also buy the SDK-document only version from
> Psion which should include some files (probably start-up-, library-
> and include-files).

This is true.   However the files would not be compatible with CPOC.  They
are only suitable for use with the TopSpeed compiler provided with the C
SDK.

> Can you please help me out ?

The libraries have been in development for some time now.  Unfortunately as
we do CPOC as a hobby and not a profession we find that there are a lot of
demands on our time, and so things have been taking a lot longer than
expected to get completed.

Having said that, we DO still intend to get the libraries plus their
associated header files released as soon as possible.  We have a complete
set of libraries at the ANSI level.  However the calls at this level map
down onto the equivalent of PLIB calls to handle the machine dependent
issues.  It is the completion of this PLIB library that has been holding up
things.  When something is ready we will post a message to that effect.  We
are also looking at changing the object format we use.  The current one is
based on the Minix/Linux one.  If we could switch to the DOS type format
used by TopSpeed this would help.  However this would need new versions of
the Assembler and Linker that could handle this object format.

There is also an issue that when hosted on the Psion, the CPOC compiler is
limited in the file size it can handle due to memory limitations.  Another
restriction for the same reason is no floating point support.   These
restrictions do not apply in a cross-compilation environment.  I would be
interested in what cross-compilation environments potential users would be
most interested in.  The underlying software (as opposed to the CPOC
front-end used when running on the Psion) is written in a portable manner
and should be useable under any operating system that can provide a command
line interface.  Possible candidates (listed in order of what I think would
be ease of use in producing them if we decide to do a particular port) are:
    Linux
    MSDOS
    QDOS or SMSQ/E (Sinclair QL)
    TOS  (Atari ST)
    Apple MAC
    Amiga

If anyone is interested in helping with such ports, or wants to try porting
to a different enviroment then they should contact me.  To help you would
need to have access to the target system, and that target system must have
an existing C compiler yopu can use.

Dave Walker.


Article: 217 of comp.sys.psion.programmer
Subject: Two-argument ArcTan in C
I was doing some graphics in 'C' the other day, and found myself wanting
wanting to set some lines at fixed angles to each other (for a simple
arrowhead to start with).

Considering PLIB's excellent range of utility functions, I was mildly
disappointed that they don't include a get-the-quadrant-right, two-
argument arctan.  So I went ahead and implemented quite a pleasing one,
using PLIB's floating point - I had to brush up my trigonometry first!

Anyway, here is the result, which I offer the Psion programming world as
a freebie.  It copes with either argument being zero, of course, but
doesn't pretend to cope with both being zero (which couldn't arise in my
application). It givea a correct-quadrant result in the range -pi to pi,
and has been exercised pretty thoroughly, though not formally tested.

I hope someone finds it useful.

========================================================================
/* ATAN2.C */

#include <p_std.h>
#include <p_math.h>

LOCAL_D DOUBLE Zero=0.0;
LOCAL_D DOUBLE Pi=PI;
LOCAL_D DOUBLE PiByTwo=PIB2;

GLDEF_C VOID ATan2(DOUBLE *pResult,DOUBLE *pXArg,DOUBLE *pYArg) {
  DOUBLE X,Y;
  UBYTE  Actions=0;

  p_fld(&X,pXArg);
  p_fld(&Y,pYArg);

  if (p_fcmp(&Y,&Zero)<0) {
    p_fneg(&Y);
    Actions^=1;
  }

  if (p_fcmp(&X,&Zero)<0) {
    p_fneg(&X);
    Actions^=3;
  }

  if (p_fcmp(&X,&Y)<0) {
    p_fdiv(&X,&Y);
    p_atan(pResult,&X);
    Actions^=7;
  }
  else {
    p_fdiv(&Y,&X);
    p_atan(pResult,&Y);
  }

  if (Actions & 4)
    p_fadd(pResult,&PiByTwo);
  if (Actions & 2)
    p_fsub(pResult,&Pi);
  if (Actions & 1)
    p_fneg(pResult);
}

