home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Datafile PD-CD 3
/
PDCD_3.iso
/
pocketbk
/
developmen
/
oplman
/
OPLEXAM.WRD
(
.txt
)
< prev
next >
Wrap
Psion Series 3 Word Document
|
1995-04-11
|
46KB
|
1,821 lines
PSIONWPDATAFILE
ROM::GENERAL.WDR
BTBody text
HAHeading A
HBHeading B
BLBulleted list
NNNormal
UUUnderline
BBBold
IIItalic
EESuperscript
SSSubscript
1: Creating and running programs
2: Variables and constants
3: Loops and branches
4: Calling procedures
5: Data file handling
PROC openfile:
IF NOT EXIST("example")
CREATE "example",A,int%,lng&,fp,str$
ELSE
OPEN "example",A,int%,lng&,fp,str$
ENDIF
PRINT "Current values:"
show:
PRINT "Assigning values"
A.int%=1
A.lng&=&2**20 REM the 1st & avoids integer overflow
A.fp=SIN(PI/6)
PRINT "Give a value for the string:"
INPUT A.str$
PRINT "New values:"
show:
PROC show:
PRINT "integer=";A.int%
PRINT "long=";A.lng&
PRINT "float=";A.fp
PRINT "string=";A.str$
GET
PROC count:
LOCAL reply%
OPEN "example",A,f%,f&,f,f$
CLS
AT 20,1 :PRINT "Record count=";COUNT
AT 9,5 :PRINT "(A)dd a record"
AT 9,7 :PRINT "(Q)uit"
reply%=GET
IF reply%=%q OR reply%=%Q
BREAK
ELSEIF reply%=%A OR reply%=%a
add:
ELSE
BEEP 16,250
ENDIF
UNTIL 0
PROC add:
CLS
PRINT "Enter integer field:";
INPUT A.f%
PRINT "Enter long integer field:";
INPUT A.f&
PRINT "Enter numeric field:";
INPUT A.f
PRINT "Enter string field:";
INPUT A.f$
APPEND
FIRST
WHILE FIND("*BROWN*")
PRINT a.name$, a.phone$
NEXT
GET
ENDWH
PROC copyrec:
OPEN "example",A,f%,f&,f,f$
TRAP DELETE "temp"
REM If file doesn't exist, ignore error
CREATE "temp",B,f%,f&,f,f$
PRINT "Copying EXAMPLE to TEMP"
USE A REM the EXAMPLE file
IF a.f%>30 and a.f<3.1415
b.f%=a.f%
b.f&=a.f&
b.f=a.f
b.f$="Selective copy"
USE B REM the TEMP file
APPEND
USE A
ENDIF
NEXT
UNTIL EOF REM until End Of File
CLOSE REM closes A; B becomes current
CLOSE REM closes B
p%=PEEKW($1c)+$1e
POKEW p%,PEEKW(p%) or 1
p%=PEEKW($1c)+$1e
POKEW p%,PEEKW(p%) and $fffe
6: Graphics
PROC exgrey:
DEFAULTWIN 1 REM enable grey
gAT 0,40 :gGREY 1 :gLINEBY 480,0 REM grey only
gAT 0,41 :gLINEBY 480,0
gAT 0,80 :gGREY 0 :gLINEBY 480,0 REM black only
gAT 0,81 :gLINEBY 480,0
gAT 0,120 :gGREY 2 :gLINEBY 480,0 REM both planes
gAT 0,121 :gLINEBY 480,0
GET
gGREY 0 REM black only
gCLS REM clear it
GET
PROC face:
gFILL 120,120,0 REM set the entire face
gMOVE 10,20 :gFILL 30,20,1 REM left eye
gMOVE 70,0 :gFILL 30,20,1 REM right eye
gMOVE -30,30 :gFILL 20,30,1 REM nose
gMOVE -20,40 :gFILL 60,20,1 REM mouth
GET
PROC wink:
gMOVE 10,20 REM move to left eye
gFILL 30,14,2 REM invert most of the eye
PAUSE 10
gFILL 30,14,2 REM invert it back again
GET
PROC brow:
gGMODE 1 REM gLINEBY will now clear pixels
gMOVE 10,8 :gLINEBY 100,0
gMOVE 0,4 :gLINEBY -100,0
gGMODE 0
GET
PROC fonts:
showfont:(4,15,"Mono 8x8")
showfont:(5,25,"Roman 8")
showfont:(6,38,"Roman 11")
showfont:(7,53,"Roman 13")
showfont:(8,71,"Roman 16")
showfont:(9,81,"Swiss 8")
showfont:(10,94,"Swiss 11")
showfont:(11,109,"Swiss 13")
showfont:(12,127,"Swiss 16")
showfont:(13,135,"Mono 6x6")
GET
PROC showfont:(font%,y%,str$)
gFONT font%
gAT 20,y% :gPRINT font%
gAT 50,y% :gPRINT str$
gAT 150,y% :gPRINT "!!!"
PROC style:
gAT 20,50 :gFONT 11
gSTYLE 12 :gPRINT "Attention!"
GET
PROC tmode:
DEFAULTWIN 1 REM enable grey
gFONT 11 :gSTYLE 0
gAT 160,0 :gFILL 160,80,0 REM Black box
gAT 220,0 :gFILL 40,80,1 REM White box
gAT 180,20 :gTMODE 0 :gPRINT "ABCDEFGHIJK"
gAT 180,35 :gTMODE 1 :gPRINT "ABCDEFGHIJK"
gAT 180,50 :gTMODE 2 :gPRINT "ABCDEFGHIJK"
gAT 180,65 :gTMODE 3 :gPRINT "ABCDEFGHIJK"
gGREY 1
gAT 160,80 :gFILL 160,80,0 REM Grey box
gAT 220,80 :gFILL 40,80,1 REM White box
gAT 180,100 :gTMODE 0 :gPRINT "ABCDEFGHIJK"
gAT 180,115 :gTMODE 1 :gPRINT "ABCDEFGHIJK"
gAT 180,130 :gTMODE 2 :gPRINT "ABCDEFGHIJK"
gAT 180,145 :gTMODE 3 :gPRINT "ABCDEFGHIJK"
GET
PROC windows:
LOCAL id%
id%=gCREATE(60,40,240,30,1,1)
gBORDER 0 :gAT 20,20 :gLINEBY 0,0
gPRINT " 20,20 (new)"
GET
gUSE 1 :gAT 20,20 :gLINEBY 0,0
gPRINT " 20,20 (default)"
GET
gUSE id%
gGREY 1 REM draw grey
gPRINT " Back"
gGREY 0
gPRINT " (with grey)"
GET
PROC gsetw1:
LOCAL a$(100),w%,h%,g$(1),factor%,info%(10)
LOCAL margx%,margy%,chrw%,chrh%,defw%,defh%
SCREENINFO info%() REM get text window information
margx%=info%(1) :margy%=info%(2)
chrw%=info%(7) :chrh%=info%(8)
defw%=23*chrw%+2*margx% REM new default window width
defh%=chrh%+2*margy% REM ... and height
w%=gWIDTH :h%=gHEIGHT
gSETWIN w%/4+margx%,h%/4+margy%,defw%,defh%
SCREEN 23,1,1,1 REM text window
PRINT "Text win:"; :GET
gCREATE(w%*.1,h%*.1,w%*.8,h%*.8,1) REM new window
gPATT -1,gWIDTH,gHEIGHT,0 REM shade it
gAT 2,h%*.7 :gTMODE 4
gPRINT "Graphics window 2"
gORDER 1,0 REM back to default+text window
EDIT a$ REM you can see this edit
gORDER 1,9 REM to background
CLS
a$=""
PRINT "Hidden:";
GIPRINT "Edit in hidden edit box"
EDIT a$ REM YOU CAN'T SEE THIS EDIT
GIPRINT ""
gORDER 1,0 :GET REM now here it is
gUSE 1 REM graphics go to default window
DO REM move default/text window around
CLS
PRINT "U,D,L,R,Quit";
g$=UPPER$(GET$)
IF kmod=2 REM Shift key moves quickly
factor%=10
ELSE
factor%=1
ENDIF
IF g$="U"
gSETWIN gORIGINX,gORIGINY-factor%
ELSEIF g$="D"
gSETWIN gORIGINX,gORIGINY+factor%
ELSEIF g$="L"
gSETWIN gORIGINX-factor%,gORIGINY
ELSEIF g$="R"
gSETWIN gORIGINX+factor%,gORIGINY
ENDIF
UNTIL g$="Q" OR g$=CHR$(27)
7: Friendlier interaction
PROC kget%:
LOCAL k%,h$(9),a$(5)
h$="nosciefgd" REM our hot-keys
WHILE 1
k%=GET
IF k%=$122 REM Menu key?
mINIT
mCARD "File","New",%n,"Open",%o,"Save",%s
mCARD "Edit","Copy",%c,"Insert",-%i,"Eval",%e
mCARD "Search","First",%f,"Next",%g,"Previous",%d
k%=MENU
IF k% AND (LOC(h$,CHR$(k%))<>0) REM MENU CHECK
a$="proc"+CHR$(k%)
@(a$): REM procn:, proco:, ...
ENDIF REM END OF MENU CHECK
ELSEIF k% AND $200 REM hot-key pressed directly?
k%=k%-$200 REM remove Psion key code
IF LOC(h$,CHR$(k%)) REM DIRECT HOT-KEY CHECK
a$="proc"+CHR$(k%)
@(a$): REM procn:, proco:, ...
ENDIF REM END OF DIRECT HOT-KEY CHECK
ELSE REM some other key
RETURN k%
ENDIF
ENDWH
PROC procn:
PROC proco:
IF k%<=%Z REM if upper case hot-key
IF LOC(hu$,CHR$(k%))
a$="procu"+CHR$(k%)
@(a$) :REM procua:, procuc:, ...
ENDIF
ELSE REM else lower case hot-key
IF LOC(hl$,CHR$(k%))
a$="procl"+CHR$(k%)
@(a$) :REM procla:, procld:, ...
ENDIF
ENDIF
PROC dcheck:
LOCAL c%
c%=2 REM default to "Internal"
dINIT "Disk Check"
dCHOICE c%,"Disk:","A,Internal,B"
IF DIALOG REM returns 0 if cancelled
... REM disk-check code
ENDIF
PROC delivery:
LOCAL d&,t&,num&,wt
d&=DAYS(DAY,MONTH,YEAR)
t&=secs&:
UNTIL t&=secs&:
num&=1 :wt=10
dINIT "Delivery"
dLONG num&,"Boxes",1,1000
dFLOAT wt,"Weight (kg)",0,10000
dDATE d&,"Date",d&,DAYS(31,12,1999)
dTIME t&,"Time",0,0,DATETOSECS(1970,1,1,23,59,59)
IF DIALOG REM returns 0 if cancelled
... REM rest of code
ENDIF
PROC secs&:
RETURN HOUR*INT(3600)+MINUTE*60
PROC daytodat:(days&)
LOCAL dyscent&(2),dateent%(4)
LOCAL flags%,ax%,bx%,cx%,dx%,si%,di%
dyscent&(1)=days&
si%=ADDR(dyscent&()) :di%=ADDR(dateent%())
ax%=$0600 REM TimDaySecondsToDate fn.
flags%=OS($89,ADDR(ax%)) REM TimManager int.
IF flags% AND 1
RAISE (ax% OR $ff00)
ELSE
year%=PEEKB(di%)+1900 :month%=PEEKB(UADD(di%,1))+1
day%=PEEKB(UADD(di%,2))+1 :yrdy%=PEEKW(UADD(di%,6))+1
ENDIF
PROC selact:
dINIT "Select action"
dTEXT "","Add",$402
dTEXT "","Copy",$402
dTEXT "","Review",$402
dTEXT "","Delete",$402
RETURN DIALOG
8: OPL and Solid State Disks
PROC delx300:
LOCAL a$(3),c%
a$="MAB" :c%=1 REM default to "Internal"
dINIT "D