home *** CD-ROM | disk | FTP | other *** search
/ Loadstar 236 / 236.d81 / t.cookbook < prev    next >
Encoding:
Text File  |  2004-01-01  |  17.4 KB  |  853 lines

  1. u
  2.           DotBASIC Cookbook
  3.            by Dave Moorman
  4.  
  5.  
  6.     Here is a "blow by blow" look at
  7. the COOKBOOK program. Many of these
  8. routines will help you make really
  9. snazzy programs with DotBASIC.
  10.  
  11.     We open with the standard DotBASIC
  12. template:
  13.  
  14.  10 dv=peek(186):ifdv<8thendv=8
  15.  11 print"<clr><white>"
  16.  90 sys4608,224
  17.  
  18.     This SYS initiates the Event
  19. Driver. 224 is the location of the
  20. .MED file in memory (pages 224 - 242).
  21. You can put your .MED files anywhere
  22. you have 18 free pages. Just change
  23. this parameter to find it.
  24.  
  25.  
  26.  100 .do:.ee:.wb:.un e%:.of
  27.  102 end
  28.  
  29.     The MAIN EVENT DRIVER LOOP. .DO
  30. begins a Do-Loop. .EE Enables Event
  31. Driving (which is turned off during
  32. Event Handling). .WB Waits for BACK
  33. ARROW. When the <BACK ARROW> is
  34. pressed, E% becomes -1.
  35.  
  36.     .UN is UNtil E% is not 0. Until
  37. that happens, the program loops back
  38. to the .DO command. .OF is OFf,
  39. turning off all of DotBASIC's exotic
  40. features.
  41.  
  42.  
  43.  200 .ru,210,215
  44.  202 e%=i%*2
  45.  204 .er
  46.  206 return
  47.  
  48.  
  49.     The EXIT Event Region is assigned
  50. line number 200 for Event Handling.
  51. The .RU command puts an "Are You Sure"
  52. dialog box on the screen. The colors
  53. (.RU,unhi,hi) have 208 added to them
  54. in order to reverse/unreverse the
  55. Yes/No options.
  56.  
  57.     If NO is selected, I%=0. If YES,
  58. I%=-1. We put I%*2 into E%. When this
  59. routine is over and the program
  60. returns to the Main Loop, E% not
  61. equaling zero will end the loop and
  62. stop the program. We put -2 in E% so
  63. that we can sort between an Exit and a
  64. <BACK ARROW> Stop.
  65.  
  66.  
  67. DRAG AND DROP
  68. -------------
  69.  
  70.     Windows seems to love this
  71. feature, where you can point and click
  72. on an object then, holding down the
  73. mouse button, drag that object
  74. anywhere on the screen.
  75.  
  76.     Well, we can do it to!
  77.  
  78.  1000 rem"  Drag 'n' Drop
  79.  1002 .bx,0,39,0,24,32,1
  80.  1004 poke1024+s,42
  81.  
  82.     This clears the screen with the
  83. .BX command, and pokes an asterisk
  84. into screen memory. S will hold the
  85. position of the asterisk.
  86.  
  87.  
  88.  1006 :.do
  89.  1008 :ift<tithen:.bx,0,39,24,24,32,1
  90.  
  91.     The Outer Do-Loop. Line 1008 is
  92. rather extraneous, clearing a line on
  93. the screen after a certain time has
  94. elapsed.
  95.  
  96.  1010 :  :.do
  97.  1012 :  :.ma
  98.  1014 :  :.kp,"_"
  99.  1016 :  :.un i% or l2% or r2%
  100.  
  101.     The Inner Do-Loop. .MA is Mouse
  102. Ask, which brings mouse information
  103. into BASIC variables. .KP watches for
  104. a KeyPress -- in this case, for a BACK
  105. ARROW.
  106.  
  107.     This loop will continue until one
  108. of these variables become Not Zero:
  109.  
  110.         I%  - The result of .KP
  111.  
  112.         L2% - A new click on the
  113.               left mouse button
  114.  
  115.         R2% - A new click on the
  116.               right mouse button
  117.  
  118.  
  119.  1018 :if i% or r2% then 1024
  120.  1020 :c = cx%+40*cy%
  121.  1022 :if c=s then gosub 1030
  122.  1024 :.un i% or r2%
  123.  1026 .er
  124.  1028 return
  125.  
  126.     When we fall through the .UN, we
  127. have to sort out which variable did
  128. it. If I% or r2% are Not Zero, we jump
  129. to line 1024.
  130.  
  131.     Otherwise, we handle a new left
  132. click. C holds the location of the
  133. mouse pointer. (CX% and CY% are
  134. generated by .MA -- the Character Cell
  135. X and Y coordinates of the pointer.)
  136. If C=S, the mouse was clicked over the
  137. asterisk, so we Gosub to the next
  138. step, at line 1030
  139.  
  140.     The .UN watches for i% or r2% to
  141. be Not Zero. If not, we return to the
  142. Outer Do.
  143.  
  144.     However, if there is a new right
  145. click or a <BACK ARROW> key press, the
  146. routine is over. .ER restores the
  147. Event Screen. RETURN returns to the
  148. Main Loop.
  149.  
  150.     If you are into Double-clicking,
  151. here is how it can be done:
  152.  
  153.  1030 for x= 1 to 20
  154.  1032 .ma
  155.  1034 if l2% then x = 99
  156.  1036 next
  157.  1038 if x < 100 then 1044
  158.  1040 .p@,1,24,"Double Click"
  159.  1042 t = ti + 60
  160.  
  161.     Just wait a bit, checking .MA for
  162. a new left click. In this code, we put
  163. the words, "Double Click" on the
  164. screen, then set the timer to hold it
  165. for at least a second.
  166.  
  167.     But now for the DRAG code:
  168.  
  169.  1044 :.do
  170.  1046 :.ma
  171.  1048 :c = cx% + 40 * cy%
  172.  1050 :poke1024+s,32
  173.  1052 :poke1024+c,42
  174.  1054 :s=c
  175.  1056 :.wh l1%
  176.  1058 return
  177.  
  178.     This Do-Loop uses .WH L1% --
  179. because we are going to do this loop
  180. WHile L1% is Not Zero. As long as you
  181. hold down the left button, L1% will be
  182. 1.
  183.  
  184.     We update C, turn off the
  185. asterisk where it was (S), then turn
  186. it back on at the pointer's location
  187. (C). We make S=C and we are done.
  188.  
  189.     It you don't like to see the
  190. asterisk flicker a bit, add this line:
  191.  
  192.  1049 if c=s then 1056
  193.  
  194.  
  195. GET DIRECTORY
  196. -------------
  197.  
  198.     File Requestors are the sign of
  199. caring coders. Since the GREAT DECREE
  200. of Fender Tucker in 1992, LOADSTAR
  201. programs that accessed the disk drive
  202. give the user a list of files to
  203. choose from.
  204.  
  205.     Getting the Directory into BASIC
  206. used to be a real chore. But thanks to
  207. the Toolboxes of Jeff Jones and now
  208. Mr.Mouse, we have no excuse for
  209. leaving the user to:
  210.  
  211.         INPUT FILENAME?
  212.  
  213.     Here is a better way:
  214.  
  215.  2000 rem"     Get Directory I
  216.  2002 .ss,208
  217.  2004 .p@,1,24,"eClick rQUITr for
  218.       More"
  219. *2005 .qs
  220. *2006 .b$,"$:*",dv,40960,235
  221. *2007 .qr
  222. *2008 .ml,5,255,0,20,2,1,7,7,40960,
  223.       t$,b$
  224. *2009 if w$="" then 2100
  225.  2010 .bx,0,30,24,24,32,1
  226.  2012 .p@,1,24,"File: "+f$
  227.  2014 .do:.ma:.un l2% or peek(198)
  228.  2016 poke198,0
  229.  2018 .er
  230.  2020 return
  231.  
  232.     The essential Requestor requires
  233. just five lines. In 2006, we bload the
  234. directory to memory under ROM. Note
  235. the .QS command just before the .B$.
  236. Anytime you do disk access, it is more
  237. than a good idea to turn off the IRQ
  238. routines used by DotBASIC. .QS is irQ
  239. Suspend. In line 2007, we use .QR --
  240. irQ Restore.
  241.  
  242.     Line 2008 puts the data into a
  243. scrolling menu. Line 2008 checks to
  244. see if a file was selected.
  245.  
  246.     The .B$ command asks for the
  247. directory ("$:*"), and you can include
  248. any search characters.
  249.  
  250.     On drive DV
  251.     To location 40960 (page 160)
  252.     With 235 directory items.
  253.  
  254.     Limiting the number of directory
  255. entries keeps the file from over-
  256. running available memory. A 16K chunk
  257. of memory can hold 255 directory
  258. lines.
  259.  
  260.     Here is the .ML (Menu scrolL)
  261. command:
  262.  
  263.  .ML,X1,X2,Y1,Y2,BX,IC,U,H,L,T$,B$
  264.  
  265.     X1 - left column
  266.     X2 - right column
  267.     Y1 - top row
  268.     Y2 - bottom row
  269.  
  270.  of the menu box. If X2 is 255, the
  271. box is automatically the width of a
  272. file requestor. Then the colors are
  273. set
  274.  
  275.     BX - Box
  276.     IC - Icon ("Home", etc)
  277.     U  - Unhighlighted items
  278.     H  - Hightlighted item
  279.  
  280.     The L parameter is the Location of
  281. the data in memory. We will look at
  282. this later. In a simple case, L = the
  283. location where you bloaded the file.
  284.  
  285.     T$ and B$ are texts that will
  286. appear at the top and bottom of the
  287. menu. When a .B$ is performed, T$
  288. holds the Disk Name and B$ holds the
  289. Blocks Free information.
  290.  
  291.     When the user selects, the whole
  292. line chosen is returned in W$. The
  293. filename itself is returned in F$
  294.  
  295.  
  296. GET DIRECTORY II
  297. ----------------
  298.  
  299.     Showing the whole directory line
  300. may not be the style you want. Here is
  301. how to display only the filenames.
  302.  
  303.  2100 rem"     Get Directory II
  304.  2102 .sr,208
  305.  2104 .p@,1,24,"eClick rQUITr for
  306.       More"
  307. *2106 .qs:.b$,"$:*",dv,40960,235:.qr
  308. *2108 .rk,40960
  309. *2110 .$l,40960
  310. *2112 for x = 1 to n%
  311. *2114 .ri,x
  312. *2116 .$p,f$
  313. *2118 next
  314. *2120 .rk,40960
  315. *2122 .ml,10,28,5,15,3,1,7,7,0,"",""
  316. *2124 if w$="" then 2200
  317.  2126 f$=w$
  318.  2128 goto2010
  319.  
  320.     Again, the essential lines are
  321. marked with asterisks. In this case,
  322. we RACK the data in line 2108. This
  323. turns the data into a virtual string
  324. array!
  325.  
  326.     Then, in 2110, we set a location
  327. where will Put strings into memory.
  328. In this case, we will put our strings
  329. right on top of the original data,
  330. since the data we are creating will
  331. not be longer than the orginal.
  332.  
  333.     With a FOR-NEXT loop, we .RI (Rack
  334. Index) each line of the data, then .$P
  335. (String Put) the Filename into the
  336. data block we are creating. The .$P
  337. command copies the string to memory,
  338. beginning with the location set with
  339. .$L. Each string follows the previous
  340. one.
  341.  
  342.     When finished building our data
  343. block, we .RK (RacK) it again. We now
  344. have the Filenames ready for a
  345. scrolling menu.
  346.  
  347.     NOTE: In this .ML command, we set
  348. the LOCATION to 0. We have already
  349. Racked the data, so we do not have to
  350. do it again for the scrolling menu.
  351.  
  352.  
  353.  2200 rem"     Sort!
  354. *2202 .az,1
  355. *2204 .ml,10,28,5,15,3,1,7,7,0,"",""
  356.  2206 ifw$=""then2300
  357.  2208 f$=w$
  358.  2210 goto2010
  359.  
  360.     We can automatically SORT the
  361. filenames with the .AZ command. The
  362. parameter is the position of the first
  363. character to be used in the sort.
  364.  
  365.  
  366. SEARCHING FOR STRINGS
  367. ---------------------
  368.  
  369.     One weakness of C=DOS is that the
  370. directory cannot be limited to a
  371. single extension (such as .MED in this
  372. case. DotBASIC gives you the tools to
  373. search for any string within the
  374. filenames, and build a custom file
  375. requestor.
  376.  
  377.  2300 rem" Directory of .med files
  378.  2302 .sr,208
  379. *2304 .qs:.b$,"$:*",dv,40960,235:.qr
  380. *2306 .rk,40960
  381. *2308 .$l,40960
  382. *2310 y=0
  383. *2312 forx=1ton%
  384. *2314 .ri,x
  385. *2316 .$i,".med",f$
  386. *2318 if i% then:.$p,w$:y=1
  387. *2320 next
  388. *2322 ify=0then2350
  389. *2324 .rk,40960
  390. *2326 .ml,5,255,0,20,1,2,3,4,0,t$,b$
  391.  2328 .er
  392.  2330 return
  393.  
  394.  
  395.     The lines with asterisks do the
  396. work. Note that this is very similar
  397. to collecting just the filenames
  398. above. The difference is line 2316.
  399.  
  400.     The .$I is the INSTRING command,
  401. searching for the first given
  402. string in the second string variable.
  403. The position of the search string
  404. characters in the target string is
  405. returned in I% (0 if not found). So,
  406. if the search string was found, we
  407. know it in line 2318, and .$P,W$ into
  408. our new data block. We use Y to
  409. indicate if any searches were
  410. successful.
  411.  
  412.     Then we Rack and put the results
  413. in a scrolling menu.
  414.  
  415.     What you do with the requested
  416. files is your problem!
  417.  
  418.  
  419. DISABLED REGIONS
  420. ----------------
  421.  
  422.     The Event Driver for DotBASIC is
  423. pretty basic. It always changes the
  424. colors of the Event Regions when
  425. rolled-over. You can change colors at
  426. run-time, but what about situations
  427. where you want to do things completely
  428. differently.
  429.  
  430.     Here is some code that does the
  431. same thing as the Event Driver, but
  432. with the Driver turned off. For some
  433. programs, you may want to abandon
  434. Event Driving all together. DotBASIC
  435. certainly has enough commands to do
  436. the work right out in front where you
  437. can control it.
  438.  
  439.  3000 rem"    Disable Regions
  440.  3002 og=4
  441.  3004 for x = 2 to 4
  442.  3006 .ra,x,255,4
  443.  3008 next
  444. *3010 .do
  445. *3012 .ma
  446. *3014 .kp,"e1234567_"
  447. *3016 if i%=9then i%=-1:goto3032
  448. *3018 if i% then l2%=1:og=i%:goto3032
  449.  3020 if rg%>1 and rg%<5 then3032
  450.  3022 if og>1andog<5then3028
  451. *3024 if rg%=og then3032
  452. *3026 .ra,og,255,1
  453. *3028 .ra,rg%,255,7
  454. *3030 og=rg%
  455. *3032 .un l2% or i%=-1
  456. *3034 ifi%=-1thene%=i%:.er:return
  457.  3036 if og=1then3060
  458.  3038 if og<5 then3010
  459. *3040 .ss,232
  460. *3042 onog-4gosub4000,5200,6000,7000
  461.  3044 ifog=5thenreturn
  462. *3046 goto3010
  463.  3060 .ss,232:gosub200
  464.  3070 ifi%thenreturn
  465.  3072 goto3010
  466.  
  467.     The essential code is again
  468. marked. We use the Do-Loop, .MA, and
  469. .KP to get input. OG is the Old
  470. reGion, used to unhighlight regions
  471. when the pointer moves off.
  472.  
  473.     The rest of the code turns off
  474. regions 2, 3, and 4. Might be useful!
  475.  
  476.  4000 rem"   Re-enable
  477.  4002 forx=2to4
  478.  4006 .ra,x,255,1
  479.  4008 next
  480.  4010 return
  481.  
  482.     This code just undoes what Disable
  483. did -- mostly by just RETURNing to the
  484. Event Driver Main Loop.
  485.  
  486.  
  487. DISABLE EVENTS
  488. --------------
  489.  
  490.     Here is another way to manage your
  491. own Event driving.
  492.  
  493.  5000 rem"    Disable Events
  494.  5002 og=6:de=abs(de-1):
  495.       ifde=0thenreturn
  496.  
  497.     DE marks Disabled Events. When it
  498. toggles back to 0, the following code
  499. is ignored.
  500.  
  501.  
  502.  5004 forx=1to8:uc(x)=210:
  503.       hc(x)=215:next
  504.  5005 uc(4)=1:hc(4)=1:uc(5)=1:hc(5)=1
  505.  
  506.     Here we set up the Unhighlighted
  507. and Highlighted colors for each
  508. region.
  509.  
  510.  
  511.  5006 .ss,208
  512.  
  513.     Screen Stash the current screen to
  514. page 208 (under I/O).
  515.  
  516.  
  517.  5008 .ra,og,255,hc(og)
  518.  
  519.     OG holds the Old reGion. Here we
  520. turn it to the Highlighted color.
  521.  
  522.  
  523.  5010 .do
  524.  5012 .ma
  525.  5014 .kp,"e1234567_"
  526.  5016 if i%=9then i%=-1:goto5032
  527.  5018 if i% then l2%=1:og=i%:goto5032
  528.  5024 if rg%=og then5032
  529.  5026 .ra,og,255,uc(og)
  530.  5028 .ra,rg%,255,hc(rg%)
  531.  5030 og=rg%
  532.  5032 .un l2% or i%=-1
  533.  
  534.     Our Do-Loop. Since all the color
  535. codes are in arrays, it is much
  536. simpler than above.
  537.  
  538.  
  539.  5034 ifi%=-1thene%=i%:.er:return
  540.  5036 if og=1then5060
  541.  5040 .ss,232
  542.  5041 ifog=0thenog=1
  543. *5042 onog-1gosub 1000, 2000, 5200,
  544.       5200, 5000, 6000, 7000
  545.  5044 ifde=0then5100
  546.  5046 goto5010
  547.  
  548.     To disable events, we simply send
  549. the program to line 5200, which is a
  550. RETURN. Nothing happens.
  551.  
  552.  5060 .ss,232:gosub200
  553.  5070 ifi%thenreturn
  554.  5072 goto5010
  555.  5100 .sr,208
  556.  5104 return
  557.  5200 return
  558.  
  559.     As you will see as you run this
  560. program, all is not yet well with the
  561. Event or Region disabling code. The
  562. ideas are sound. My implimentation has
  563. fallen short. The darn computer is
  564. doing exactly what I tell it to do,
  565. not what I want it to do.
  566.  
  567.     Which only goes to show that even
  568. DotBASIC does not read minds! Someone
  569. needs to sit down and work out how to
  570. best accomplish these tasks. You have
  571. the essential code!
  572.  
  573.  
  574. DIALOG BOXES
  575. ------------
  576.  
  577.     If you are creating an elegant
  578. program, you will need to "visit" with
  579. your user. Lines 6500-6818 will
  580. produce three kinds of Dialogs
  581.  
  582.         OK
  583.         Yes/No
  584.         THREE CHOICES
  585.  
  586.  
  587.  6000 rem" Dialog Boxes
  588.  6002 w$="This a Message Box"
  589.  6004 bc=3
  590.  6006 hc=7
  591.  6008 ty=1
  592.  6010 gosub6500
  593.  
  594.     Put the message in W$. Set the Box
  595. Color (BC), the Highlight Color (HC),
  596. and choose the Type (TY). TY will
  597. equal the number of responses you want
  598. to give your user.
  599.  
  600.  
  601.  6020 w$="This is a Message Box"
  602.  6022 bc=7
  603.  6024 hc=3
  604.  6026 ty=1
  605.  6028 gosub6500
  606.  
  607.     We included this to show that
  608. messages with even or odd lengths
  609. still looked good.
  610.  
  611.  
  612.  6030 w$="Do You Like This?"
  613.  6032 bc=14
  614.  6034 hc=6
  615.  6036 ty=2
  616.  6038 gosub6500
  617.  
  618.     Here is a Yes/No box, followed by
  619. an OK box to show the response to the
  620. Yes/No box.
  621.  
  622.  6040 a$="No.":ifi%thena$="Yes."
  623.  6042 w$="You Chose "+a$
  624.  6044 bc=7
  625.  6046 hc=3
  626.  6048 ty=1
  627.  6050 gosub6500
  628.  
  629.     Then a Yes/No to see if the user
  630. wants to try again.
  631.  
  632.  6052 w$="Try Again?"
  633.  6054 ty=2
  634.  6056 gosub6500
  635.  6058 if i% then 6030
  636.  
  637.  
  638.  6060 w$="Now Choose Between:"
  639.  6062 a1$="Validate"
  640.  6064 a2$="Extricate"
  641.  6066 a3$="Pontificate"
  642.  6068 bc=4
  643.  6070 hc=3
  644.  6072 ty=3:hk$="vep"
  645.  6074 gosub6500
  646.  
  647.     For the THREE CHOICE box, you must
  648. give the three choices and set HK$ to
  649. the hotkeys for each choice. HK$=""
  650. disables any hotkey control.
  651.  
  652.  6076 a$=a1$
  653.  6078 ifsl%=2 then a$=a2$
  654.  6080 ifsl%=3 then a$=a3$
  655.  6082 w$="You Chose "+a$
  656.  6084 bc=7
  657.  6086 hc=3
  658.  6088 ty=1
  659.  6090 gosub6500
  660.  6092 w$="Try Again?"
  661.  6094 ty=2
  662.  6096 gosub6500
  663.  6098 if i% then6060
  664.  6100 w$="Good Bye"
  665.  6102 bc=14
  666.  6104 hc=7
  667.  6106 ty=1
  668.  6108 gosub6500
  669.  6110 .er
  670.  6112 return
  671.  
  672.     This code just displays the choice
  673. and asks if the user wants to try
  674. again. If not, it says "Good Bye" in
  675. an OK box.
  676.  
  677.  
  678.     Now we get to the Message Box
  679. routine itself. You can look through
  680. it if you want. Or just copy it to
  681. your own programs! That's what
  682. Cookbooks are for.
  683.  
  684.  6500 .ss,216
  685.  6502 x=0
  686.  6504 w=len(w$)/2
  687.  6508 if ty=3 then gosub 6550
  688.  6510 x1=19-w
  689.  6512 x2=20+w
  690.  
  691.     The width of the box is wide
  692. enough to hold W$.
  693.  
  694.  6514 .bx,x1,x2,5,9,160,bc
  695.  6516 .tx,bc+128
  696.  6518 print"<rev>";
  697.  6520 .pc,6,w$
  698.  
  699.     This is fairly standard code. Once
  700. a reverse box is drawn, set the color
  701. to the same as the box using .TX,BC --
  702. with +128 to REVERSE the characters.
  703.  
  704.  6522 on ty gosub 6600,6700,6800
  705.  6524 .sr,216
  706.  6526 return
  707.  
  708.  
  709.  6550 a1=len(a1$)
  710.  6552 a2=len(a2$)
  711.  6554 a3=len(a3$)
  712.  6556 x=(a1+a2+a3+2)/2
  713.  6558 ifx>w then w=x
  714.  6560 y1=20-x
  715.  6562 return
  716.  
  717.     This code makes sure the box is
  718. wide enough for all three answers.
  719.  
  720.  6600 .p1,646,hc
  721.  6602 print
  722.  6604 poke198,0
  723.  6606 .pc,8,"OK"
  724.  6608 .do
  725.  6610 .ma
  726.  6612 .un l2% or peek(198)
  727.  6614 poke198,0
  728.  6616 return
  729.  
  730.     The OK response.
  731.  
  732.  6700 .yn,17,8,bc+208,hc+208
  733.  6702 return
  734.  
  735.     The Yes/No response uses the
  736. YES/NO command. Easy, huh!
  737.  
  738.  6800 y2=y1+a1-1
  739.  6802 y3=y2+2
  740.  6804 y4=y3+a2-1
  741.  6806 y5=y4+2
  742.  6808 y6=y5+a3-1
  743.  6810 .p@,y1,8,a1$
  744.  6812 .p@,y3,8,a2$
  745.  6814 .p@,y5,8,a3$
  746.  6816 .mz, 3, y1, y2, y3, y4, y5, y6,
  747.       8, 8, bc, hc, hk$
  748.  6818 return
  749.  
  750.     .MZ is a multi-column menu put
  751. into service to present the three
  752. choices.
  753.  
  754.  
  755. RIGHT CLICKING
  756. --------------
  757.  
  758.     When you assign Right Click to an
  759. Event Region in VDOt, the right click
  760. event is given its own Event Handling
  761. line number, which is 256 larger than
  762. the left click's Event Handling line
  763. number. Lines 7000 and 7256 show this
  764. off.
  765.  
  766.  7000 w$="You LEFT CLICKED"
  767.  7002 bc=8
  768.  7004 hc=7
  769.  7006 ty=1
  770.  7008 gosub6500
  771.  7010 .er
  772.  7012 return
  773.  
  774.  7256 w$="You RIGHT CLICKED"
  775.  7258 goto7002
  776.  
  777.  
  778. DRIVE ACCESS
  779. ------------
  780.  
  781.     This was a last minute addition to
  782. this Cookbook. If you are doing File
  783. Requesting, you should give your user
  784. the chance to pick which drive. This
  785. code polls all active drives between 8
  786. and 15 and puts them into a menu.
  787.  
  788.  8000 rem"    Get Disk Drive
  789.  8001 dd=dv
  790.  8002 ifdkthen8013
  791.  
  792.     DK is the Drive Kount. If it is
  793. not zero, the drives have already been
  794. polled.
  795.  
  796.  8004 .qs:close2
  797.  8006 forx=8to18
  798.  8008 open2,x,2:close2
  799.  8010 ifst=0thendk=dk+1:d%(dk)=x
  800.  8012 next:.qr:poke186,dd
  801.  
  802.     This code polls the drives to see
  803. if they are active. Note, the current
  804. drive information at location 186 is
  805. changed by this routine. POKE186,DD
  806. returns it to the base drive.
  807.  
  808.  8013 .ss,208
  809.  8014 .bx,0,5,0,3+dk,160,8
  810.  8016 .p1,646,8
  811.  8018 .p@,1,1,"rDisk"
  812.  8020 forx=1todk
  813.  8022 .p@,1,2+x,str$(d%(x))
  814.  8024 next
  815.  8026 .mu,2,4,3,2+dk,8,1,""
  816.  
  817.     This makes a proportioned menu of
  818. the drive numbers.
  819.  
  820.  8027 .sr,208
  821.  8028 ifsl%=0then8048
  822.  8030 dv=d%(sl%)
  823. -8032 w$="Your Disk is"+str$(dv)
  824. -8034 ty=1
  825. -8036 bc=8
  826. -8038 hc=1
  827. -8040 gosub6500
  828. -8042 dv=dd
  829. -8044 w$="Now it is"+str$(dv)
  830. -8046 gosub6500
  831.  8048 .er:return
  832.  
  833.     You will certainly want to do more
  834. than just announce the results.
  835.  
  836.  
  837. SUMMARY
  838. -------
  839.  
  840.     DotBASIC is incredibly powerful.
  841. If you have only a little experience
  842. with BASIC 2.0, you should find
  843. DotBASIC the perfect way to add
  844. pazzazz without a lot of skull sweat!
  845.  
  846.     Print this out, along with the
  847. DotBASIC Command Summary, and step
  848. through the COOKBOOK program to see
  849. what is happening.
  850.  
  851.  DMM
  852.  
  853.  
  854.