home *** CD-ROM | disk | FTP | other *** search
/ 17 Bit Software 4: Phase Four / 17Bit_Phase_Four.iso / files / 3023.dms / 3023.adf / Source-Code / View-Directory / View-Directory.amosSourceCode < prev   
Encoding:
AMOS Source Code  |  1994-02-22  |  7.1 KB  |  119 lines

  1. '
  2. ' This routine was ripped out of my Tele Title 2 program. It's called 'View      
  3. ' Directory' because it simply Views the contents of your Disk and its   
  4. ' first set of Drawers.    
  5. '
  6. ' Note: Keep the 'Key Speed' command in the routine as this slows down your      
  7. ' key press long enough for the print routine to finish. If you don't keep 
  8. ' the command in then you'll get the effect of pressing a key 3 times and
  9. ' printing the up-dated list only once for example.
  10. '
  11. ' This program is Public Domain. 
  12. '
  13. ' Commands like YJ=YJ+1 are for Easy Amos users. If you change it to Add YJ,1
  14. ' then Easy Amos user will lose out. Amos users could also replace the Mouse 
  15. ' Key function with the Mouse Click function.
  16. '
  17. ' I will try and put a comment on each line, but don't expect too much because     
  18. ' its a long time since I written this routine.
  19. '
  20. ' Routine 22 - Set up the Screen and Mouse Zones   
  21. '
  22. ' Routine 23 - O$=DF0, Read the Directory and store the Drawer/File Names in 
  23. ' string array M$(0 to 59).  
  24. '
  25. ' Routine 91 - Check each character in the name for a Space. Array YP holds
  26. ' the length of each name. YQ counts off the names. If YQ=60 or the next 
  27. ' name is blank then this routine goes onto routine 90 (The Main Loop).  
  28. ' Note: If a Space isn't found after the 30th character then the length of   
  29. ' that name becomes 29 and does not exist.   
  30. '
  31. ' Keys: Q - Move the Bar 
  32. '
  33. '       A - Again
  34. '
  35. '       P - Go back to the post menu. Pressing 'p' will stop this program
  36. '           because the post-menu isn't here, of course. 
  37. '
  38. '       M - Select a Drawer to View.   
  39. '
  40. '       Arrow Keys - Scroll the listing. 
  41. '
  42. '       Your other option is to use the Mouse Keys.  
  43. '
  44. Close Workbench : Close Editor : Dim M$(59) : Dim YP(59) : YA=0 : YB=0 : YX=0 : YJ=0 : Key Speed 50,50
  45. Screen Open 0,320,240,16,Lowres : Get Sprite Palette : Curs Off : Ink 13 : Flash Off : Cls 14 : Gosub 22 : End 
  46. 22
  47. 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
  48. 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
  49. 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"
  50. Print At(0,1);"(c) J.White, 1993. All right reserved." : Paper 10
  51. 23
  52. 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
  53. 91
  54. 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
  55. If Z=30 Then YP(YQ)=29 : YQ=YQ+1 : If YQ<60 Then If M$(YQ)<>"" Then Goto 91
  56. If YQ<60 Then If M$(YQ)="" Then Goto 90
  57. If YQ=60 Then Goto 90
  58. Next Z
  59. 90
  60. 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
  61. 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
  62. ' Print the names if there are 20 lines to print them on. This uses YJ - so as     
  63. ' long as YJ is 20 less than the end marker then the above routine will print  
  64. ' the names. 
  65. If YQ=20 Then YO=1
  66. ' YO=1 to tell the up/down scroll gadgets not to scroll.     
  67. If YQ<20 Then YV=YQ
  68. ' If there are less than 20 names then YV equals YQ (YQ=Number of names) to
  69. ' tell the Bar gadget its end marker. If there are 20 names or more then 
  70. ' the bar gadget scrolls its normal 20 spaces.   
  71. If YM=16 Then YU=YU+1 : If YU>YV Then YU=1
  72. ' Move Bar gadget forward - if it's more than the end marker then it goes back   
  73. ' to the top of the box, YU=1. 
  74. If YM=78 or YS=24 and Mouse Key=1 Then YK=YK+1 : If YK>18 Then YK=18 : Rem move listing right.
  75. If YM=79 or YS=23 and Mouse Key=1 Then YK=YK-1 : If YK<1 Then YK=1 : Rem move listing left. 
  76. 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
  77. ' Move the listing down if YO=0. 
  78. ' minus 20 places.       
  79. 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
  80. ' Move the listing up if YO=0. 
  81. 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
  82. ' Press the M key to pick your Drawer to View - if the length of the name you  
  83. ' picked (YP=length of name) is more than 0 then P$ will hold the name.  
  84. ' O$ then equals Directory name+P$. If the name exists on the disk then the  
  85. ' page is cleared by Routine 92 and YT is return with 1 to tell you that you 
  86. ' are on part two of this routine (I.e. you're viewing a Drawer).  
  87. 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
  88. ' same as above, but this works out the calculations for the mouse and zone. 
  89. 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
  90. ' This is the again function. Dir$ is reset to DF0: so that on return to part
  91. ' one of this routine you can read DF0: again. This means that on part two 
  92. ' you could insert another disk, so that when you press 'again' you're     
  93. ' reading a new Directory. 'A' is the key for again. 
  94. If YM=25 or YS=26 and Mouse Key=2 Then Reserve Zone : Return 
  95. ' This returns to your Main Program. after the 'Reserve Zone' command you may      
  96. ' need to put a 'Screen Close' command if you used another screen to access  
  97. ' this routine.
  98. If YT=0 and YQ<20 Then Paper 0 : Pen 12 : Print At(28,13);"No" : Paper 10 : Pen 13
  99. If YT=0 and YQ=>20 Then Paper 0 : Pen 12 : Print At(27,13);YJ+20 : Paper 10 : Pen 13
  100. If YT=0 and YQ=>0 and YQ<10 Then Paper 0 : Pen 12 : Print At(27,14);YQ;" " : Paper 10 : Pen 13
  101. If YT=0 and YQ>9 and YQ<61 Then Paper 0 : Pen 12 : Print At(27,14);YQ : Paper 10 : Pen 13
  102. ' The above four lines just work out the Start/End positions to print on the 
  103. ' screen.  
  104. Goto 90
  105. 92
  106. 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 
  107. '
  108. '
  109. ' When you enter a drawer to view, I've simply sent the program to read the  
  110. ' directory again and then set YT to either 0 or 1 accordingly. However,   
  111. ' you could change this so that instead of viewing the drawer you would  
  112. ' load the file you clicked on instead. or you could view the directory and  
  113. ' then put in a routine to load the file, perhaps setting YT to 2 for example. 
  114. '  
  115. '
  116. ' By the way, Routine 91 looks for a space in the first character of the name
  117. ' to see if its a Drawer or file. if it finds a space then YP=0 meaning its  
  118. ' a file. When you click on a name the check is made for YP to equal more than 
  119. ' 0. You could change this so that the routine looks at a file and loads it.