OPL

Pop Out and Print Instructions if required

Lets have a go at programming the PSION Organiser II - Hello World and Mastermind type game. Everything you need is outlined in the Instructions (Introduction to Programming)

PsionProg.pdf

These are the routines used for the Mastermind game example in the Introduction to Programming paper above. As explained on page 4 you can cut and paste these routines into Windows Notepad in order to load them into the ORG2 emulator.

MIND.OPL

mind:global a$(16),z$(1),c%,p%,i%,j%,x,b$(9),c$(9),g$(9),l%global ok,i$(9,1),j$(9,1),b%,w%
GAMEUDG:               :REM set top level icon
REM Initialise variablesa$="Master Mind Game"b$="ABCDEFGHI"x=int(rnd*10)randomize x

REM Jump back to here to restartstart::l%=1GameTOP:(2) :REM top line, icon and clock, sets the cursor on line 2
REM Get game options number of positions and letters maximum 9at 3,2 :print a$ :KSTAT 3do :at 3,3:print "No Positions 4-9" :p%=get :until p%>%3 and p%<=%9do :at 3,4:print "No Letters   4-9" :c%=get :until c%>%3 and c%<=%9i%=0 :c$="" :p%=p%-48 :c%=c%-48do :x=int(rnd*c%)+1 :c$=c$+mid$(b$,x,1) :i%=i%+1 :until i%=p%

KSTAT 1                         :REM Set the status of the keyboard to CAPs GameTOP:(2)print "From   =";left$(b$,c%)   :REM Possible available letters to try
REM Jump to here to retrytry::at 1,4 :print "Q=Quit O=Off (Pos=";p%;")"  REM p% tells the user no positionsat 1,3 :print "Try ";l% : at 8,3 :print "="; :input g$
REM Check for Q=Quitif loc(g$,"Q")>0GameTOP:(2) :print "Answer "; :print c$ :AT 1,4 :PRINT "Quit:"pause 20 :goto quit:: :endif
REM check for switch Offif loc(g$,"O") :off :goto try:: :endif
REM check that length guess is less that number of positionsif len(g$)<>p% :goto try:: :endif
REM Compare the guess with the answeri%=0do :i%=i%+1i$(i%)=mid$(c$,i%,1)j$(i%)=mid$(g$,i%,1)until i%=p%i%=0 :ok=0do :i%=i%+1ok=loc(left$(b$,c%),j$(i%))until ok=0 or i%=p%if ok=0 :goto try:: :endifl%=l%+1i%=0 :b%=0do :i%=i%+1if i$(i%)=j$(i%) :i$(i%)="K" :j$(i%)="L" :b%=b%+1 :endifuntil i%=p%i%=0 :w%=0do :i%=i%+1 :j%=0if i$(i%)<>"K"do :j%=j%+1if j$(j%)<>"L"if i$(i%)=j$(j%) :w%=w%+1 :i$(i%)="K" :j$(j%)="L" :endifendifuntil j%=p%endifuntil i%=p%at 1,2 :print "+";b%;" -";w% :at 8,2 :print "=";g$;"      "if b%=p% :goto done:: :endif
REM Jump back for another trygoto try::
REM Completed print good then check for Quitdone::at 1,4:print "Good   "

REM Jump to here to check for quittingQuit::at 8,4 :print " Go Again Y/N";:z$=get$if z$="y" or z$="Y" :goto start:: :endif

GAMEUDG.OPL

gameudg:UDG 0,4,4,4,4,0,4,0,31

GAMETOP.OPL

gametop:(x%)print chr$(15);chr$(22);chr$(23)at 1,1print chr$(0);rept$(chr$(2),14)clock(1)at 1,x%return

Getting this old DOS Emulator program ORG2.EXE (dated 1992) running in Windows is outlined in the Introduction to Programming above and the Developer Manual (here

For all your Organiser II supplies try eBay (here)

The link to the JAPE Emulator is (here)

Psion Organiser II users who would like to comment or are looking for further information can leave a message for Martin