' This routine was ripped out of my Tele Title 2 program. It's called 'View
' Directory' because it simply Views the contents of your Disk and its
' first set of Drawers.
'
' Note: Keep the 'Key Speed' command in the routine as this slows down your
' key press long enough for the print routine to finish. If you don't keep
' the command in then you'll get the effect of pressing a key 3 times and
' printing the up-dated list only once for example.
'
' This program is Public Domain.
'
' Commands like YJ=YJ+1 are for Easy Amos users. If you change it to Add YJ,1
' then Easy Amos user will lose out. Amos users could also replace the Mouse
' Key function with the Mouse Click function.
'
' I will try and put a comment on each line, but don't expect too much because
' its a long time since I written this routine.
'
' Routine 22 - Set up the Screen and Mouse Zones
'
' Routine 23 - O$=DF0, Read the Directory and store the Drawer/File Names in
' string array M$(0 to 59).
'
' Routine 91 - Check each character in the name for a Space. Array YP holds
' the length of each name. YQ counts off the names. If YQ=60 or the next
' name is blank then this routine goes onto routine 90 (The Main Loop).
' Note: If a Space isn't found after the 30th character then the length of
' that name becomes 29 and does not exist.
'
' Keys: Q - Move the Bar
'
' A - Again
'
' P - Go back to the post menu. Pressing 'p' will stop this program
' because the post-menu isn't here, of course.
'
' M - Select a Drawer to View.
'
' Arrow Keys - Scroll the listing.
'
' Your other option is to use the Mouse Keys.
'
Close Workbench : Close Editor : Dim M$(59) : Dim YP(59) : YA=0 : YB=0 : YX=0 : YJ=0 : Key Speed 50,50
Screen Open 0,320,240,16,Lowres : Get Sprite Palette : Curs Off : Ink 13 : Flash Off : Cls 14 : Gosub 22 : End
22
Cls 12,8,216 To 311,224 : Print At(1,25);" " : Screen Open 3,320,240,16,Lowres : Screen 3 : Curs Off : Paper 0 : Pen 13 : Flash Off : Cls : Colour 1,$FF2 : YK=1 : YJ=0 : YN=1
Paste Bob 0,26,1 : Get Palette 0 : Reserve Zone 26 : For Z=32 To 191 Step 8 : Set Zone YN,8,Z To 167,Z+7 : YN=YN+1 : Next Z : Set Zone YN,185,134 To 205,158 : Set Zone 22,211,134 To 231,158 : Set Zone 23,185,164 To 205,188
Set Zone 24,211,164 To 231,188 : Set Zone 25,185,35 To 231,59 : Set Zone 26,185,65 To 231,89 : Dir$="DF0:" : O$=Dir$ : YT=0 : Print At(22,13);"Start";At(24,14);"End";At(4,0);"View Directory is Public Domain"
Print At(0,1);"(c) J.White, 1993. All right reserved." : Paper 10
23
L$=Dir First$(O$) : M$(0)=L$ : For Z=1 To 59 : M$(Z)=Dir Next$ : Next Z : For Z=4 To 23 : Print At(1,Z);Mid$(M$(YJ),YK,20) : YJ=YJ+1 : Next Z : YJ=0 : YQ=0 : YU=1 : YV=20 : YO=0
91
For Z=1 To 30 : If Mid$(M$(YQ),Z,1)=" " Then YP(YQ)=Z-2 : YQ=YQ+1 : If YQ<60 Then If M$(YQ)<>"" Then Goto 91
If Z=30 Then YP(YQ)=29 : YQ=YQ+1 : If YQ<60 Then If M$(YQ)<>"" Then Goto 91
If YQ<60 Then If M$(YQ)="" Then Goto 90
If YQ=60 Then Goto 90
Next Z
90
N$=Inkey$ : YM=Scancode : YS=Mouse Zone : Paper 0 : Pen 9 : Print At(0,26);Dir$ : Paper 10 : Pen 13 : If M$(19)="" Then YO=1
YI=4 : For Z=YJ To YJ+19 : Print At(1,YI);Mid$(M$(Z),YK,20) : YI=YI+1 : Next Z : Paper Rnd(7) : Print At(1,YU+3);" " : Paper 10
' Print the names if there are 20 lines to print them on. This uses YJ - so as
' long as YJ is 20 less than the end marker then the above routine will print
' the names.
If YQ=20 Then YO=1
' YO=1 to tell the up/down scroll gadgets not to scroll.
If YQ<20 Then YV=YQ
' If there are less than 20 names then YV equals YQ (YQ=Number of names) to
' tell the Bar gadget its end marker. If there are 20 names or more then
' the bar gadget scrolls its normal 20 spaces.
If YM=16 Then YU=YU+1 : If YU>YV Then YU=1
' Move Bar gadget forward - if it's more than the end marker then it goes back
' to the top of the box, YU=1.
If YM=78 or YS=24 and Mouse Key=1 Then YK=YK+1 : If YK>18 Then YK=18 : Rem move listing right.
If YM=79 or YS=23 and Mouse Key=1 Then YK=YK-1 : If YK<1 Then YK=1 : Rem move listing left.
If YM=77 and YO=0 or YS=22 and Mouse Key=1 and YO=0 Then YJ=YJ+1 : If YJ>YQ-20 Then YJ=YQ-20
' Move the listing down if YO=0.
' minus 20 places.
If YM=76 and YO=0 or YS=21 and Mouse Key=1 and YO=0 Then YJ=YJ-1 : If YJ<0 Then YJ=0
' Move the listing up if YO=0.
If YT=0 and YU=>1 and YU<21 and YM=55 Then If YP(YJ+YU-1)>0 Then P$=Mid$(M$(YJ+YU-1),2,YP(YJ+YU-1)) : O$=Dir$+P$ : If Exist(O$) Then Gosub 92 : Goto 23
' Press the M key to pick your Drawer to View - if the length of the name you
' picked (YP=length of name) is more than 0 then P$ will hold the name.
' O$ then equals Directory name+P$. If the name exists on the disk then the
' page is cleared by Routine 92 and YT is return with 1 to tell you that you
' are on part two of this routine (I.e. you're viewing a Drawer).
If YT=0 and YS=>1 and YS<21 and Mouse Key=1 Then If YP(YJ+YS-1)>0 Then P$=Mid$(M$(YJ+YS-1),2,YP(YJ+YS-1)) : O$=Dir$+P$ : If Exist(O$) Then Gosub 92 : Goto 23
' same as above, but this works out the calculations for the mouse and zone.
If YT=1 and YS=25 and Mouse Key=2 or YT=1 and YM=32 Then Dir$="DF0:" : O$=Dir$ : Paper 0 : For Z=0 To 30 : Print At(Z,26);" ";At(Z,28);" " : Next Z : Paper 10 : For Z=4 To 23 : Print At(1,Z);" " : Next Z : YT=0 : Goto 23
' This is the again function. Dir$ is reset to DF0: so that on return to part
' one of this routine you can read DF0: again. This means that on part two
' you could insert another disk, so that when you press 'again' you're
' reading a new Directory. 'A' is the key for again.
If YM=25 or YS=26 and Mouse Key=2 Then Reserve Zone : Return
' This returns to your Main Program. after the 'Reserve Zone' command you may
' need to put a 'Screen Close' command if you used another screen to access
' this routine.
If YT=0 and YQ<20 Then Paper 0 : Pen 12 : Print At(28,13);"No" : Paper 10 : Pen 13
If YT=0 and YQ=>20 Then Paper 0 : Pen 12 : Print At(27,13);YJ+20 : Paper 10 : Pen 13
If YT=0 and YQ=>0 and YQ<10 Then Paper 0 : Pen 12 : Print At(27,14);YQ;" " : Paper 10 : Pen 13
If YT=0 and YQ>9 and YQ<61 Then Paper 0 : Pen 12 : Print At(27,14);YQ : Paper 10 : Pen 13
' The above four lines just work out the Start/End positions to print on the
' screen.
Goto 90
92
For Z=4 To 23 : Print At(1,Z);" " : Next Z : Paper 0 : Pen 5 : Print At(0,28);P$ : Paper 10 : Pen 13 : YT=1 : Return
'
'
' When you enter a drawer to view, I've simply sent the program to read the
' directory again and then set YT to either 0 or 1 accordingly. However,
' you could change this so that instead of viewing the drawer you would
' load the file you clicked on instead. or you could view the directory and
' then put in a routine to load the file, perhaps setting YT to 2 for example.
'
'
' By the way, Routine 91 looks for a space in the first character of the name
' to see if its a Drawer or file. if it finds a space then YP=0 meaning its
' a file. When you click on a name the check is made for YP to equal more than
' 0. You could change this so that the routine looks at a file and loads it.