Why "Hints"?

When I first discovered computers, or rather the microprocessor, away back in the dim and distant past, with a ScMP four bit processor, I was in a world of my own - no-one knew anything about these machines, and programming [to me] was a black art. I graduated from the ScMP to the Commodore Pet 2001 quite quickly, simply because I spent my life savings on one, a much battered and used secondhand 8K unit with a built-in cassette drive and Psion size keyboard! I never regretted it. I taught myself BASIC, which seemed quite easy to pick up, but with only 8K or RAM, I did on a couple of occasions run out of memory, so I fell back on Assembler - or with the PET it was pure machine code POKE'd into place (until I got a ROM upgrade with a built-in monitor!) What's the point of all this? Well, I have written many programs on a purely amateur basis over my life, and have always thought how it would be nice to actually have done some training, but I've never had the money (or time). In attempting to use the web for help, my requests have more often than not fallen on deaf if not at times extremely sarcastic ears. I have often experienced the feeling that I'm in the wrong place, but been completely unable to find the right place. That's what I hope to achieve here ... a place where I an share out any useful information I have gleaned over the years. OK, I hope anyone who finds this site useful will also contribute something and I'll learn from it too, so if you do feel you have anything to contribute, please email it to me and I'll include it here. The site is aimed primarily at OPL running on EPOC machines, but anything you think worthwhile will be gladly accepted. Email contributions to me - john@wilsonjo.demon.co.uk


Set focus in DIALOG

Contributed by : john@wilsonjo.demon.co.uk

I had an application where I wanted to quite simply change the overwrite to an append in a dialog box, OPL seemed powerful enough to do it, but could I make it work? Then I discovered SYSTEM.OPX, and the SendKeyEventToApp function. Knowing it existed didn't make it any easier though - it still took me a week to make it work! First of all, give your app an ID - the reason for this will become apparent shortly:

APP Glom,&65489
ENDA

where &65489 is the ID. Rules are you can give your app any id as long as it's in the range range 0x00000001 - 0x0FFFFFFF which are open for all users for "experimentation!". If you want to distribute your app eventually, I recommend you apply by email to Symbian who are in my experience very quick in coming back with an id.
See http://www.symbiandevnet.com/techlibrary/technotes/uidinfo.html for more details.

I suggest you include your app id as a constant, and link in the libraries - I always use CONST.OPH anyway.

INCLUDE "Const.oph"
INCLUDE "System.oxh"
CONST AppId&=&65489

Now you know the App id, you can find the thread by:

PROC Glom:
LOCAL Thread&,Previous&,Temp1$(5),Temp2$(5),Temp3$(5)
Previous&=0
Thread&=GetThreadIdFromAppUid&:(AppId&,Previous&)

Let's set up some variables:

Temp1$="abcde"
Temp2$="fghij"
Temp3$="klmno"

now when you get to your DIALOG, you can do:

dINIT "New dialog"
dEDIT "Temp1$,"Box1"
dEDIT "Temp2$,"Box2"
dEDIT "Temp3$,"Box3"

Now the clever bit ... let's say we want to set focus on the second dialog box, position the cursor three characters in, and replace the character ...

SendKeyEventToApp&:(Thread&,0,KKeyDownArrow32%,16,0,0)
SendKeyEventToApp&:(Thread&,0,KKeyRightArrow32%,16,0,0)
SendKeyEventToApp&:(Thread&,0,KKeyLeftArrow32%,16,0,0)
SendKeyEventToApp&:(Thread&,0,KKeyLeftArrow32%,16,0,0)

why two "left arrows"? Think about it ... !

SendKeyEventToApp&:(Thread&,0,KKeyDel%,16,0,0)

Now do the DIALOG bit

DIALOG

and for clarity let's see what we get:

PRINT Temp1$,Temp2$,Temp3$
GET
ENDP

You can download the OPL source here to save you typing it all in! glom.opl


Back
Arrow Back to Psion stuff.