home *** CD-ROM | disk | FTP | other *** search
/ Loadstar 245 / 245.d81 / t.tutorial1 < prev    next >
Text File  |  2022-08-26  |  8KB  |  379 lines

  1. u
  2.           DotBASIC Tutorial
  3.            by Dave Moorman
  4.  
  5.  
  6.     DotBASIC is a fantastic way to
  7. quickly develop software. Visual
  8. Design lets you see what your main
  9. screen is going to look like -- and
  10. lets you define buttons or Event Areas
  11. and assign each to a certain line
  12. number in your DotBASIC program.
  13. Object Oriented Programming features
  14. make writing the code a cinch. Your
  15. project is finished in no time!
  16.  
  17.     This tutorial will take you
  18. through the whole process of designing
  19. a Quiz game. The questions with up to
  20. four answers each are in a quiz file.
  21. So the task is to allow the user to:
  22.  
  23.     Pick a quiz
  24.     Take the quiz
  25.     Exit the program.
  26.  
  27.     The first step in DotBASIC is to
  28. move the DotBASIC files to your work
  29. disk:
  30.  
  31.     B.DOT
  32.     DOT.DOT
  33.     DOT.ML
  34.  
  35.     You also will need B.VDOT in order
  36. to design the screen. For this
  37. tutorial, we will assume all four
  38. program files are on your work disk
  39. (on drive 8).
  40.  
  41. [NOTE:] All four programs are on this
  42. disk. Unfortunately, we could not
  43. include our Copy It feature on this
  44. side of the 1541 disks -- so you will
  45. need to use your own copy program to
  46. make the transfer.
  47.  
  48.  
  49. LOAD"B.VDOT",8:<Shift-RUN>
  50.  
  51. (If you are using VICE, use WARP
  52. speed whenever in Mouse Mode with
  53. VDOT. It just makes things faster and
  54. smoother.)
  55.  
  56.     Press <F3> and point to the
  57. Reverse Space on the Font window and
  58. click. Then press <F5>, and click on
  59. White on the Color Palette. Now, press
  60. <F3> (toggles off font window) and
  61. <F1> (toggles off menu bar).
  62.  
  63.     Press <Ctrl-E> to open the Edit
  64. Menu. Click on Box. Move the square to
  65. the upper-left corner of the screen
  66. and click. Then move down and right
  67. until the whole screen is bracketed --
  68. and click. Press <F3>, move the White
  69. "bucket" to the left edge of the
  70. window and click. This makes the
  71. border white.
  72.  
  73.     Now you have a nice, white screen,
  74. in reverse with a black background.
  75.  
  76.     Press <Shift-RETURN> to toggle
  77. into Text Mode. (VICE users will want
  78. to toggle off Warp.) A shimmering
  79. square is your cursor. You edit the
  80. screen almost exactly like using the
  81. C-64s own text editor. Cursor up to
  82. row 0, column 1. Type <Ctrl-9>
  83. <Ctrl-2> (reverse white), then
  84.  
  85.  Quiz    Exit
  86.  
  87. (separated by four spaces).
  88.  
  89.     Press <Shift-RETURN> to toggle
  90. back to mouse mode. If the Color
  91. Palette is not visible, press <F3> and
  92. <F5> until it is. Press <UP ARROW> to
  93. move the Palette to the bottom of the
  94. screen.
  95.  
  96.     Point the bucket to Yellow and
  97. click, then point at the word Quiz,
  98. hold down the left mouse button, and
  99. "paint" all of row 0 yellow.
  100.  
  101.     Choose the color Cyan from the
  102. Palette and paint a 40 column wide, 7
  103. column tall box (for your quiz
  104. questions). Below it, paint four
  105. 40-column, two-row boxes (for the
  106. answers). You can add shadows if you
  107. want.
  108.  
  109.  NOW TO DEFINE EVENT REGIONS
  110.  
  111.     Event Regions are areas on the
  112. screen that can change color when the
  113. mouse arrow rolls over, and when
  114. clicked will call Event Handling
  115. routines in your DotBASIC program.
  116.  
  117.     Press <F1> until you see the menu
  118. bar (Files Edit, etc). Click Edit,
  119. Box. Place the square to the left of
  120. the word Quiz, and click. Then move
  121. right until Quiz is bracketed, and
  122. click. The Edit menu will reappear.
  123. Click Add Region. A dialog box will
  124. appear. Press the indicated <keys>:
  125.  
  126. Line Number 1000 <RETURN>
  127. Hot Key <q><RETURN>
  128. Right Clk (Y/N) <n>
  129. Unhighlighted Color <7><RETURN>
  130. Reverse (Y/N) <y>
  131. Highlighted Color <8><RETURN>
  132. Reverse (Y/N) <y>
  133. Is This Right? (Y/N) <y>
  134.  
  135.     Region 1 is now added. Click Edit,
  136. Box again, put the little box to left
  137. of Edit, click, bracket Exit, click,
  138. and click Add Region.
  139.  
  140. Line Number 2000 <RETURN>
  141. Hot Key <e>
  142. (repeat as above for Region 2).
  143.  
  144. (If you are wondering why we did not
  145. make the answer boxes into Event
  146. Areas -- we will discuss it later.
  147. Event Driven programming has its
  148. limitations at this point.)
  149.  
  150.     You have now defined and assigned
  151. two Event Regions. You are ready to
  152. save your screen. Click File, Save,
  153. MeddleScreen MED. Type in the name you
  154. are going to call your program. In
  155. this case, quiz and press <RETURN>.
  156. Click OK.
  157.  
  158.     Your screen is ready. If you need
  159. to edit it later, you can Load it
  160. (File, Load, "quiz.med"). When you
  161. resave, you have to click OK twice.
  162.  
  163.     Now -- on to the real fun! Reset
  164. your computer and
  165.  
  166. LOAD"B.DOT",8
  167.  
  168. LIST 60008
  169.  
  170.   60008 N$="DOT"
  171.  
  172.     Change the name DOT to QUIZ. Press
  173. <RETURN>, then type
  174.  
  175. GOTO60000<RETURN>
  176.  
  177. Your boot is ready. RUN it.
  178.  
  179.     You will soon see the title, then
  180. a list of lines:
  181.  
  182. 1000 return:rl1
  183. 2000 return:rl2
  184.  
  185. ?undef'd statement  error in 90
  186. ready.
  187.  
  188.  
  189. Move your cursor up and press
  190. <RETURN> on each line. Move to the
  191. bottom of the screen and type
  192.  
  193. GOTO60000<RETURN>
  194.  
  195. LOAD"B.QUIZ",8:<Shift-RUN>
  196.  
  197.     And -- Lo and Behold! There is
  198. your screen. Notice how Quiz and Exit
  199. change color when you roll over with
  200. the mouse arrow. Nothing works when
  201. you click, because you have not
  202. written the Event Handling routines.
  203. Press <BACK ARROW> to escape.
  204.  
  205. NOTE: It you happen to press STOP or
  206. the mouse arrow is still visible,
  207. type
  208.  
  209. .OF<RETURN>
  210.  
  211. to turn off the Event and Mouse
  212. Drivers. This is important: If these
  213. are not off, you may get a corrupted
  214. program.
  215.  
  216.  
  217. LIST 100-199
  218.  
  219.  
  220. 100 .do:.ee:.wb:.un e%
  221. 101 .of:end
  222.  
  223.     These few commands create a loop
  224. that operates while the Event Driver
  225. is working. Note that DotCommands all
  226. begin with a period (dot) and have two
  227. characters. Here is a quick
  228. run-through of line 100:
  229.  
  230. .DO  Begins a DO-LOOP, one of the
  231. most powerful features of DotBASIC.
  232. See .UN below.
  233.  
  234. .EE  Event Enable. When you started
  235. your program, the assigned line
  236. numbers were all found and internal
  237. GOSUBs were calculated. While line
  238. 100 loops around, the Event Driver
  239. watches for roll-overs and clicks on
  240. Event Regions. A click is an Event.
  241. The Event Driver is disabled (because
  242. we don't need an event to happen
  243. while one is being handled). The
  244. Event Handling Routine at the
  245. assigned line number is called. When
  246. RETURN is encountered, the program
  247. comes back to the loop at line 100.
  248. The .EE command re-enables the Event
  249. Driver.
  250.  
  251. .WB  Watch Backarrow. This command
  252. watches the <BACK ARROW> key, and
  253. when pressed, the variable E% (which
  254. is normally 0) becomes -1.
  255.  
  256. .UN E%  This is the end of the
  257. DO-LOOP, and will loop back to the
  258. .DO command UNtil E% is not zero.
  259.  
  260. .OF  Off. Turns off DotBASIC.
  261.  
  262. And the program ENDs.
  263.  
  264.     Now it is time to do the Event
  265. Handling Routine for Exit, which
  266. begins with line 2000.
  267.  
  268. 2000 .RU,216,215
  269. 2002 E%=I%
  270. 2004 .ER:RETURN
  271.  
  272. .RU is short for "Are You Sure," an
  273. automatic dialog box that asks, of
  274. all things, "Are You Sure?" The two
  275. numbers indicate the color of the box
  276. (plus 208) and the color of the
  277. selected response (also plus 208).
  278.  
  279. E%=I%
  280.  
  281. The result of the Are You Sure dialog
  282. is returned in I% -- 0 for No, -1 for
  283. Yes. We put the result in E%
  284.  
  285. .ER  Event Screen Restore -- which
  286. removes the Are Your Sure Dialog box.
  287.  
  288. RETURN  Returns to line 100. If we
  289. have put Not Zero into E%, the loop
  290. will end. Note: You can use different
  291. values in E% to signal different
  292. things, and sort them out in line
  293. 101.
  294.  
  295. To save your work, type:
  296.  
  297. GOTO60000<RETURN>
  298.  
  299. NOTE: Be sure to save early and often.
  300. With DotBASIC, saving the current code
  301. is always the same: GOTO60000.
  302.  
  303.     Then RUN the program. You can
  304. point and click Exit, or press <E> to
  305. bring up the Are You Sure box. Try
  306. clicking No, pressing <N>, clicking
  307. Yes, and (after running again),
  308. pressing <Y>.
  309.  
  310.     See how easy that was? DotBASIC
  311. does a lot for you!
  312.  
  313.     We will now need to make a couple
  314. of test quizzes for our program to
  315. use. Be sure to save your program with
  316. GOTO60000. Then reset your computer
  317. and boot MR.EDSTAR or EDSTAR.
  318.  
  319. The first line of the file is the
  320. Quiz Name. Then follows 5 lines of
  321. question, then, for each answer, a
  322. line with the value for the answer
  323. and two lines of the answer. Here is
  324. our example:
  325.  
  326. ----------------- <top of text
  327. Quiz One
  328. Question 1: What is
  329. the size of
  330. the
  331. Grand
  332. Canyon?
  333.  
  334. Smaller than
  335. a Breadbox
  336. 10
  337. Really, Really
  338. BIG (you will get 10 points)
  339. -5
  340. This answer will cost
  341. you five points
  342.  
  343. This answer is wrong, but
  344. you will not be penalized.
  345. <ENGLISH POUND SIGN>
  346. Question 2
  347. Line 2
  348. Line 3
  349. Line 4
  350. Line 5
  351.  
  352. Wrong
  353. .................
  354.  
  355. Wrong Again
  356. ..................
  357.  
  358. Wronger Yet
  359. ................
  360. 1
  361. Right
  362. You get one point with