home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Creative Computers
/
CreativeComputers.iso
/
commercial
/
inovatronics
/
candodemo
/
testdrivemanual
/
testdrive2.doc
< prev
next >
Wrap
Text File
|
1994-11-17
|
17KB
|
414 lines
**** CANDO TEST DRIVE #2
Now that you've completed the first Test Drive, you have learned
to create objects, such as Buttons and Fields, and to tell them to do
something. Now it's time to put this basic knowledge to work by
making a real application.
You are going to make a movie database. To assist in making
database applications, CanDo comes with a Deck called "DBBaseDeck".
It contains "Routines" which are useful for making many kinds of
databases. While these routines are not very complicated, in this
tutorial we won't go into detail on how they work. However, you don't
need to know much about them to make use of them. You can use them
like the Editor Tools in the first Text Drive.
So let's get started by loading "DBBaseDeck". You are going to be
using a Menu option to load the Deck. Therefore, click on some part
of the Main Panel which does not have a Button. Now, using the right
mouse button, select "Open..." from the Deck Menu.
This will bring up the File Requester. Click on DBBaseDeck in the
File List and then select Ok.
This will open a plain looking window. This deck only contains a
single card which does not have any Objects.
The Process for making this application is:
╖ Define the picture window.
╖ Make a couple of buttons for moving around in the database.
(i.e. Next Entry, Previous Entry, Add Entry)
╖ Make a couple of "database" Objects.
╖ Test it out a little.
╖ Add the remaining operations
(Search, Delete, Sort, Load and Save)
First, let's make your window little more jazzy. Select the
Window Icon from the Main Panel.
See Picture "Images/WindowIcon"
Click on the Dimension Button and then the "Unnamed" Picture
Button. Now select "MovieBackdrop.Pic" and click Ok on the File
Requester, Dimension Requester and finally the Window Editor.
This will bring up a window similar to the one used in the first
Test Drive but with some nice titles and imagery. Now to add the
buttons which allow you to move through the database entries.
The first button will cause the database to move to the the
previous entry. It will use the same yellow arrow used in the first
Test Drive. Click on Add and then the Button Icon on the Main Panel.
See Picture "Images/AddIcon"
See Picture "Images/ButtonIcon"
Position the cross-hairs to the left of the brown box at the
coordinates 15,50 , click and release the left mouse button.
The button you are creating will cause the database to move
backwards to the previous entry. In this application you are going to
give names to the Objects you create. Change "Button#1" to "Previous
Button".
See Picture "Images/Name.PreviousButton"
Click on the box next to "Image" and then the "Unnamed" Image Name
Button. Select "left1.br" by double-clicking it in the File List
(Some people find this easier than selecting the file and clicking
Ok). Click Ok on the Image Button Requester to return to the Button
Editor. Click on the "COMPLEMENT" Highlight Button and then the
"Undefined" button to select the alternate image for this button.
Select "left2.br" and return to the Highlight Style Requester. Click
Ok to return to the Button Editor.
Click on the Release Button to bring up the Script Editor. The
DBBaseDeck contains the Routines necessary for creating this, and many
other database applications. To access them, select "Routines..."
from the "Special" Menu.
This will bring up the Routine Browser.
See Picture "Images/RoutineBrowser"
From the list of Routine names, select "Previous Entry" by
clicking on it once. Then, click the "Insert a 'Do' to this Routine"
Button. This will create the following line.
Do "Previous Entry"
Click Ok to return to the Button Editor, and then Ok again to
return to the Main Panel.
Now you are going to do a similar process for creating the button
which will cause the database to move the next entry. Click on the
Add and Button Icons on the Main Panel. Position the cross-hairs at
60,50 and click and release the mouse button. When the Button Editor
appears, change "Button#1" to "Next Button". Click on the box next to
Image, and then the "Unnamed" buttons. Select "right1.br" and return
to the Button Editor. Change the Highlight from "COMPLEMENT" to
"right2.br". Next, click on the Release button to go to the Script
Editor. Select "Routines..." from the Special Menu. This time click
on "Next Entry" and then "Insert a 'Do' to this Routine".
Do "Next Entry"
Exit the Script Editor and then the Button Editor by clicking
their Ok buttons.
Next you will add a Text button below the two arrows which will
"Add" new entries to the database. Click on Add and then the Button
Icons. Position the cross-hairs at 20,75, click and release the mouse
button (text buttons get their size from the text).
Change "Button#1" to "Add Button". Click on the box next to Text
to bring up the Font/Text Requester. Change "Add Button" to " Add ".
Make sure there are two space on both sides of "Add". Because the
Text buttons conform to the size of the Text, the spaces will make the
button longer.
See Picture "Images/Text.Add"
Click on Yellow in the Color Palette and then the Shadowed button.
Click Ok to return to the Button Editor
Click on the "OUTLINE" Border Button. Click on the Shadow style
and Ok to return to the Button Editor.
Click on the Release Button to go to the Script Editor. Using the
Routine Browser, insert a 'Do' to the "Add Entry" routine.
Do "Add Entry"
Exit the Script Editor and then the Button Editor.
You've created the essential operations to add and look at
database entries. Now you need to make some "database" fields to use.
In this application you are going to add a "Name" text field, a
"Tape#" integer (number) field, and a "Description" document. (These
will be easy!)
Click on the Add and Field Icons on the Main Panel.
See Picture "Images/AddIcon"
See Picture "Images/FieldIcon"
Position the cross-hairs at 230,52. Press and hold the left mouse
button. Drag the mouse to the right until the width is 320 and
release the mouse button.
To make this a database field, set the Name Field to ".Name".
See Picture "Images/Name.Name"
When you want a Field, Document, or Button to be included in the
database, the name must begin with ".", followed by a letter, and then
as many letters or numeric characters (0 - 9) as you want. (The name
cannot contain spaces.) That's all you do to designate a database
object.
Click on the OUTLINE Border button and change it to the new Double
Border style and click Ok.
This Field has a Width of 320. This leaves room for 40 characters
(320 ≈ 8 pixels per character). Click on the box, containing a
checkmark, next to the title Text.
See Picture "Images/TextCheckmark"
This brings up the Text Requester. Change the "Max Number of
Characters" to 40.
See Picture "Images/MaxChars"
Click Ok on the Text Requester. Click Ok on the Field Editor
Requester to return to the Main Panel.
Click on the Add and Field Icons. Position the cross-hairs at
230,70. Press-Drag the mouse to the right until the Width is 80 and
release the mouse button. When the Field Editor appears, change the
Name to ".Number".
See Picture "Images/Name.Number"
Click on the Box next to Integer.
See Picture "Images/IntegerBox"
This changes the Field into an Integer Field. This restricts the
field to only containing numeric values. This requester allows you to
specify limits for these values and the initial value. Change Minimum
to 0.
See Picture "Images/MinimumVal"
Click Ok to return to the Field Editor. Change the Border to the
new Double Border Style. Click Ok on the Field Editor to return to
the Main Panel.
Finally, let's add the Description Document. Click on the Add and
the Document Icons on the Main Panel.
See Picture "Images/AddIcon"
See Picture "Images/DocumentIcon"
Position the cross-hairs at 230,88. Press-Drag the mouse to make
the dimensions 320,64 and then release the mouse pointer.
Set the Name to ".Description" and the Document to "Description - Doc"
See Picture "Images/Name.Description"
The first Test Drive used the Document Field to specify a File to
load. This Document should not load a file. It is highly unlikely
the current directory will contain a file named "Description - Doc".
This way the Document will initially be empty.
Click on the Border button and change the style to the new Double
Style.
Click Ok to return to the Main Panel.
Now you get to see how it works. Click on the Browse and Screen
Up/Down Button. Click in the Name Field. Enter the name of any movie
you want. Click in the Tape# Field and set the number to something
other than 0. Finally, enter a description for the movie.
Now, click on the Add Button (the one on your window). The Name
Field and the Document should clear and the Tape# should be reset to
0. (If one of the Fields does not clear, then you did not correctly
specify the Name. If all three Fields stay the same, it could be one
of two things: you did not correctly specify the Name in any of the
Objects or you did not correctly insert the instruction Do "Add Entry"
in the Release Script for the "Add Button".)
Enter another movie by setting all three fields. Finally, add a
third movie. By having three movies in the database, you should be
able to determine if the "Next Button" and "Previous Button" are
operating correctly. Try Clicking on the yellow arrow buttons a few
times.
If you correctly made these Objects, you should be able to Add new
entries to the database, and move from one entry to another using the
arrow buttons. However, if you were to add a lot of entries to the
database, it could take quite a while to find an entry. Time to add
Search capabilities. Raise CanDo's screen and then click on the Add
and Field Icons on the Main Panel.
Position the cross-hairs at 230,165. Press-Drag the mouse to make
the Field a width of 320, and release the mouse button. Change the
name from "Field#1" to "SearchField". Because the name does not start
with a "." and it contains a space, this Field will not be included in
the database. You want to use the field for getting a Name to search
for, not data to be included with each database record.
Click on the OUTLINE Border Style and change it to the new Double
Border style and return to the Field Editor. Click on the box next to
the title Text. Set the Field "Max Number of Characters" to 40 and
click Ok.
Next, click on the Return button under "Scripts...". Select
"Routines..." in the Special Menu. Use the slider to locate the
Routine "Search For Entry" in the list of Routines. Click on it once
to select it and then on the "Insert a 'Do' to this Routine" button.
This will insert the following line in your script.
Do "Search For Entry"
The "Search For Entry" will locate a text string in a specific
record field in the database. Therefore, you need to tell this
routine two more pieces of information: the text string to look for
(it comes from this field) and the record field to search in (the
".Name" Field). Add the following text to the end of the current
line:
,TextFrom("SearchField"),".Name"
The TextFrom Function, like the example in the first Test Drive,
returns the current text from a field. This text is given to the
"Search For Entry" Routine. The ".Name" tells this Routine which
record field to look in. The line should read as follows:
Do "Search For Entry",TextFrom("SearchField"),".Name"
Double check that the Quotes and Commas are in the correct places.
This can be an easy error to make. Add the line:
SetObjectState "SearchField",ON
This will cause the "SearchField" Field to remain active after the
Return key has been pressed. The Script should read:
Do "Search For Entry",TextFrom("SearchField"),".Name"
SetObjectState "SearchField",ON
Click Ok to return to the Field Editor and Ok again to return to
the Main Panel.
Click in the Field you just created. Enter the name or partial
name of a movie. When you press the return key, the entry should be
displayed. Notice the Cursor in the "SearchField". This is the
result of the SetObjectState command. You can now press return again
to search for the next occurrence of the name or partial name.
Now that you have a database, you probably want a way to save it.
It would also be nice to be able to delete unwanted entries and to
sort the database in alphabetical order. Let's create some Menus to
do these operations.
Press on the Edit and Menu Icons on the Main Panel.
See Picture "Images/EditIcon"
See Picture "Images/MenuIcon"
This brings up a Requester allowing you to Edit the Menu Titles.
You do not currently have any, so press on the Add Button. The
default name is Menu#1. Change "Menu#1" to "Project" and click Ok or
press the Return Key.
This brings up an identical requester for the Menu Items to be
added to the "Project" Menu you are creating. Click on Add.
This brings up the Menu Item Object Editor. Change the Name to
"Save". Enter the letter "S" for the Short Cut Key.
See Picture "Images/Save.Menu"
Click on the Selected button to bring up the Script Editor.
Select "Routines..." from the "Special" Menu. Find the Routine "Save
Database" and Click on it once. Click on the "Insert a 'Do' to this
Routine" button.
Do "Save DataBase"
Click Ok on the Script Editor and then on the Menu Item Object
Editor.
You should now see "Save" in the list of Menu Items. Click on Add
again. You are now going to make a Menu Item to Load the previously
saved version of the database. Change the name to "Load" and give it
a short cut key of "L". Click on the Selected button. Bring up the
Routine Editor. This time make a Do to the Routine "Load Database".
Do "Load Database"
Click Ok to return to the Menu Item Object Editor and Ok again to
return to the Menu Item Editing System.
You should now have both "Save" and "Load" in the List. Click
Exit. This returns you to the Menu list. The Menu "Project" is the
one you just created containing the "Save" and "Load" Menu Items.
You are now going to add a second Menu. Click on Add. Change the
Name to "Options" and click Ok or press the Return key. You are going
to Add two Menu Items to "Options": "Sort" and "Delete".
Click on Add and change the Name to "Sort". This time don't add a
Short Cut Key (besides, "S" is already used for Save). Click on the
Selected button and insert a Do to the Routine "Sort DataBase".
Do "Sort DataBase"
You want to sort the database where the names will appear in
alphabetical order. As with the "Search For Entry" Routine, the "Sort
DataBase" routine needs to know which record field to sort by. Modify
the line so it reads as follows:
Do "Sort DataBase",".Name"
This tells the "Sort DataBase" Routine to sort the database based
on the text in the ".Name" field.
Click Ok to return to the Menu Item Object Editor. Click Ok again
to return to the Menu Item list. It should contain the single entry
"Sort".
Click on Add again. Change the Name to "Delete". Click on the
Selected button. Bring up the Routine Browser and insert a Do to the
"Delete Entry" Routine.
Do "Delete Entry"
Click Ok on the Script Editor and the Menu Item Object Editor.
That's all the Menu Items to be added to the "Options" menu so
click Exit. This will display your two Menu headings, "Project" and
"Options". Click Exit again.
Click on Browse, lower CanDo's Screen, and Click somewhere in your
window to activate it (on the Amiga, a window must be active to show
its Menus).
Press your right mouse button. Notice the two Menu headings you
created. Select "Save" from your "Project" Menu. Now select "Sort"
in the "Options" Menu. Using the Next and Previous Buttons you can
verify the movies are in alphabetical order. Delete one or all of the
entries. Now select "Load" from the Project Menu. This should
restore the database.
You have now completed the Second Test Drive. In doing so, you
have created an application which would have been very complicated to
make in any "high-level" programming language, and impossible to
match, feature for feature, using any other software "Authoring"
system.
This little Test Drive has "shown you around the block" of your
potential using CanDo. However, the real power is getting it to make
the software you really want. When you get CanDo, you can hit the
highway to unseen horizons.
With your 10$ coupon, order CanDo today through your favorite
dealer or directly from INOVAtronics at 1-800-875-8499.