
The Vesta
Single Tasking Basic Manual
For the SBC2000-074,
the MC2000-074 &
Dev-074,
and the SBC2000-062
Revised February 21, 2000
Installing the Vesta Basic IDE
The Integrated Development Environment
Using the Stack as Variable Space
Language Extensions and Examples
Appendix A - The ASCII Conversion Table
Vesta Technology's innovative Vesta Single Tasking Basic (VSTB) unites the ease of use and worldwide support of BASIC with the speed and flexibility of C. Modeled on the latest, third-generation BASICs, our Single Tasking Basic is procedure oriented to promote structured programming, enhance programmer productivity and minimize maintenance.
Vesta Basic source code is compiled on your PC into tokens that are executed by the Runtime Engine on the Vesta single-board computer (SBC). The result is the convenience of a Windows development environment and the speedy execution needed for real-time embedded control.
Vesta Basic owes its friendly operation to an Integrated Development Environment (IDE), which is based on a Graphic User Interface. This reduces compiling, linking, location, downloading and initializing code to a single click of the mouse.
The Vesta Basic Integrated Development Environment (IDE) is the PC portion of the Vesta Basic language. The key components are:
• The Graphic User Interface
• The Vesta Basic compiler
• The link between the PC and the SBC.
SBC2000
Features -074 -062
GUI U U
Compiler U U
Structured Code U U
Timers U U
Error handler U U
Event handler U U
Floating-Point U
Vesta Single Tasking Basic provides extensive, easy to use keywords and structures that are versatile enough for any application and object oriented to allow easy creation of extremely powerful programs. The Vesta Single Tasking Basic IDE was designed to help you write cleaner code faster. Here are some of the features of Vesta Single Tasking Basic that we really like.
Animation and
Watching Variables
Vesta Single Tasking Basic allows you to debug your code as it will run in the actual destination environment. You can download your program to the SBC and step through each line watching the values of each variable as they change.
A variable may be interrogated at any time by highlighting the variable and pressing Ctrl-W while the task is executing or after the task has been completed.
There is simply no substitute for knowing exactly how your code will execute in the environment for which it is written.
Tool Bar Buttons
Compile, link, download, reset and start execution with a single mouse click. Stop and step execution with convenient toolbar buttons.
Link Activity Indicator
The heart/sun activity indicator in the upper right corner indicates polling activity between the Vesta Basic IDE and the SBC.
Vesta Single Tasking Basic requires a PC
with a ‘386 or higher microprocessor, Windows 95 / 98 / NT, one available COM
port, 8 megabytes of RAM and 10 megabytes of available hard disk space. Life without a mouse, 16 megabytes of RAM
and an 80 MHz or faster clock will be slow.
If you have a spare terminal or another COM port available on your PC and terminal emulation program, you can use it as the output destination for print statements. Connect the COM port of the SBC2000-074 to the terminal.
PRINT "Hello World", a, b
If you are using an SBC2000-062, PRINT statements are automatically PIPEd to the LCD. The LCD_COMMAND(128) statement will return the cursor to the home position of the LCD.
Beware of ESDModern technology has not solved the electrostatic discharge (ESD) problem. Electrostatic discharge can be disastrous to the integrated circuits on your Single Board Computer (SBC).
To prevent ESD damage you must:
• Always work with your SBC in an ESD-proof area.
• Ground your workbench and yourself before touching the board.
Your final product should also be made ESD safe. For example a common source of static electricity is through the keypad, because the keypad is one part of the system that is exposed to the outside world.
You can prevent electrostatic discharge through the keypad with a ground plane above the keys to short any ESD or sufficient insulation to prevent ESD from entering the SBC.
Likewise, if other components of your project may be exposed to electrostatic discharge, you must take steps to ensure that the ESD cannot reach the SBC.
You may have purchased Vesta Single Tasking Basic separately or as part of a Development kit. If you purchased, a Vesta Development kit, you already have everything you need to get started programming your SBC.
Vesta development kits come with the SBC, the Software a battery pack, an LCD and LCD cable, and a "Dev" cable. The Dev cable provides the serial connection between the SBC and your PC. The SBC2000-074 kit also comes with a keypad.
If you purchased only the SBC and Vesta Single Tasking Basic, you may still need a battery pack, and the Dev cable before you can get started. An LCD and keypad are also very useful components but not really necessary.
If you have all the parts you need:
1) Find a static-free workplace and ground your self.
2) Remove the SBC2000 from its protective packaging and set it on a non-conducting surface.
3) Connect the Dev cable's standard D-sub connector to the COM port on your PC, and connect the 3-pin side to the connector marked "DEV" on your SBC.
4) Connect the 4-pin connector from the battery pack to the connector marked "PWR" on your SBC.
1) Insert the Vesta Single Tasking Basic CD into your CD Drive.
2) Choose RUN from the START menu.
3) Enter "D: \setup" in the text box (change the "D" to the drive letter of your CD drive).
4) Follow the prompts for installation.
5) Read the README.TXT file for information on new features, fixes, known anomalies, and update history.
When the installation is complete, you will have a subdirectory called \Program Files\VSTBasic2 on your PC. In that subdirectory will be the compiler, the Vesta Basic IDE, and some support files. There will also be a subdirectory named \Projects, which is a default storage area for applications.
The \Manuals and \Examples directories are not automatically installed on your PC. If you want them there, you will need to copy them from the CD.
Hard copy manuals may also be ordered separately from Vesta Sales (303)422-8088. You can also get updated information from our web site, www.vestatech.com.
If the Vesta Basic CD is in the drive, you can get to the application examples using File|Open and selecting your CD drive from the "Look in" listbox.
Vesta Basic is designed to promote structured programming. Structured programming is not just an enviable goal for the programmer to achieve—it is today's standard for design methodology. The benefits of structured programming are important:
• Your code will contain fewer bugs.
• Your code will be easier to test.
• Your code will be easier to document.
• Your code will be easier to maintain.
Structured programming begins with a logical partition of the complex, global program into smaller, less complex, logical units. Each of these smaller code constructs requires less "mental gymnastics" on your part.
To limit a module's complexity:
1. Require no more than five mental objects to understand the block of code.
2. Have blocks of code no more than 40 lines long.
Dividing a program into small code modules encourages the programmer to design the program, rather than immediately programming without a solid plan.
Vesta Basic supports modular subdivision within the following programming constructs:
• Named Functions
• Named Subroutines
Traditional BASIC programs often have been criticized for over-dependence on GOTO. In fact, Vesta Basic has no GOTO statement. The use of predefined control structures reduces the actual and perceived complexity of the source code. There are specific entry and exit points from each control structure. Vesta Basic utilizes the following control constructs in order to ensure unambiguous control flow:
IF ELSE ENDIF
SELECT CASE ELSE
DO WHILE LOOP STEP
DO LOOP UNTIL
RETURN
FOR EXIT NEXT
ENDSELECT
Procedure orientation is the final component which enables structured programming. Vesta Basic divides procedures into two categories: functions and subroutines. Functions return a value that may be used as part of a calculation or a variable. Subroutines do not return a value. Vesta Basic allows named functions to be called and the results assigned directly to variables.
The interface between the main procedure and its underlying procedures is carefully controlled by the declaration of data that may or may not be shared.
Coding style is another important aspect of creating bug free, documented and maintainable code.
The first step in creating clear code is to choose meaningful names for variables, functions and subroutines. Vesta Basic supports variable names of up to 30 characters in length.
Another style consideration is the use of upper- and lowercase letters in naming variables. Vesta Basic does not differentiate between upper- and lowercase characters for variable names, procedure names, or keywords. This manual denotes keywords in uppercase letters. Programmer-defined variables and procedure names are in lower case.
Documenting the program while you are designing, entering and debugging is easy and productive. Use remarks to record the guidelines for what the code module is intended to accomplish. (Keep in mind that these comments will be useful after you have forgotten how this code operated!)
Indenting your source code is another important aspect of good coding style. Control structures are easy to visualize when source is indented at each level. Compare the following two code modules:
Don't Do This:
FOR I=1 TO 9:PRINT i:if I=5:PRINT
"five":ENDIF:NEXT
Do This:
FOR
index=1 TO 9
PRINT index :REM print the outer loop
index
IF index=5
PRINT
"five" :REM if index is 5, print "five"
ENDIF
NEXT index
A Vesta Basic program can be organized into five sections.
Section 1 contains remarks describing the program's purpose.
Section 2 procedures, arrays and forward procedure declarations.
Section 3 contains all function, subroutine, local and static variable declarations.
Section 4 is comprised of all the global variable declarations.
Section 5 begins with the first executable statement and is considered the main procedure.
Section 1
REM The structure of a Vesta Basic program
REM A description of the program
Section 2
REM Declare forward Reference here
DECLARE x AS INTEGER ARRAY
Section 3
REM The second section defines any
REM subroutines and functions
FUNCTION zero () AS INTEGER
zero=x [0]
END
FUNCTION value (num AS INTEGER) AS INTEGER
value=num
END
SUBROUTINE report (num AS INTEGER)
PRINT num
END
Section 4
REM The third section is for global
REM variable declaration
GLOBAL index AS INTEGER, sum AS INTEGER
Section 5
REM the main routine starts here with the
REM first executable statement. Certain
REM statements such as procedure
REM definitions and global variable
REM declarations cannot occur after this
REM first executable statement.
FOR index=0 TO 2
SELECT index
CASE 0
sum
= zero()
CASE ELSE
sum = value(index)
ENDSELECT
report(sum)
NEXT
The Integrated Development Environment
To invoke the Vesta Basic IDE, use the Windows Start Bar to select Programs|VSTBasic2|Vesta Single Tasking Basic, or click the Vesta Single Tasking Basic icon.
Use Tools|Serial Port to select the COM port that the IDE will use to communicate with the SBC.
You may select the COM port that you intend to use or you may select "none" for now. Selecting none will enable you to write and compile code, but you cannot download it into an SBC2000.
With the Vesta Single Tasking Basic CD in
the drive, you can select File|Open Task and navigate to the
D:\Examples\Vesta ST Basic folder to see the sample code that we provide
(substitute the drive letter of your CD ROM drive).
The \Examples directory contains two subdirectories.
\Vesta MT Basic - Contains examples that are specific to Vesta Multi Tasking Basic and the SBC2000-188 and SBC2000-332. You may want to look at these examples to see what our multi-tasking engines can do or to get programming ideas. However, please don't try to compile and download these examples to your single tasking board; they won't work.
\Vesta ST Basic - Contains examples that are specific to Vesta Single Tasking Basic and the SBC2000-062 and SBC2000-074.
The \Vesta ST Basic directory contains the following subdirectories:
\Applications - Examples of applications.
\Keywords - Contains examples that
illuminate the use of Vesta keywords.
\Peripherals - Examples using different peripheral boards.
\VSTB Extensions - Examples that demonstrate the use of some
of the on-board features of your SBC2000.
Please spend some time browsing around these examples, you'll find a gold mine of information.

1)
Put the Vesta Basic CD is in the drive.
Choose File|Open and select your CD drive from the "Look in"
listbox at the top of the window.
Double click \Examples, \Vesta ST Basic, then \Keywords, then the
\Dowhile directory. Then double click
the Dowhile0.txt file to open it.
2) Double click on the word "index" in the first line, then double click the watch variables button (that looks like two eyes opened wide) on the tool bar, and click OK in the window that comes up.
The Watch Variables Window will pop up; This is where the variable values will appear when the program is running. If it's not in a convenient place, move it to the side, off the IDE window so that you can see it and the Task window at the same time.
3) Because this text was read from the CD drive, we need to save it to the hard drive before we continue. You don't have to do this step if the file was read from your local hard drive. However, keep in mind that the compiler will save the current changes to your program each time you compile it.
Select File|Save As, and navigate back to C:\Program Files\VSTBasic2\Projects, and click the Save button (feel free to rename the file first).
4)
Now click the Go button. A progress window will pop up for a minute
and then disappear.
Your task has just been linked, and compiled, downloaded, and reset. This is the point where you would have been alerted if there had been any errors in the code.
5)
Now click the Step button a several
times. You'll see the highlight cycle
around each line of code as it is executed.
Now click the Step button a few times slowly, and watch the
variables in the Watch Variables Window as they change.
6) It only takes 30 clicks before this little program runs out of things to do. It will stop on the last executable line, which in this case is the DO WHILE index line.
If you want to get out early, click the Stop
button, to halt execution of the task.
Polling will continue and the Heart icon in the upper left corner will
continue to flash. You can turn off
polling by selecting Tools|Debugger, then Disable Polling.
Open Task
Save Task
Cut
Paste
Copy
Find
Next
Add Watch
Delete Watch
Restart Monitor
Test Link
Go
Stop
Step Task
Animate Task
Continue Task
Reset Task
Stop Autostart
The File|Open command opens any .TXT file.
The File|Save command saves the source code. If the program is not yet named, it will be saved under the default name, program.txt. Programs are also saved when compiled.
This command saves a program under any filename in any subdirectory.

This command allows you to print the text of a program.
Exits the Vesta Single Tasking Basic IDE and returns to the Windows desktop.
The Edit menu commands are standard Windows commands. These commands can also be invoked using the traditional Windows keystrokes:
^X Cut
^C Copy
^P Paste
^Z Undo
The IDE Task Editor also provides some fancy features such as drag-and-drop text, double-click to select a word and triple click to select a line.
Edit|Find searches the source code for a specified string.

Edit|Find Next searches for the next occurrence of the last string specified with Edit|Find. It is not available until you have already searched for a string with Edit|Find.
Tools|Serial PortUse Tools|Serial Port to select the serial port that is connected to the DEV port on the SBC.
The baud rate and connection settings are determined by the capacity of the SBC that is connected to the Dev Port.
Click the Test Serial Link button to verify that the SBC is connected to the PC or to re-establish communications with the SBC if the link has gone down.
From the Serial Port Settings window, you can
click the View Button under IDE/SBC Transactions to view the status of
communications between the SBC and the Vesta Basic IDE.
TO SBC 2000 and Transmit Buffer show what the IDE sends to the SBC.
Transmit Keystrokes - provides an entry area where you can type characters that you would like to send to the SBC.
Keystrokes Received and Receive Buffer - show keystrokes that have been sent to the IDE.

The SBC2000-074 and the SBC2000-062 use different processors and have different memory configurations.
The IDE will detect the SBC2000 model connected to your PC before download and set the compiler to match. If no SBC is connected at power-up, you will be asked to enter the revision level of the SBC you expect to be using. However, if you connect and power up a different board, the IDE will detect it, and change this setting automatically.
The
default memory configuration provides more memory for stack space than for
Global Storage. Vesta Basic allows you
to override this configuration for programs that use very little stack space,
but need more Global space than is provided by default.
By default, the stack and global storage areas are separate and isolated from each other. By overriding this configuration you may expose your program to possible errors caused by stack data encroaching upon variable data space. Therefore this setting is disabled by default and must be reset each time the IDE is invoked.
See "Using the Stack as Variable Space", on page 44 for more information on using the Allow Variables to Overflow Stack Space setting.
You must set the correct size EEPROM. The system cannot determine this. If your program exceeds the space available, a “code limit exceeded” error message will appear.
If you specify a size that is larger than the EEPROM on your system, you could end up downloading a program that is larger than your EEPROM and will not run.

This dialog box shows the currently selected polling rate and whether or not programs will be compiled with full debug capability.
The poll rate determines how often the PC communicates with the SBC2000. If you are watching variables or animating, the polling rate should be set high. If your application is compiled without debug, disable polling or the IDE will complain that the SBC2000 is not responding.
Vesta Basic runtime errors are reported to the IDE when the SBC2000 is polled, so turning off the polling will cause the IDE to cease reporting errors. When the polling is disabled, animation and variable watch is also disabled. However, you can still highlight a variable and press Ctrl-W to find its value.
Polling the Basic Monitor affects the execution speed of Vesta Basic to a small degree. When your application is finished, there will be no IDE connected, so for final application speed testing and fastest execution, disable polling.
If you get a message that says “SBC2000 is not responding”, try cycling power to the SBC2000.
Compiling with debug allows the program to respond to polling and other program control commands issued by the IDE (stop, animate, step, etc.).
If you compile without debug:
· The program will run 5 to10% faster.
· You will have no program control via the IDE.
· Approximately 800 more bytes of EEPROM will be available for program storage.
·
A
few (4 on -074) more bytes of RAM will be available for global and static
variable declarations.
· You must use Debug|Stop Autostart to regain control.

The debugger is nothing more than an ON COM1 subroutine added to your program that gains control of the program whenever characters are received from the IDE through the DEV port. You can examine this subroutine by looking at the program text in MON74.TXT or MON62.TXT. If you change it, you will have to re-install Vesta Basic to recover the original version.
Select Disable Debug if you use the DEV port for anything other than the IDE connection.
The Reboot SBC2000 command will send a reboot command to the SBC2000. This will cause the Vesta Basic execution engine to jump to the reset vector as though a power on reset or hardware reset had taken place.
Stop AutoStart will suppress the
AutoStart function of the SBC so that the SBC can be restarted without
automatically passing control to the application in EEPROM. This command is required when an application
is compiled without debug.
This command will erase the program in EEPROM.
The Go command compiles and downloads the current task (if not already downloaded in its unmodified form), resets the program pointer to the beginning of the new task and starts the task executing.
Mousing around or switching to another program during the download process can cause a packet error and require power cycling the SBC2000. If the progress bar appears particularly slow, a packet error may have occurred. Abort the transfer and cycle power to the SBC2000.
You can edit your source code while the program is executing. Obviously, if you change your source code and then invoke animation, the IDE may highlight the wrong line of source code.
The Go button performs that same
function as the Debug|Go menu option.
The Stop command stops execution of
the current program. The Stop
button performs the same function as the Debug|Stop menu option.
This menu selection will compile the source code according to the information in Tools|Compiler but not attempt to download it into the SBC. To compile and automatically download, and execute your program, use Debug|Go.
This command executes the currently highlighted line of Vesta Basic code.
The Step button performs that same
function as the Debug|Step menu option.
This command highlights and executes lines of
code. The rate of animation is
controlled by the Poll Rate setting in the Tools|Debugger dialog
box.
The Animate button performs that same function as the Debug|Animate menu option.
This command executes the current task from
where it was last stopped.
The Continue button performs that same function as the Debug|Continue menu option.
This command resets the current program
pointer to the start of the task.
The Reset button performs that same function as the Debug|Reset menu option.
This command invokes the Add Watch Variable dialog box, which allows you to add variables to the list in the Watch Window. Variables entered into the Watch Window will be monitored during execution.
Highlight a variable by double clicking on it, then invoke ADD WATCH, or press the ADD WATCH button. The variable will appear automatically in the watch window.
Variables are updated every time the SBC2000 is polled. The value of a variable may be changed by stopping the application and entering a new value into the watch window. A carriage return sends the new data to the SBC2000.
You can watch elements of an array that are specified by constant indices, but you cannot watch array elements with variable indices.
The rate at which these variables are updated
depends on the Poll Rate set with the Tools|Serial Port command.
The Add Watch button performs that same function as the Debug|Add Watch menu option.
This command removes variables from the watch
window. Variables can be deleted
directly from the watch window by highlighting the variable and pressing the
delete key.
The Delete Watch button performs that same function as the Debug|Delete Watch menu option.
This command allows you to change the value of a variable in the Watch Window Enter the new value followed by the enter key. The modified value is sent to the SBC2000.
STOP the program before you MODIFY WATCH for best results.
This command toggles the toolbar on and off.
The toolbar may be modified by double clicking on any blank area of the toolbar.

This command invokes a window showing the resources used by the program after the last compilation.
This report shows the amount of RAM usage, amount of EEPROM program space used by the entire program, amount of EEPROM space used by the debugger and the amount of EEPROM space used by arrays.
Run time errors are reported to the IDE error status window.
You cannot edit the source code while viewing error status.
If you have assigned an On Error handler in your program, do not use View|Error Status. The two error handling routines will produce unpredictable results as they fight over which routine will handle the error.
Online Help is an online version of the Vesta Single Tasking Basic manual.
The Help|About Vesta Basic tells you some important information such as the version of the Basic IDE you are running and our Tech Support e-mail address.
The System Info button tells you interesting details about the system PC on which Vesta Basic is running.