home *** CD-ROM | disk | FTP | other *** search
- u
- DotBASIC Tutorial
- by Dave Moorman
-
-
- DotBASIC is a fantastic way to
- quickly develop software. Visual
- Design lets you see what your main
- screen is going to look like -- and
- lets you define buttons or Event Areas
- and assign each to a certain line
- number in your DotBASIC program.
- Object Oriented Programming features
- make writing the code a cinch. Your
- project is finished in no time!
-
- This tutorial will take you
- through the whole process of designing
- a Quiz game. The questions with up to
- four answers each are in a quiz file.
- So the task is to allow the user to:
-
- Pick a quiz
- Take the quiz
- Exit the program.
-
- The first step in DotBASIC is to
- move the DotBASIC files to your work
- disk:
-
- B.DOT
- DOT.DOT
- DOT.ML
-
- You also will need B.VDOT in order
- to design the screen. For this
- tutorial, we will assume all four
- program files are on your work disk
- (on drive 8).
-
- [NOTE:] All four programs are on this
- disk. Unfortunately, we could not
- include our Copy It feature on this
- side of the 1541 disks -- so you will
- need to use your own copy program to
- make the transfer.
-
-
- LOAD"B.VDOT",8:<Shift-RUN>
-
- (If you are using VICE, use WARP
- speed whenever in Mouse Mode with
- VDOT. It just makes things faster and
- smoother.)
-
- Press <F3> and point to the
- Reverse Space on the Font window and
- click. Then press <F5>, and click on
- White on the Color Palette. Now, press
- <F3> (toggles off font window) and
- <F1> (toggles off menu bar).
-
- Press <Ctrl-E> to open the Edit
- Menu. Click on Box. Move the square to
- the upper-left corner of the screen
- and click. Then move down and right
- until the whole screen is bracketed --
- and click. Press <F3>, move the White
- "bucket" to the left edge of the
- window and click. This makes the
- border white.
-
- Now you have a nice, white screen,
- in reverse with a black background.
-
- Press <Shift-RETURN> to toggle
- into Text Mode. (VICE users will want
- to toggle off Warp.) A shimmering
- square is your cursor. You edit the
- screen almost exactly like using the
- C-64s own text editor. Cursor up to
- row 0, column 1. Type <Ctrl-9>
- <Ctrl-2> (reverse white), then
-
- Quiz Exit
-
- (separated by four spaces).
-
- Press <Shift-RETURN> to toggle
- back to mouse mode. If the Color
- Palette is not visible, press <F3> and
- <F5> until it is. Press <UP ARROW> to
- move the Palette to the bottom of the
- screen.
-
- Point the bucket to Yellow and
- click, then point at the word Quiz,
- hold down the left mouse button, and
- "paint" all of row 0 yellow.
-
- Choose the color Cyan from the
- Palette and paint a 40 column wide, 7
- column tall box (for your quiz
- questions). Below it, paint four
- 40-column, two-row boxes (for the
- answers). You can add shadows if you
- want.
-
- NOW TO DEFINE EVENT REGIONS
-
- Event Regions are areas on the
- screen that can change color when the
- mouse arrow rolls over, and when
- clicked will call Event Handling
- routines in your DotBASIC program.
-
- Press <F1> until you see the menu
- bar (Files Edit, etc). Click Edit,
- Box. Place the square to the left of
- the word Quiz, and click. Then move
- right until Quiz is bracketed, and
- click. The Edit menu will reappear.
- Click Add Region. A dialog box will
- appear. Press the indicated <keys>:
-
- Line Number 1000 <RETURN>
- Hot Key <q><RETURN>
- Right Clk (Y/N) <n>
- Unhighlighted Color <7><RETURN>
- Reverse (Y/N) <y>
- Highlighted Color <8><RETURN>
- Reverse (Y/N) <y>
- Is This Right? (Y/N) <y>
-
- Region 1 is now added. Click Edit,
- Box again, put the little box to left
- of Edit, click, bracket Exit, click,
- and click Add Region.
-
- Line Number 2000 <RETURN>
- Hot Key <e>
- (repeat as above for Region 2).
-
- (If you are wondering why we did not
- make the answer boxes into Event
- Areas -- we will discuss it later.
- Event Driven programming has its
- limitations at this point.)
-
- You have now defined and assigned
- two Event Regions. You are ready to
- save your screen. Click File, Save,
- MeddleScreen MED. Type in the name you
- are going to call your program. In
- this case, quiz and press <RETURN>.
- Click OK.
-
- Your screen is ready. If you need
- to edit it later, you can Load it
- (File, Load, "quiz.med"). When you
- resave, you have to click OK twice.
-
- Now -- on to the real fun! Reset
- your computer and
-
- LOAD"B.DOT",8
-
- LIST 60008
-
- 60008 N$="DOT"
-
- Change the name DOT to QUIZ. Press
- <RETURN>, then type
-
- GOTO60000<RETURN>
-
- Your boot is ready. RUN it.
-
- You will soon see the title, then
- a list of lines:
-
- 1000 return:rl1
- 2000 return:rl2
-
- ?undef'd statement error in 90
- ready.
-
-
- Move your cursor up and press
- <RETURN> on each line. Move to the
- bottom of the screen and type
-
- GOTO60000<RETURN>
-
- LOAD"B.QUIZ",8:<Shift-RUN>
-
- And -- Lo and Behold! There is
- your screen. Notice how Quiz and Exit
- change color when you roll over with
- the mouse arrow. Nothing works when
- you click, because you have not
- written the Event Handling routines.
- Press <BACK ARROW> to escape.
-
- NOTE: It you happen to press STOP or
- the mouse arrow is still visible,
- type
-
- .OF<RETURN>
-
- to turn off the Event and Mouse
- Drivers. This is important: If these
- are not off, you may get a corrupted
- program.
-
-
- LIST 100-199
-
-
- 100 .do:.ee:.wb:.un e%
- 101 .of:end
-
- These few commands create a loop
- that operates while the Event Driver
- is working. Note that DotCommands all
- begin with a period (dot) and have two
- characters. Here is a quick
- run-through of line 100:
-
- .DO Begins a DO-LOOP, one of the
- most powerful features of DotBASIC.
- See .UN below.
-
- .EE Event Enable. When you started
- your program, the assigned line
- numbers were all found and internal
- GOSUBs were calculated. While line
- 100 loops around, the Event Driver
- watches for roll-overs and clicks on
- Event Regions. A click is an Event.
- The Event Driver is disabled (because
- we don't need an event to happen
- while one is being handled). The
- Event Handling Routine at the
- assigned line number is called. When
- RETURN is encountered, the program
- comes back to the loop at line 100.
- The .EE command re-enables the Event
- Driver.
-
- .WB Watch Backarrow. This command
- watches the <BACK ARROW> key, and
- when pressed, the variable E% (which
- is normally 0) becomes -1.
-
- .UN E% This is the end of the
- DO-LOOP, and will loop back to the
- .DO command UNtil E% is not zero.
-
- .OF Off. Turns off DotBASIC.
-
- And the program ENDs.
-
- Now it is time to do the Event
- Handling Routine for Exit, which
- begins with line 2000.
-
- 2000 .RU,216,215
- 2002 E%=I%
- 2004 .ER:RETURN
-
- .RU is short for "Are You Sure," an
- automatic dialog box that asks, of
- all things, "Are You Sure?" The two
- numbers indicate the color of the box
- (plus 208) and the color of the
- selected response (also plus 208).
-
- E%=I%
-
- The result of the Are You Sure dialog
- is returned in I% -- 0 for No, -1 for
- Yes. We put the result in E%
-
- .ER Event Screen Restore -- which
- removes the Are Your Sure Dialog box.
-
- RETURN Returns to line 100. If we
- have put Not Zero into E%, the loop
- will end. Note: You can use different
- values in E% to signal different
- things, and sort them out in line
- 101.
-
- To save your work, type:
-
- GOTO60000<RETURN>
-
- NOTE: Be sure to save early and often.
- With DotBASIC, saving the current code
- is always the same: GOTO60000.
-
- Then RUN the program. You can
- point and click Exit, or press <E> to
- bring up the Are You Sure box. Try
- clicking No, pressing <N>, clicking
- Yes, and (after running again),
- pressing <Y>.
-
- See how easy that was? DotBASIC
- does a lot for you!
-
- We will now need to make a couple
- of test quizzes for our program to
- use. Be sure to save your program with
- GOTO60000. Then reset your computer
- and boot MR.EDSTAR or EDSTAR.
-
- The first line of the file is the
- Quiz Name. Then follows 5 lines of
- question, then, for each answer, a
- line with the value for the answer
- and two lines of the answer. Here is
- our example:
-
- ----------------- <top of text
- Quiz One
- Question 1: What is
- the size of
- the
- Grand
- Canyon?
-
- Smaller than
- a Breadbox
- 10
- Really, Really
- BIG (you will get 10 points)
- -5
- This answer will cost
- you five points
-
- This answer is wrong, but
- you will not be penalized.
- <ENGLISH POUND SIGN>
- Question 2
- Line 2
- Line 3
- Line 4
- Line 5
-
- Wrong
- .................
-
- Wrong Again
- ..................
-
- Wronger Yet
- ................
- 1
- Right
- You get one point with this answer.
- <ENGLISH POUND SIGN>
- end quiz
-
- -----------------------
-
- The layout is self-explanatory.
- Save the file to "q.quiz 1". Save it
- again to "q.another quiz", and a third
- time as "q.busy".
-
- You are ready to do some serious
- coding -- the easy DotBASIC way -- in
- Part 2.
-
- DMM
-
-
-