From: Roland Muts <mutsrola@ip-groep.nl>
Subject: Re: Using list boxes in OVAL
Date: Sun, 19 Jan 1997 17:04:11 +0100
Reply-To: mutsrola@kantoor.ip-groep.nl
To: Francis Shrago <fshrago@compuserve.com>

Francis Shrago wrote:
> 
> Does anyone have any suggestions as to how I can get items from a list box
> into a text box.

In VB4 you can read the ListIndex property. So if you got a listbox
lstBox, you can pick the current selection with

	selection = lstBox.ListIndex

selection = 0 is the first item,
selection = 1 for the next, and
selection = -1 if there is nothing selected.

You can always check the total count of items in the listbox with

	lstBox.ListCount

Note that the count starts with 1, so when you have four items in the
box, the ListCount will be four, and when the last one is selected the
index will be 3

Hope this is of some help,
Roland Muts
mutsrola@kantoor.ip-groep.nl
weasel@xs4all.nl

From: alanr@rd.bbc.co.uk (Alan Roberts)
Subject: Re: Please help with IOREAD
Date: 21 Jan 1997 17:18:33 GMT

Antony Sims (Antony.Sims@dial.pipex.com) wrote:

:       RETA%=IOOPEN(F1%,"NUMBERS",$0000)
:       RETB%=IOREAD(F1%,ADDRESS%,1)
: 
: Contents of "NUMBERS" written in WORD:
: 
: 27
: 34
: 32
: etc...

The problem is that you've opened the file as a binary file, but your
data is in ASCII. Open it as a text file (mode&=$20) and read strings
in, then convert to numbers with VAL.
-- 
******* Alan Roberts ******* BBC Research & Development Department *******
* My views, not necessarily Auntie's, but they might be, you never know. *
**************************************************************************

From: heuven@pi.net (Rene Heuven)
Subject: Q: Main supply ON/OFF detection (re-send 1)
Date: Fri, 24 Jan 1997 10:05:39 GMT

Hello,

I am using the Psion C SDK to develop software for the WorkAbout. I
would like a piece of code to scan a barcode, read a key, or detect a
change in power supply (main supply ON/OFF indicates whether the
WorkAbout is IN/OUT the holster and can communicate with a PC).
ReadBarOrKey() is supposed to do this:

int ReadBarOrKey()
{
    WORD  serStat;      // status word barcode scan
    WORD  pwrStat;      // status word for power monitor
    WS_EV event;        // window server event (evt. toetsaanslag)
    UWORD len;
    int   valid;
    int   power;
    
    // barcode buffer leegmaken.
    p_scpy(bcode, "");
    // max. len karakters vanaf barcode interface lezen.
    len   = sizeof(bcode) - 1;
    valid = FALSE;
    
    // queue request for toetsaanslag (window server event) en barcode scan.
    wGetEvent(&event);        
    p_ioc(pSerial, P_FREAD, &serStat, bcode, &len);    
    // p_ioc(...)
    do {
	// wacht op een event  
	p_iowait();      
	// power on/off ?
	if(pwrStat != E_FILE_PENDING)
	{
	    // cancel barcode scan
	    p_iow(pSerial, P_FCANCEL);         
	    p_waitstat(&serStat);
	    // cancel request voor toetsaanslag
	    wCancelGetEvent();        
	    if(power_connect)
		return W_KEY_CONNECT;
	    else
		return W_KEY_DISCONNECT;
	}
	// barcode scan ?
	if(serStat != E_FILE_PENDING)
	{
	    p_sleept(6);
	    // cancel request voor toetsaanslag
	    wCancelGetEvent();        
	    // correcte barcode scan ?
	    if(serStat == 0 && len > 1)
	    {
		// maak ZTS
		bcode[len - 1] = 0;
		return W_KEY_BARCODE;
	    }
	    // queue nieuwe requests voor toetsaanslag en barcode scan
	    wGetEvent(&event);        
	    len = sizeof(bcode) - 1;
	    p_ioc(pSerial, P_FREAD, &serStat, bcode, &len);

	}
	// window server event (evt. toetsaanslag) ?
	if(event.type != E_FILE_PENDING)
	{
	    // cancel barcode scan
	    p_iow(pSerial, P_FCANCEL);         
	    p_waitstat(&serStat);
	    // toetsaanslag ?
	    if(event.type == WM_KEY)
	    {
		modifiers = event.p.key.modifiers;
		return (int) event.p.key.keycode;
	    }
	    // queue nieuwe requests voor window server event +
barcode scan
	    wGetEvent(&event);
	    len = sizeof(bcode) - 1;
	    p_ioc(pSerial, P_FREAD, &serStat, bcode, &len);    
	}
    } while(!valid);
    return FALSE;
} /* ReadBarOrKey */

ReadBarOrKey() return the key when a key is typed, KEY_BARCODE when a
barcode is read, KEY_CONNECT, or KEY_DISCONNECT when the WorkAbout is
put into or taken out from the holster.

Just before the do { ... } while loop start we need to make a
asynchronous request to monitor the power. A wait handler has been
installed using:

//
// Power supply connected ?
//
int PowerOn()
{
    E_SUPPLY Value;
    
    p_supply(&Value);
    return(Value.mainsPresent == 1);
} /* PowerOn */

//
// Wait handler for power monitoring
//
int WaitHandler_Power()
{
    int power = PowerOn();    
    if((power_connect && !power) || (!power_connect && power))
    {
	power_connect = power;
	return(P_SIGNAL_ENABLE);
    }
    return(P_SIGNAL_UNUSED);
} /* WaitHandler_Power */

// 
// Install power monitor handler
// 
void InstallHandler()
{
    power_monitor = p_svecadd(WaitHandler_Power, NULL);
    p_sveccall(power_monitor, TRUE);
} /* InstallHandler */

I do not intend to use a timer as in the example on page 87, Vol. 2
PLIB reference.

Now my question is:

1) How do I make the service request for power monitoring ? Thus fill
in the dots in p_ioc( ... ) just before the do { ... } while loop.
2) Is it necessary to have a opened channel to the mains power supply
?
3) To make this solution work: is it necessary to write a LDD / PDD ?
4) Are the available services for a device determined by the LDD ?
Like P_FREAD, etc.
5) Where can I find information a these topics ?

Best regards,

Heuven Personal Consultancy & Automation
Contact: Rene Heuven
EMail: heuven@pi.net
Phone/Fax +31 572 301599

From: "Keld Laursen" <mse-data@inet.uni-c.dk>
Subject: Re: Main supply ON/OFF detection (re-send 1)
Date: 27 Jan 1997 07:25:40 GMT

Rene Heuven <heuven@pi.net> wrote in article <5ca1i1$hkf@halley.pi.net>...
> Hello,
>
> I am using the Psion C SDK to develop software for the WorkAbout. I
> would like a piece of code to scan a barcode, read a key, or detect a
> change in power supply (main supply ON/OFF indicates whether the
> WorkAbout is IN/OUT the holster and can communicate with a PC).
> ReadBarOrKey() is supposed to do this:
>
[LARGE snip]
> 1) How do I make the service request for power monitoring ? Thus fill
> in the dots in p_ioc( ... ) just before the do { ... } while loop.
> 2) Is it necessary to have a opened channel to the mains power supply
> ?
> 3) To make this solution work: is it necessary to write a LDD / PDD ?
> 4) Are the available services for a device determined by the LDD ?
> Like P_FREAD, etc.
> 5) Where can I find information a these topics ?
>
> Best regards,
>
> Heuven Personal Consultancy & Automation
> Contact: Rene Heuven
> EMail: heuven@pi.net
> Phone/Fax +31 572 301599

From the C SDK manual, general system services:

VOID p_supply(E_SUPPLY *pValue);

where

typedef struct
	{
	UWORD mainBatteryReading;
	UWORD lithiumBatteryReading;
	WORD mainsPresent;
	} E_SUPPLY;

Be warned, that this information is quite infrequently updated (The battery readings about once
every 5 minutes). I am not sure, whether the mainsPresent is better.

The approach I use, when checking for the holster or docking station is: 
Can I open the serial port (or whichever port I expect), then I am plugged 
in!. This check works much faster, and can be put in-line without a too big 
impact on performance.

You probably still want the battery check somewhere in the system, so you 
can issye your own battery warnings. To do this correctly, also use (once):

VOID p_wsupply(E_SUPPLY_WARNINGS *pValue);

where pValue is:

typedef struct
	{
	UWORD mainBatteryWarning;
	UWORD lithiumBatteryWarning;
	UWORD mainBatteryMax;
	UWORD lithiumBatterymax;
	} E_SUPPLY_WARNINGS;

p_wsupply() gives you the warning levels that the machine currently use.

Be adviced, that you only need to read the warning levels once, as they very 
rarely changes.
Hope that this helps in your program. (I didn't bother to read it in its 
entirety).

Best regards,
Keld Laursen
MSE Mobile Systems Engineering A/S
Tel: +45 8680 5399
Fax: +45 8680 5339
E-mail: mse-data@inet.uni-c.dk


From: pete@sorted.org (Pete Bentley)
Subject: Psion Infrared FAQ
Date: 27 Jan 1997 00:22:30 -0000

I've been meaning to finish tidying this up and post it for a couple
of weeks now, but had to many calls on my time.  Anyway, here it is,
somewhat expanded from the draft I posted before.  I'll HTML-ise
it and post a URL for that version Real Soon Now

Pete.
--------------------------------------------------------------------
1. What differences are there between the IR port on the Psion 3c and Siena?
2. Does the infrared port on the Psion conform to any standards?
3. What is IrDA?
4. What machines have IrDA adaptors?
5. Where can I get an IrDA adaptor for my desktop machine?
6. Where can I get an IrDA protocol stack for my desktop machine?
7. Where can I get an IrDA adaptor for my printer?
8. Can I transfer files between my Psion and some other machine with IrDA?
9. Can I run PsiWin over the IR link?
10. How do I program the IR interface on my Psion?
11. What if I want to build an IrDA adaptor myself?
12. Can I use my Psion as a remote control for  my TV, VCR etc etc?

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

1. What differences are there between the IR port on the Psion 3c and Siena?
   The Siena has no IrDA printer drivers (ie cannot print directly to
   IrDA-enableds printers). Ajai Khattri <ajai@nwt.com> adds:-
	AFAIK, all 3c's have the ability to print to an IR-capable printer. I
	don't know what plans Psion have for the Siena. An IR driver appeared
	on CompuServe for a few days and was later withdrawn for `various
	reasons'. Since the IR port is the same on the 3c and Siena I don't
	know what the problem is.

2. Does the infrared port on the Psion conform to any standards?
   Yes, it is compliant with the IrDA standards

3. What is IrDA?
   IrDA is the Infrared Data Association, an organisation formed by
   vendors of infrared communications harwdare to ensure their
   products can work together. IrDA publishes a set of standards for
   compliant implementations to adhere to which specify the physical
   layer (how the actual IR adaptor sends pulses of light) and
   protocol layers (how two machines establish an IR link between
   themselves to transfer data), but not the application layers (how
   those machines interpret the data which is transferred). The
   standards are available from the IrDA web site, http://www.irda.org/

4. What machines have IrDA adaptors?
   Many laptop and desktop PCs are shipped with adaptors which are
   compliant with the IrDA physical layer. To my knowledge none of
   these ship with any kind of IrDA protocol stack.

   Some PDAs ship with IrDA adaptors and protocol stacks (eg Sharp
   Zaurus, some HPs, Newton Messagepad 2000 (*not* earlier Newtons)
   and so on).  Some of the Sharps can also use ASK (Sharp's own
   IR protocol).

   Several models of printer ship with IrDA ports and software
   including HP DeskJet 340, HP LaserJet 5 and Citizen PN60i.

5. Where can I get an IrDA adaptor for my desktop machine?
   A lot of current PC motherboards ship "IR capable". That is, they
   have hardware on the motherboard, but need a transceiver unit
   attaching (XXX: source for these) and a BIOS setting changing.

   If your desktop machine has a spare RS232 port you can buy a
   serial to IrDA adaptor from a number of manufacturers including
   Adaptec (http://www.adaptec.com), Actisys (http://www.actisys.com/)
   and Extended Systems (http://www.extendsys.com/products/irpage.html) 
   and many more listed at http://www.irda.org/irda/resrclst.html.  I
   bought an Extended Systems Jet Eye PC adaptord from CompUSA for US$45
   and it seems to work OK with my Sun workstation.

   Note that merely having IrDA hardware is not enough to enable
   your machine to communicate using infra-red, you also need
   some kind of IrDA protocol stack software (see next question)

6. Where can I get an IrDA protocol stack for my desktop machine?
   Some serial port adaptors ship with IrDA stacks for DOS or
   Windows, or can be driven by the Windows 95 IrDA stack available
   from the Microsoft web site
   (http://www.microsoft.com/windows/software/irda.htm) 

   If you are running some other operating system on your desktop
   computer then you are currently out of luck as far as talking
   IrDA protocols goes. I'm planning on doing some free IrDA drivers
   for various Unixes, but it's a big project and I haven't started
   yet. (XXX: Does anyone know the situation for OS/2?)
    
7. Where can I get an IrDA adaptor for my printer?
   At least one manufacturer (Hewlett Packard) makes a parallel port
   IrDA adaptor, this plus directly into the parallel port on your
   printer and provides the hardware and software for any compatible
   IrDA machine to print via IR.  Compatible in this case means "uses
   the IrCom protocol for printing" which includes the Psion series.

8. Can I transfer files between my Psion and some other machine with IrDA?
   No.  As mentioned above the IrDA standards only specify the
   protocol layers, not the interpretation of the data --- the
   exception here being that there is a standard (IrCom) for emulating
   serial and parallel ports over an IrDA link.  This is how the Psion
   can print to IrDA compliant printers.

   For transferring files and cut'n'paste for Agenda entries etc Psion
   use their own, currently undocumented higher level protocols. There
   are currently no implementations of these for non-Psion platforms.

   Psion have said that they will provide some means of transferring
   data between PCs and Psions over IR, but it is not clear whether
   this will be software to run on the PC and provide support for the 
   Psion application-level protocols or whether it will be extra
   software for the Psion to run the IR file-transfer protocols
   supported by Windows.  Psion UK support have apparently said "don't
   hold your breath waiting" and support for non-PC platforms looks
   like it will be minimal or nonexistant.

9. Can I run PsiWin over the IR link?
   Not as things currently stand.  There is no way to make the link 
   software on the Psion use IrDA for communications.  

10. How do I program the IR interface on my Psion?
   The best thing to do is to get the new edition of the Psion SDK
   documentation (V2.15) which allegedly documents all the IR
   software interfaces available.  The problem is that this costs
   money and Psion are incredibly elusive about when it might be
   available ... the last information I received (in November '96) 
   was:-
       The forthcoming update (v2.15 I believe) to the SDK includes
       documentation of the APIs to the IrDA stack in the ROMs of Siena's and
       3c's. There is a device driver (AIR:) which offers access to the IrLMP
       level of the stack

   Meantime, a few people have worked out some odd and ends for using
   the port in "non-protocol" mode (ie not using the IrDA protocol
   layers). Basically opening the SIR:I device allows programs to
   access the IR port as if it were a simple serial port. By using
   the same technique on a PC (or any other computer which has an
   IrDA adpator that can be treated as a serial port) you can
   transmit a non-error corrected, half-duplex byte stream between
   the two computers.

   Jim Pollock <jpollock@ix.netcom.com> has a program (IRCOPY) which
   will copy files from a PC to a Psion in non-protocol mode. The
   following small OPL program is used to 'bootstrap' IRCOPY by 
   downloading the Psion part of it and illustrates programming the
   SIR:I device:-

PROC rcvcom:
LOCAL f$(255),h%,r%,d$(255),a%,s&(3)
  FONT 10,16                       rem select Swiss 11, mono
  f$="\OPL\temp.opl"               rem default file name
  dINIT "Receive PC file"          rem title of dialog
  dFILE f$,"",19                   rem use edit box,allow dir,query exist
  IF DIALOG                        rem display above defined dialog
    LOPEN "TTY:I"                  rem Open IR Port
    s&(1)=&30F0F                   rem set data=8,no parity, baud=9600
    s&(2)=&131104                  rem set handshake to NONE
    s&(3)=&4000400                 rem set terminating chars to Ctrl-Z & LF
    IOW(-1,7,s&(1),a%)             rem go setup IR port with above parms
    a%=ADDR(d$)                    rem address of start of string buffer
    IOOPEN(h%,f$,$0122)            rem open file, Replace/variable/Update
    d$="X"                         rem set length of d$ string to 1 char
    PRINT "Mode com2 96 n 8 1"
    PRINT "Copy /b src.opl COM2:"
    PRINT "Ready to Receive"
    DO
      r%=IOREAD(-1,a%+1,255)       rem read from IR port until term char
      IF r%>1                      rem don't write EOF character
	IOWRITE(h%,a%+1,r%-2)      rem Write receive string to file
      ENDIF                        rem -2 removes the CR LF characters
    UNTIL d$=CHR$(26)              rem Exit if EOF character received
    IOCLOSE(h%)                    rem Close file
    LCLOSE                         rem Close IR link
    PRINT                          rem New line
    PRINT "File received"          rem Print file message
    BEEP 5,300                     rem Sound Beep
    GET                            rem Keep screen until user press key
  ENDIF
ENDP

11. What if I want to build an IrDA adaptor myself?
    Jon Ashley <jon.ashley@iee.org> posted some details on adding an
    IrDA transceiver to a PC motherboard which has the rest of the
    hardware available (but I lost it).

    Jan Eijlers <Jan.Eijlers@IT-organisatie.NL> wrote:-
       In november in the dutch 'elektuur' a complete scheme is
       published, for an IrDA interface. You can order a complete
       packages at DIL electronics in Rotterdam
       (Netherlands). DIL@Euronet.NL The package costs 159 Dutch
       Gulders (ex P&P!!) Order number 960107.

    Ian Stirling <root@mauve.demon.co.uk> wrote:-
       http://www.temic.de/ Err, I forget the partnumber, it's
       somewhere on the floorin my pileof datasheets.


12. Can I use my Psion as a remote control for  my TV, VCR etc etc?
    My usual reaction to this question is "why would you want to do
    that? the Psion has a limited range etc etc", but people have
    quoted plausible applications recently, eg using the Psion as a
    'database' of all your other IR controllers, then using it to
    teach universal remote controls as needed etc.

    The simple answer is "no, not without a lot of work".  

    Somebody wrote the following, but I lost the attribution (sorry!)
       I have done some basic experiments with a 3c as far as transmitting IR
       remote control codes is concerned. With the aid of a storage scope and
       some basic circuitry I discovered that when you output a serial stream
       via the IR port the 3c sends a light pulse for a 0 bit and no pulse
       for a 1 bit.
       
       Given the above, you could simulate a limited amount of modulation
       frequencies by selecting a suitable baud rate. For example, 38400 bps
       is very close to the 40 Khz that most remotes use. By oppening the IR
       port via LOPEN "TTY:I" and sending a series of $00 bytes you
       efectively send a series of light pulses at 38400 pulses per second.
       
       In fact there's a missing pulse for each stop bit (high = no pulse).
       You could overcome this asymetry by using a different pattern, eg
       at 115200 bps with 7 data bits, no parity, 1 stop bit a transmitted
       value of $6d will look in binary like (0)11 011 01(1) where (0) is
       the start bit and (1) is the stop bit. Because you send a pulse (0)
       every 3rd bit the pulsed come out at a rate of 38400 per second and
       they are more regular especially when repeating the pattern a number
       of times.
       
       I have confirmed that this is recognized as a modulated beam by a
       standard off the shelf monolithic remote control decoder IC rated
       to work with a 40Khz carrier.
       
       The problem then becomes simply to send the right ammount of $00's
       or $6d's to simulate various lengths of modulated beam (logic "high"
       usually) and wait in between the right amount of time (not emitting
       any IR) to simulate a logic a "low". Unfortunately I only got as far
       a OPL programs which are far too slow for this kind of thing. I am
       confident however that an assembly program will produce satisfactory
       results.
       
       I have not experimented with receiving IR codes from remotes, ie
       learning a given remote's codes.

    Mat Walker <mat.walker@soton.sc.philips.com> wrote:-
       After discussions with various IR related engineers, here is what has
       been said.....
       
       Further info is available from the datasheets of the transmitter chips
       used in domestic R/C. Philips SAA3010 is a fairly old one, but should
       help. This describes RC-5 timings (including the "carrier" timing),
       but does not deal with actual code allocations. RC-5 is used by
       Philips and some others and has a completely different coding
       principle to the R/C used by many Japanese companies. Sony use one of
       their own (called SIRCS).
       
       The coding principle used by most (but not RC5) involves
       pulse-interval modulation. The inter-pulse interval may be long or
       short depending on the symbol encoded.
       
       The pulses themselves are "bursts" as described above, and to work,
       the frequency of the burst may have to be held to perhaps 5% or better
       in some cases. As many receivers have an agc system, it is more
       acceptable for the absolute value of the burst frequency to be off by
       5% than for it to flutter by that much.
       
       Most R/C systems encode a customer or system code of 5-8 or more bits,
       then a function code of about 8 bits . Sometimes the whole caboodle is
       encoded twice, with opposite polarity, for error protection (with a
       pulse-interval system, this means the transmission length is fixed).
       Usually, the complete code is repeated about 8-30 times/second, as
       long as the key is held down. You can see this happening if you point
       it at a camcorder....
       
       RC5 (and RC6) used by Philips encodes a one as an on-off transition,
       and a zero the other way about.(or vice versa)(I think). A stream of
       ones looks the same as a stream of zeroes, so it has (like most do) a
       start sequence which is fixed. It also has a toggle bit (as do some
       other systems). This inverts each time the button on the handset goes
       down .  Each code therefore has 2 values - a factor to remember if you
       design a learning system! The toggle bit makes sure that if you press
       and hold a key, the receiver knows this is what you are doing, and not
       repeatedly pressing the same key....
       
       What is easily missed is that the r/c protocols used for TVs and the
       like almost all (well, probably all) use a technique where the pulses
       which make up the code are in turn composed of bursts of small pulses
       at a clearly defined rate (See above).
       
       This rate is usually around 36kHz but can be up to several hundred
       kHz.  In this way, the receiver can be set up to behave like a trf
       radio set (one that provides all it's amplification at the signal
       frequency). In doing this, you can reject isolated pulses, steady
       light and trains of pulses at other frequencies. The range for a given
       power level is vastly more than you get without using this
       technique. IF you can simulate sequences of pulses at exaactly 36kHz,
       you might be able to talk RC5 to your TV or hifi. If not, forget
       it......

From: "J.G. Ramage" <jgr@ulysses.att.com>
Subject: Re: IR link: Statement from PSION
Date: Sat, 1 Feb 1997 18:03:00 GMT

Michael Banditt wrote:
> Does anybody of you know anything about this Psion protocol?

You don't even really need to know anything about the Psion protocol to
use the IR port.  The IR port is accessed the *exact* same way as the
serial port (i.e. TTY:A) except it should be opened as TTY:I (for
infared).  This supports all the TTY device driver calls which are
explained in the psionics devices file, so you don't need to buy
anything to use the IR port.

I was working on a remote program which learned your tv/stereo remote
commands by reading from the serial port and then sending them back out,
but I never really got into it.

I made a simple OPL program which printed out all information recieved
from the ir port.  It worked great with my remote controls, but i never
took it very far.  I can post the source if anyone would like it  ;)

Dan Ramage
  dramage@worldnet.att.net
  Damage@juno.com

From: "J.G. Ramage" <jgr@ulysses.att.com>
Subject: Re: IR link: Statement from PSION
Date: Tue, 4 Feb 1997 13:55:23 GMT

Michael Banditt wrote:
> 
> Well, it is not the control of the IR port via TTY:I that I am
> interested in. It is the way PSION uses the IR communication in their
> inbuilt IR protocol, which they use for data exchange between two
> PSIONs. That is IrLAP/LMP compatible, as they told me, but relies
> additionaly on a PSION specific protocol.

Ah, I see...

> Good idea. Please post it.

No problem.  Here it is:

PROC main:
	GLOBAL h%,s%(6),b%
	
	PRINT "Make sure InfraRed is enabled in the System Screen!"
	PRINT "(any key to continue)"
	GET
	PRINT "Press psion-escape to exit"
	
	IOOPEN(h%,"TTY:I",0)
	POKEB ADDR(s%(1)),18
	POKEB UADD(ADDR(s%(1)),1),18
	POKEB ADDR(s%(2)),3
	POKEB UADD(ADDR(s%(2)),1),0
	POKEB ADDR(s%(3)),2
	IOW(h%,7,s%(),#0)
	
	PRINT "Psion IRemote"
	
	WHILE 1
		IOREAD(h%,ADDR(b%),200)
		print HEX$(b%);
	ENDWH
	IOCLOSE(h%)
ENDP

Dan Ramage
  dramage@worldnet.att.net
  Damage@juno.com
  http://www.geocities.com/SiliconValley/9577/


From: steveg@dircon.co.uk (Stephen Godfrey)
Subject: Re: bitmap backed-up windows
Date: 27 Jan 1997 21:51:43 GMT

In article <32EC9902.46E5@cursci.co.uk>, andrew@cursci.co.uk (Andrew 
Witbrock) wrote:

> I have an application where I generate my image in 
> an off-screen bitmap and copy it to the window.  I 
> would prefer to write directly to the window's 
> backup bitmap and then cause a refresh as that 
> would reduce the number of block copies by one.

You can just write to the backup bitmap of a backed-up-window using
the following code:

wBeginRedraw(winId);
/*
  your redraw code here - nothing
  will appear on the screen
*/
wEndRedraw();
wInvalidateWin(widId);
wFlush();
p_ioyield();

It uses the fact that if you use wBeginRedraw...wEndRedraw with a
backed-up-window, all redrawing goes to the backup bitmap only.
At the p_ioyield() the window will be updated from your modified
backup bitmap. Alternatively, use something like wGetEvent() in
place of the p_ioyield() if suitable.

Steve
http://www.users.dircon.co.uk/~steveg/


From: ian.penson@virgin.net (Ian Penson)
Subject: Re: viewing pic files
Date: Tue, 28 Jan 1997 20:04:02 GMT
Reply-To: ian.penson@virgin.net

On Wed, 22 Jan 1997 13:02:33 GMT, hodges19@mail.idt.net wrote:

>I am trying to find a way to view a pic file in my Psion3a. The file
>converts from .bmp or .jpg to .pic using PsiWin, and copys into my 3a
>from my pc, but from there I'm stuck. Any ideas?
>tia,
>Tim Hodges
>
Either use a shareware picture viewer/edittor like Draw28 (or whatever
version it is now) from Chocolate.

Or you could try programming your own simple viewer using the
"gloadbit" command ie;

	id2% = gloadbit ("m:\pic\map2.pic")
	id%=gCREATE(0,0,479,159,1,1)

I have programmed a simple scrollable pic viewer that is only a few
lines long.
Cheers
Ian P

From: Jean-Francois Mezei <"[nospam]jfmezei"@videotron.ca>
Subject: Re: PIC Viewer
Date: Thu, 20 Feb 1997 19:09:31 -0500
Reply-To: "[nospam]jfmezei"@videotron.ca

Dieter Pointeau wrote:
> id% = gLoadBit("m:\pic\file.pic")
> gUse 1
> gCopy id%,X%,Y%,479,159,2
> 
> X% and Y% are new coordinates for starting when the picture is scrolled.

To find out what the size of the bitmap you loaded with gLoadBit is, use
the gWIDTH and gHEIGHT keywords. the id% returned by gLoadBit points to
a structure similar to a window.(a "drawable").

So, you can find out the right values on the size of your picture right
after the gLoadBit.

From: ianpenson@enterprise.net (Ian Penson)
Subject: Re: [Q] gLOADBIT problem
Date: Fri, 14 Feb 1997 03:18:36 GMT

Maurice Oude Tijdhof <maurice@spase.nl> wrote:

>Hi,
>There is a command gLOADBIT but the manual says nothing about
>the parameters needed. I also don't know how the gCOPY commands works.
>Is there somebody who can tell me or where to find it ?

The following loads a picture that is larger than the screen and uses
the arrow buttons to scroll about it.

Hope it is of some use

APP Tube
	TYPE $1000
	ICON "m:\tube.pic"
ENDA

PROC draw:
local id%,id2%,k%,key%,x%,y%,offsetx%,offsety%
local oldx%, oldy%
	busy "Tube. Colt Tech 96"
	offsetx% = 107
	offsety% = 113
	x% = 0
	y% = 0
	id2% = gloadbit ("m:\pic\map2.pic")
	id%=gCREATE(0,0,479,159,1,1)
	gborder 1
	gcopy id2%,x%,y%,479,159,2
	dummy::
	k% = get
	if k% = 256 AND y% > 0   rem UP
	y% = y% - offsety%
	elseif k% = 257 AND y% < 341   rem  DOWN
	y% = y% + offsety%
	elseif k% = 258 AND x% < 215    rem RIGHT
	x% = x% + offsetx%
	elseif k% = 259 AND x% > 0   rem LEFT
	x% = x% - offsetx%   
	elseif k% = 27     rem  EXIT
	stop
	elseif k% = 291     rem HELP
	oldx% = x%
	oldy% = y%
	y% = 453
	x% = 0
	gclose id%
	id%=gCREATE(0,0,479,159,1,1)
	gborder 1
	gcopy id2%,x%,y%,479,159,2
	get
	y% = oldy%
	x% = oldx%
	endif
	busy off
	gclose id%
	id%=gCREATE(0,0,479,159,1,1)
	gborder 1
	gcopy id2%,x%,y%,479,159,2

goto dummy::
ENDP


From: slitchfield@cix.compulink.co.uk ("Steve Litchfield")
Subject: Re: Java for Psion?
Date: Mon, 3 Feb 1997 07:19:29 GMT

> Anyone heard of Psion implementing Java in their products?  I know other
> companies like Nokia are planning handhelds/phones with Java embedded

Dan Ramage's web site has information on the Psion Java project. You can 
link to him from my pages.
Steve Litchfield

From: "J.G. Ramage" <jgr@ulysses.att.com>
Subject: Re: Java for Psion?

Jesse W. Asher wrote:
> 
> Anyone heard of Psion implementing Java in their products?  I know other
> companies like Nokia are planning handhelds/phones with Java embedded
> in it.

I don't know about psion, but a few of us are working on a psion-java
net project.  It's URL is:
http://www.geocities.com/SiliconValley/9577/
under the java link.

Dan Ramage  :)
  dramage@worldnet.att.net
  Damage@juno.com
  http://www.geocities.com/SiliconValley/9577/


From: steve@cholwell.demon.co.uk (Steve Duncan)
Subject: Re: Psion and C programming
Date: Thu, 06 Feb 1997 23:22:01 GMT

Andrew Lord <Andrew_Lord@tertio.co.uk> wrote:

>Three solutions at the moment.

>1. Buy the SDK.

>2. If you have access to Micro$oft C. Write the input/output in OPL and
>using PLINK to compile the "engine" part. Avoid standard functions or
>you'll have to write them yourself - or find the libc source.  (Is this
>still true or did I miss something?)

Yes, it's still true.  However, it's fairly easy to write your own
system calls in C/asm.  For example:

unsigned short getSystemTimeLowWord(void)
{
	unsigned short lowval;
	__asm
	{
		mov ah,02h;
		mov al,89h;
		int 89h;
		mov lowval,bx;
	}
	return lowval;    
}

I'm filling in some system stuff as and when I need it in my own
applications, i.e. slowly.  Of course, if anybody wanted to help out
by writing some system calls themselves...

BTW PLINK also works with some other PC C compilers, e.g. Borland
Regards,
Steve Duncan

From: steve@cholwell.demon.co.uk (Steve Duncan)
Subject: Re: Wanted: Info on PLink
Date: Sat, 08 Feb 1997 17:28:36 GMT

mark@inkland.demon.co.uk (Mark Incley) wrote:

>Hi all!
>A few weeks ago I saw PLINK mentioned somewhere and I know it converts
>PC .OBJ files to a Psion format, but does it have a WEB page? Now I
>want to try it, I can't find it!

>Cheers,
>       Mark.

You can pick up PLINK from ftp://ftp.it.dtu.dk/pub/psion/1996/856
I really ought to get my web page up !
Regards,
Steve Duncan


From: "J.G. Ramage" <jgr@ulysses.att.com>
Subject: Re: A brainteaser - Inverting a S3a bitmap in OPL
Date: Tue, 4 Feb 1997 22:09:03 GMT

Dave Rushall wrote:
> 
> Here's an interesting problem for anyone with a masochistic trate. I'm 
> looking for a way to photographically invert a grey-level S3a bitmap 
> in OPL.
> 
> That is: Black->White; Grey->Grey; White->Black.
> 
> Of course one can gINVERT the black plane of the bitmap, but that results in
> anything that was not black in the original image masking out any grey objects
> underneath, and anything that was black but with grey underneath being grey
> instead of white. This could be fixed by subtracting the grey plane from the
> new black plane, thus making holes in it for the grey to show through, and the
> original black plane from the grey plane, making sure that any black is now
> definitely white. Making sense so far?
> 
> This would appear to be a job for gCOPY, but there lies the problem. We need
> to be able to apply the black plane to the grey plane and vice versa. Applying
> the black plane to the grey plane is possible via an intermediate single plane
> bitmap (gCOPY to to the bitmap and then back with gGREY 1 for the
> destination), but I cannot come up with an elegant solution to moving
> information from the grey plane to the black. The only thing I've come up with
> is to save the bitmap to a file, and load back the grey plane as a single
> plane bitmap for the gCOPY - Yuk!
> 
> Interesting problem, eh? Of course, I could be missing the obvious solution...

That is essentially what you have to do.  I had a similar problem when
creating Damage Graphics (a sprite animation driver w/ transparent
colors, 10 frames per second resolution, and a ton of other features. 
You can get it from the page linked to at the bottom of this post.).  I
wanted the grey pixels in the sprite to show over the black background
pixels.  I wrote it in oo c, so I didn't get this kind of a problem.  A
different one arose for me.  In c, you can *not* have a bitmap with
black and grey planes, so you have to have one bitmap for black and one
for grey and copy them to their respective screen planes.  All I had to
do was to invert/copy the grey sprite bitmap to the black background
bitmap to get the grey instead of the black visible.  The problem that
you come up with in c is to *not* be able to copy the grey out of a
window.  It is simply impossible.  I had to create a method for the
sprite window superclass that would be called by the sprite to create an
appropriate background image.  This is almost the opposite of your
problem, but shows some of the stupid little things overlooked when
psion made the window server and the opl interpreter.

Both languages seem to have the share of annoyances...

Dan Ramage  :)
  dramage@worldnet.att.net
  Damage@juno.com
  http://www.geocities.com/SiliconValley/9577/


From: ali-manson@psion.com (Alasdair Manson)
Subject: Re: Diamond key in menu
Date: Tue, 11 Feb 1997 19:59:12 GMT

On 11 Feb 1997 18:24:55 GMT, "Marc Bruggeman" <marcb@club.innet.be>
wrote:

>Can somebody explain me how to activate the diamond key in a menu. Using
>the basic OPL programming manual I cannot find how to put the diamond in a
>menu. 
>Also I would like to know how or where I can find info on enabling the
>diamond key to switch between modes of operation in my programs.

The diamond character has the value 4 in the character set so just use
CHR$(4) in the appropriate place in your mCARD

With regards to your second question, the Diamond key returns a value
the same as any other key. The value is 292 and you can deal check for
this along with other keypresses and events. You move the Diamond in
the Diamond list using DIAMPOS.

Bye
Ali

From: alanc@donor2.demon.co.uk (Alan Clifford)
Subject: Setting Time/Date via OPL
Date: 15 Feb 97 02:04:23 GMT

Hello Phil!

Replying to a message of Phil Spencer to All:

 PS> Does anybody know how to (or if there's any pre-written code on the
 PS> archives to) set the System time and date from OPL?  I'm looking to
 PS> ideally do it via a dialog like in the Time application.  I had a
 PS> look at Sunsite and NWT last night, but found nothing.

proc timdemo%:
 local newyr&, newsec&, temp&, newtime&, clocks$(50), rc%
 rem display a clock
 clocks$ = " %6:%T:%S%7, %1/%2/%3 "
 gclock on, 10,0, clocks$, $9A
 
 newyr& = days(day,month,year)
 do
  newsec& = (hour * int(3600) + minute * 60 + second)
 until newsec& = (hour * int(3600) + minute * 60 + second)
 rem newsec& = newsec& - datetosecs(year, month, day, hour, minute, second)
 dinit "set time"
 ddate newyr&, "this year",days(1,1,year),days(31,12,year)
 dtime newsec&, "today", 1, 0, datetosecs(1970, 1,1,23,59,59)
 rc% = dialog

 if (rc% = 0) :stop :endif
 
 gclock off
 rem set time
 newtime& = (newyr& - days(1,1,1970)) * 86400 + newsec&
 call($0389, 0, peekw(uadd(addr(newtime&), 2)), peekw(addr(newtime&)))
 gclock on, 10,0, clocks$, $9A
 rem wait 5 secs
 pause 100
endp

Alan
(note:  please remove the $, or maybe it's still c, from the address before
replying by email)

From: "J.G. Ramage" <jgr@ulysses.att.com>
Subject: Re: Non backed-up HWIF applications
Date: Tue, 11 Feb 1997 22:07:49 GMT

W Joosten wrote:
> I like programming with HWIF but want the redrawing speed of
> a non backed up window.
> 
> Is there a way to make the main window non-backuped ? I've
> tried the wSetWindow after uCommanInit() but this property can't
> be changed afterwards.

What you can do is:
  a)  Don't call uCommonInit() and emulate its functionality via the
individual calls
-or-
  b)  Free the main console window created by uCommonInit() and create a
new one in its place.  This one should have its handle in the same place
as the one created by uCommonInit(), but you can declare it with any
flags you want.

> I also looked for a wCreateWindow in the HWIF source code but
> it's not there :(

No, that kind of information is in the Window Server Reference Manual,
or if you don't have that, its in the Window Server Psionics File.  The
Window Server Psionics File that is on the Psionics Files web page
(Clive's site) doesn't have as much info as the one I'm writing.  I gave
the current version of mine to Clive, but he just made some changes
which made it more legible but he also took out a lot of content before
uploading it to his page.  My uncompleted version is at:
http://www.geocities.com/SiliconValley/9577/
under the Programming Resources page.

Dan Ramage  :)
  dramage@worldnet.att.net
  Damage@juno.com
  http://www.geocities.com/SiliconValley/9577/

From: "Fred (I.C.) Vanner" <fred@vanner.demon.co.uk>
Subject: Re: Comparing variables
Date: Wed, 19 Feb 1997 21:28:56 +0000

In article <EpdyoDAIViCzEwmF@vanner.demon.co.uk>, "Fred (I.C.) Vanner"
<fred@vanner.demon.co.uk> writes
>In article <01bc16bc$0d864fa0$452449c2@toad>, John Colles
><jcolles@btinternet.com> writes
>>Can anyone help?
>>I am trying to test for a number being an integer by using
>>IF INT(x)=x
>>
...
>>John Colles
>
>If your requirement is to determine if y& is a perfect square, the
>following will ALWAYS work:
...
>rem: Analysis shows that r is never more than +/- 0.02 away
>rem: from exact sqr(y&), for any long integer y&; for
>rem: small y& it is much closer.

correction- +/-0.02 is for 64 bit ints; 32 bit ints are never more
than 10^-11 out.
...
>
>To test if any float is an exact representation of an integer (the
>question you originally asked) is not easy without poking around inside
>the IEEE representation, because the largest exact integer represented
>is much bigger than a long integer. However:
>
>local s$(20)
>s$=gen$(x, 20)
>rem: 20 > 16(digits in max int) + 1(dec. pt.) + 1(sign) + 1(traling 0)
>rem: if all the characters after the decimal point are 0, 
>rem: x is an exact integer; if not, it isn't.
>
Sorry, this DOES NOT WORK (Moral: test it THOROUGHLY before posting!)
(I actually tested with fix$(x, 20, 40), but that doesn't always work
either!) This outputs integers exactly, but sometimes rounds the last
digit of non-integers, making them look like integers.

Fortunately, all is not lost. I have (carefully!) checked that:

 if x=intf(x)

reliably tests a float for containing an exact integer (up to the full
53 bits plus sign that can be exactly represented).

To recap on the original problem:

a) all long int values are accurately and exactly represented by the
float type.

b) both sqr(x&) and sqr(x) (where x& (x) is (the (exact) float of) a
perfect square) do NOT always return the exact float representation of
the corresponding integer square root, although it is always very close.
This can be corrected by:
 r=sqr(x)
 ir=intf(x+0.02)
 if ir*ir=x
  r=ir
 endif

c) to test in general if a float is an exact representation of an
integer, use:
  if x=intf(x)
 
I hope this makes things even clearer!
-- 
Fred (I.C.) Vanner                    video meliora proboque... (Ovid)
17, Portway, Wells, Somerset BA5 2BA, UK           (44) (0)1749-674629

