home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Datafile PD-CD 3
/
PDCD_3.iso
/
pocketbk
/
developmen
/
frame
/
FRAMELIB.OPL
next >
Wrap
Text File
|
1993-01-17
|
14KB
|
302 lines
REM APPLICATION FRAMEWORK FOR PSION SERIES 3.
REM =========================================
REM By: John Hind. (Full documentation in FRAMELIB.TXT)
PROC fVer%: REM Returns the version number of the library
REM -----------------------------------------
RETURN 202
ENDP
PROC fLock: REM Used in application callbacks prior to DIALOG or ALERT use
REM ----------------------------------------------------------
BUSY OFF
LOCK ON
ENDP
PROC fUnlock: REM Used in application callbacks after DIALOG or ALERT use
REM -------------------------------------------------------
BUSY "busy....",1,2
LOCK OFF
ENDP
PROC fMenu%: REM Used in application callbacks in place of MENU routine
REM ------------------------------------------------------
LOCAL r%
BUSY OFF
LOCK ON
USR(ADDR(fPt1&(1)),ADDR(fPt3&(1)),0,0,0)
r%=MENU
USR(ADDR(fPt2&(1)),ADDR(fPt3&(1)),0,0,0)
BUSY "busy....",1,2
LOCK OFF
RETURN(r%)
ENDP
PROC fAutoOff: REM Used in application initialisations to enable auto-off
REM ------------------------------------------------------
CALL($138B,0,0,0,0,0)
ENDP
PROC fRun:(mesMsk%,hkMsk$,sysE%) REM Main Application Framework routine
REM ----------------------------------
GLOBAL fParm% REM Message Parameter
GLOBAL fParm$(128) REM Message Parameter
GLOBAL fKmod% REM Key modifier status at last key message
GLOBAL fPt1&(7) REM Machine code storage for menu routine fix
GLOBAL fPt2&(7) REM ""
GLOBAL fPt3&(8) REM ""
LOCAL t%,j&,t& REM These declarations must be in this order on their own.
REM t% REM Ticks (1/32ths of second)
REM j& REM Unknown (just a place-holder)
REM t& REM Time in seconds since the year dot
LOCAL fFopen% REM True if a file is currently open
LOCAL fCStat% REM Command/key status (-46=pending, 0=ready)
LOCAL fTStat% REM Timer status (-46=pending, 0=ready)
LOCAL fTCB% REM Handle for timer control block
LOCAL fS& REM Elapsed seconds at last timer message
LOCAL fMask% REM Message mask set (bits)
LOCAL fHkMsk$(30) REM Hotkey mask set (characters in string)
LOCAL fSys% REM System error handling enabled
LOCAL k%(2) REM Parameters from command/key request
LOCAL m% REM Current message
LOCAL mn% REM Next message
LOCAL a%(6) REM Used for parsing filenames
LOCAL init% REM True during processing of initialisation messages
LOCAL wait% REM True when waiting for events
LOCAL x&,x%,y& REM Working variables
BUSY "busy....",1,2 REM Not responsive to user input until initialised
fPt1&(1)=&8BF88BFC REM Machine code for menu fix from
fPt1&(2)=&8B00121E REM PSION application note MENPAT.TXT
fPt1&(3)=&778B205F
fPt1&(4)=&E42AAC0C
fPt1&(5)=&A5ABC88B
fPt1&(6)=&75C084AC
fPt1&(7)=&CBF8E2FB
fPt2&(1)=&00B4F08B
fPt2&(2)=&FC808BCD
fPt2&(3)=&AD0D7330
fPt2&(4)=&C932D08B
fPt2&(5)=&CDD88BAD
fPt2&(6)=&F8754ACF
fPt2&(7)=&CB
m%=0 REM Initialise no messages pending
fFopen%=0 REM File not open
fTStat%=-46 REM Timers not running, so fake pending
init%=-1 REM Initial masks still to be processed
wait%=0 REM Not waiting: events to be processed
fSys%=sysE% REM System error status
fParm$=CMD$(2) REM Initial Filename
IF CMD$(3)="C"
m%=101 REM Create file command
ELSEIF CMD$(3)="O"
m%=102 REM Open file command
ENDIF
IOA(-2,14,fCStat%,k%(1),#0) REM Queue asynchronous keyboard/command request
IF fSys% :ONERR sysErr :ENDIF REM Enable System Errors
DO REM START OF MAIN MESSAGE PROCESSING LOOP
REM -------------------------------------
Restart:: REM Re-entry for application errors
IF m%=0 REM NO FRAME MESSAGES PENDING
IF fTStat%=-46 AND fCStat%=-46 REM NO SYSTEM MESSAGES PENDING
IF wait% REM NOTHING TO DO AT PRESENT
BUSY OFF REM Responsive to user input
IOWAIT REM Suspend the application
BUSY "busy....",1,2 REM Not responsive to user input while processing
ELSE
m%=11 REM The "nothing better to do message"
wait%=-1 REM Suspend at next cycle if no system messages
ENDIF
ENDIF
IF fTStat%<>-46 REM TIMER MESSAGE PENDING
wait%=0 REM Message rx, not in wait mode
CALL($078b,0,10,0,$41c,addr(t%)) REM Fetch time information
x%=SECOND REM Current (clock) seconds
y&=10-((t% AND $1f)*10)/32 REM Calculate timer ticks to next whole second
x&=t&-fS& REM Elapsed seconds since last message generated
fS&=t& REM Store current seconds for next cycle
IF (fMask% AND $80) REM TIMER IS MINUTES TIMER
y&=y&+10*(60-x%) REM Scale number of ticks to next whole minute
x&=(x&+30)/60 REM Scale parameter value to elapsed minutes
m%=8 REM Minutes time-out message
ELSE REM TIMER IS SECONDS TIMER
m%=7 REM Seconds time-out message
ENDIF
IOA(fTCB%,1,fTStat%,y&,#0) REM Queue asynchronous timer message request
fParm%=x& REM Parameter is actual elapsed units
ELSEIF fCStat%<>-46 REM KEYBOARD OR SYSTEM MESSAGE PENDING
wait%=0 REM Message rx, not in wait mode
IF (k%(1) AND $400) REM MESSAGE IS SYSTEM MESSAGE
m%=k%(1)-$400
IF m%=4 REM MESSAGE IS FILE COMMAND
fParm$=GETCMD$ REM Get the command parameter
x%=ASC(fParm$) REM Get the type character
fParm$=MID$(fParm$,2,128) REM Get the filename
m%=0 REM Just in case future version adds more commands
IF x%=%X REM MESSAGE IS "EXIT"
m%=100
ELSEIF x%=%C REM MESSAGE IS "CREATE FILE"
m%=101
ELSEIF x%=%O REM MESSAGE IS "OPEN FILE"
m%=102
ENDIF
ENDIF
ELSE REM MUST BE A KEYSTROKE MESSAGE
fParm%=k%(1) REM The keycode
fKmod%=k%(2) AND $00FF REM The modifier key set
IF (fParm% AND $200) REM KEYSTROKE IS HOTKEY
fParm%=fParm%-$200 REM ASCII value
fParm$=CHR$(fparm%) REM Character
m%=4 REM Hotkey message
ELSEIF fParm%>31 AND fParm%<256 REM KEYSTROKE IS PRINTABLE
fParm$=CHR$(fparm%) REM Character
m%=5 REM Printable key message
ELSEIF fParm%=290 REM KEYSTROKE IS MENU KEY
m%=9 REM Menu key message
ELSEIF fParm%=291 REM KEYSTROKE IS HELP KEY
m%=10 REM Help key message
ELSE REM KEYSTROKE IS SPECIAL KEY
m%=6 REM Special key message
ENDIF
ENDIF
IOA(-2,14,fCStat%,k%(1),#0) REM Re-queue asynchronous key/command request
ENDIF