home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Datafile PD-CD 3
/
PDCD_3.iso
/
pocketbk
/
utilsr
/
scbank23
/
src
/
sys$sch.opl
< prev
next >
Wrap
Text File
|
1994-12-21
|
8KB
|
337 lines
rem on escape return to chosen menu item, not just first
proc mainhelp:
local hfile$(128)
hfile$="\opd\*.hlp"
dinit
dfile hfile$,"Help file:",16
if dialog
schelp%:(hfile$)
endif
endp
proc getinfo:(here%)
position here%
tpos%=here%
items%=D.n%
rem info:(tpos%,items%)
endp
proc info:(a%,b%)
alert(num$(a%,10),num$(b%,10))
endp
proc biggest%: rem find size of largest record
local i%,big%
position tpos%
gstyle 1
big%=gtwidth("Help:"+D.text$)
i%=0
do
position tpos%+i%
if (D.n%<>-1)
gstyle 1
else
gstyle 0
endif
big%=max(gtwidth(D.text$),big%)
i%=i%+1
until (i%>items%)
return (big%+32)
endp
proc sizehelp: rem determine size of main window
local info%(32),tamm$(10),w%,h%
w%=biggest%:
helpnx%=(scwidth%-w%)/2
helpmx%=w%
ginfo info%()
linehi%=info%(3)+2 rem how high is this font
lined%=info%(4)+2 rem font descent
linea%=info%(5)+1 rem font ascent
helpmy%=schight%-20
helplen%=(helpmy%-(linehi%+10))/linehi%
helplen%=min(items%,helplen%) rem no biggerthan we need
helpmy%=helplen%*linehi%+linehi%+10+6 rem make sue we don't have any left over
helpny%=(schight%-helpmy%)/2
gsetwin helpnx%,helpny%,helpmx%,helpmy%
dohelp:("Help")
endp
proc select:
local i%,tmpidx% rem s3z
position tpos%+filepos%+1
rem alert(num$(d.n%,10),d.text$)
if (D.n%<>-1)
level%=level%+1
tmpidx%=call($0081,0,(level%+1)*2) rem s3z
i%=0 rem s3z
while (i%<level%) rem s3z
pokew tmpidx%+i%*2,peekw(lvlidx%+i%*2) rem s3z
i%=i%+1 rem s3z
endwh rem s3z
pokew tmpidx%+level%*2,D.n% rem s3z
call($0381,0,lvlidx%) rem s3z
lvlidx%=tmpidx% rem s3z
rem s3a lvlidx%=realloc(lvlidx%,(level%+1)*2)
rem s3a pokew uadd(lvlidx%,level%*2),D.n%
getinfo:(D.n%)
sizehelp:
helpdisp:(0,1)
endif
endp
proc schelp%:(hfile$)
rem title position
global tpos%
global items%
global filepos%,scrpos%
rem help level
global level%,lvlidx%
rem remember where we are moving from
global oldpos%
global helplen%
rem font info
global linehi%,lined%,linea%
rem screensizes
global scwidth%,schight%
global search$(20),helpwin%
global filenm$(128)
global helpnx%,helpmx%,helpny%,helpmy%
local k%,mod%,h$(26),hu$(26),a$(6),a%(6),t$(1),file$(128),pname$(6)
local i%,tmpidx% rem s3z
if (scwidth%=0)
rem s3a scwidth%=480 : schight%=160
scwidth%=240 : schight%=80 rem s3z
endif
rem s3a helpwin%=gcreate(2,12,1,schight%-16,1,1)
helpwin%=gcreate(2,12,1,schight%-16,1) rem s3z
guse helpwin%
rem set up levels
level%=0
rem s3a lvlidx%=alloc(2)
lvlidx%=call($0081,0,2) rem s3z
pokew lvlidx%,1
trap open hfile$,D,n%,text$
if err
helperr:(err,hfile$)
return -1
endif
getinfo:(1)
sizehelp:
helpdisp:(0,1)
filepos%=0
scrpos%=1
while 1
position tpos%+filepos%+1
if (D.n%=-1)
gat 8,(scrpos%-1)*linehi%+linehi%+10+linea%
gprint ""
else
gat 8,(scrpos%-1)*linehi%+linehi%+10
gfill gtwidth("þ "+D.text$),linehi%,2
gat 7,(scrpos%-1)*linehi%+linehi%+10
ggmode 0
gborder $400,gtwidth("þ "+D.text$)+2,linehi%
endif
getevent a%()
if (D.n%=-1)
gat 8,(scrpos%-1)*linehi%+linehi%+10+linea%
gprintb "",gtwidth("")-1
else
gat 8,(scrpos%-1)*linehi%+linehi%+10
gfill gtwidth("þ "+D.text$),linehi%,2
gat 7,(scrpos%-1)*linehi%+linehi%+10
ggmode 1
gborder $400,gtwidth("þ "+D.text$)+2,linehi%
ggmode 0
endif
if ((a%(1) and $400)<>0) rem not keypress
else rem a keypress sc should optimise this
k%=a%(1)
mod%=a%(2) and $00ff
if (k%=13)
select:
endif
if (k%=27) rem escape
level%=level%-1
if ((level%=-1)or(mod%=4))
gclose helpwin%
close
rem s3a freealloc (lvlidx%)
call($0381,0,lvlidx%) rem s3z
return 0
endif
tmpidx%=call($0081,0,(level%+1)*2) rem s3z
i%=0 rem s3z
while (i%<=level%) rem s3z
pokew tmpidx%+i%*2,peekw(lvlidx%+i%*2) rem s3z
i%=i%+1 rem s3z
endwh rem s3z
call($0381,0,lvlidx%) rem s3z
lvlidx%=tmpidx% rem s3z
rem s3a lvlidx%=realloc(lvlidx%,(level%+1)*2)
rem s3a getinfo:(peekw(uadd(lvlidx%,level%*2)))
getinfo:(peekw(lvlidx%+level%*2)) rem s3z
sizehelp:
helpdisp:(0,1)
endif
if (k%=262) rem home
helpdisp:(0,1)
elseif (k%=263) rem end
helpdisp:(count,helplen%)
elseif ((k%=257)and(filepos%<items%-1)) rem down arrow
if (scrpos%=helplen%)
helpdisp:(filepos%+1,helplen%)
else
scrpos%=scrpos%+1
filepos%=filepos%+1
endif
elseif ((k%=261)and(filepos%<items%-1)) rem page down
if (scrpos%=helplen%)
helpdisp:(filepos%+(helplen%-1),helplen%)
else
filepos%=filepos%-scrpos%+helplen%
scrpos%=helplen%
endif
elseif ((k%=256)and(filepos%>0)) rem up arrow
if (scrpos%=1)
helpdisp:(filepos%-1,1)
else
scrpos%=scrpos%-1
filepos%=filepos%-1
endif
elseif ((k%=260)and(filepos%>0)) rem page up
if (scrpos%=1)
helpdisp:(filepos%-(helplen%-1),1)
else
filepos%=filepos%-scrpos%+1
scrpos%=1
endif
endif
endif
endwh
endp
proc helperr:(val%,file$)
alert ("Error "+err$(val%),file$)
busy off
endp
proc helpdisp:(from%,posit%) rem display current screen of entries
local i%,j%,k%,pos%,oldpos%,lposit%,ppos%,qpos%,opos%,rpos%,disp$(255)
rem alert(num$(from%,10),num$(posit%,10))
lposit%=posit%
rem remember where we were
oldpos%=filepos%
rem if position beyond start of file, should be unecessary
if (from%<0)
filepos%=0
rem if position beyond end of file, should be unecessary
elseif (from%>items%-1)
filepos%=items%-1
else
filepos%=from%
endif
rem if the gap between screenpos and end of screen is greater than
rem gap from file position and end of file then fill up resultant gap on screen
if (helplen%-lposit%)>(items%-filepos%-1)
rem if there is enough left over to move downto fill whole screen
if (helplen%<items%)
lposit%=helplen%-(items%-filepos%-1)
else
rem move down the spare stuff
lposit%=filepos%+1
endif
endif
rem simple check for small files
if (lposit%>items%)
lposit%=items%
endif
rem stop positioning beyond end of screen, should be unnecessary
if (lposit%>helplen%)
lposit%=helplen%
endif
rem i counts position on screen j counts how many printed
i%=0:j%=1
gupdate off
rem top of display is current - start
pos%=filepos%-lposit%+1
if (pos%<0)
pos%=0
lposit%=filepos%+1
endif
position pos%+1+tpos%
gat 14,linehi%+10
if ((scrpos%=1)and(lposit%=1)and(filepos%=oldpos%-1))
gscroll 0,linehi%,14,linehi%+10,helpmx%-29,helpmy%-(linehi%+10)-6-linehi%
j%=helplen%
elseif ((scrpos%=helplen%)and(lposit%=helplen%)and(filepos%=oldpos%+1))
gscroll 0,-linehi%,14,linehi%+linehi%+10,helpmx%-29,helpmy%-(linehi%+10)-6-linehi%
j%=helplen%
while (i%<helplen%-1)
i%=i%+1
endwh
else
gfill helpmx%-20,helpmy%-(linehi%+10)-6,1
endif
rem alert(num$(pos%,10))
gstyle 0
if (pos%<>0)
gat (gwidth-14),linehi%+10+linea% :gprint ""
else
gat (gwidth-14),linehi%+10+linea% :gprintb " ",6
endif
k%=i%
while ((j%<=helplen%)and(pos%+k%<items%))
rem alert(num$(pos%+k%+1,10))
position pos%+k%+1+tpos%
disp$=D.text$
if (D.n%=-1)
gstyle 0
ppos%=18
else
gstyle 1
disp$="þ "+disp$
ppos%=8
endif
gat ppos%,(i%*linehi%+linehi%+10+linea%) :gprint disp$
i%=i%+1
j%=j%+1
k%=k%+1
endwh
gstyle 0
if (((pos%+k%)<>items%)and(j%=helplen%+1))
gat (gwidth-14),helpmy%-lined% :gprint chr$($0d)
else
rem s3a gat (gwidth-14),helpmy%-lined%-3 :gprintb " ",6
gat (gwidth-14),helpmy%-lined% :gprintb " ",6 rem s3z
endif
if (D.n%=-1)
gstyle 0
else
gstyle 1
endif
if (lposit%>(i%))
scrpos%=i%
else
scrpos%=lposit%
endif
if scrpos%<1
scrpos%=1
endif
gupdate on
position filepos%+1+tpos%
endp
proc dohelp:(m$)
local tsize%,i%
gcls
rem s3a gxborder 1,1
gborder 1
tsize%=linehi%+2
gstyle 1
position tpos%
gat 16,tsize%-lined%+6 :gprintb m$+":"+D.text$,helpmx%-32,3
gat 5,tsize%+6 :glineby gwidth-10,0
endp