home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Black Box 4
/
BlackBox.cdr
/
progbas
/
asic301.arj
/
ASIC.DOC
next >
Wrap
Text File
|
1991-09-28
|
246KB
|
8,317 lines
+--------------------------------------------------------------------+
| |
| A S I C 3.01 |
| |
| "Its Almost Basic" |
| |
| |
| Copyright 1991 |
| by |
| David A. Visti |
| |
| All Rights Reserved |
+--------------------------------------------------------------------+
| ASIC 3.01 is provided as shareware. Under the shareware concept, |
| you can test a program before you buy it. If you find it suitable |
| for your needs and make use of this program, you are expected to |
| send a $10 registration fee. |
| |
| Feel free to distribute this software to others. However, you |
| may not charge for the distribution of this software to others |
| nor may you alter the software or this documentation. |
| |
| Registered users of any version of ASIC will receive a diskette |
| containing the current version of ASIC, plus may purchase future |
| updates at half of the normal registration price. A printed |
| manual is available to registered users for an additional $10.00. |
| |
| For further ordering information, please see the file ORDER.FRM, |
| included with ASIC. |
+--------------------------------------------------------------------+
| |
| Please send registration fees and suggestions to: |
| |
| David Visti |
| P.O. Box 2952 |
| Raleigh, NC 27602-2952 |
| |
| Please mention the version of ASIC in any correspondence |
| (This is ASIC Version 3.01) |
+--------------------------------------------------------------------+
| I can also be reached for questions/comments on GEnie and |
| Compuserve via EMAIL: |
| |
| Compuserve 73065,1302 |
| GEnie D.VISTI |
| |
+--------------------------------------------------------------------+
| |
| DISCLAIMER: This software is provided "as is" without warranty |
| of any kind. In no event shall I be held liable for any damages |
| whatsoever arising from the use of or inability to use this |
| product. |
| |
| Your registration fee entitles you to use this software on a |
| single computer. Site licenses are available, write for details. |
+--------------------------------------------------------------------+
A S I C
Table of Contents
Chapter Title
1. Getting Started Page 3
2. Tutorial Page 5
3. Integrated Editor/Compiler Environment Page 11
4 Using the Debugger Page 22
5. Stand-alone Compiler Options Page 30
6. Language Elements Page 33
7. Keyword Reference Page 39
ABS Page 39
ASC Page 39
BEEP Page 40
BLOAD Page 41
BSAVE Page 42
CALL Page 43
CHDIR Page 44
CHR$ Page 45
CLOSE Page 45
CLS Page 46
CODE Page 46
COLOR Page 47
COMMAND$ Page 48
COMSTAT Page 49
CSRLIN Page 50
DATA Page 51
DATE$ Page 52
DEFSEG Page 52
DIM Page 53
END Page 53
ENVIRON$ Page 54
FILEPOS Page 55
FIND Page 57
FOR/NEXT Page 59
GETDIR Page 60
GOSUB Page 61
GOTO Page 61
IF/THEN/ELSE/ENDIF Page 62
INKEY$ Page 64
INP Page 64
INPUT Page 65
INPUT# Page 66
INSTR Page 68
INT86 Page 69
KILL Page 71
LCASE$ Page 71
LEFT$ Page 72
LEN Page 72
LOCATE Page 73
LPRINT Page 73
LTRIM$ Page 74
MID$ Page 74
MKDIR Page 75
Page - 1
Table of Contents (Continued)
Chapter Title
7. Keyword Reference (Continued)
MOD Page 75
NAME Page 76
OPEN Page 76
OPENCOM Page 77
OUT Page 78
PEEK Page 78
POINT Page 79
POKE Page 80
POS Page 80
PRESET Page 81
PRINT Page 81
PRINT# Page 82
PSET Page 84
RANDOMIZE Page 84
READ Page 85
RECEIVE Page 86
REM Page 87
RESTORE Page 87
RETURN Page 88
RIGHT$ Page 88
RMDIR Page 89
RND Page 90
RTRIM$ Page 91
RUN Page 92
SCREEN Page 93
SEND Page 94
SOUND Page 94
SPACE$ Page 95
STR$ Page 95
STRING$ Page 96
TIME$ Page 97
TIMER Page 98
UCASE$ Page 99
VAL Page 99
VARPTR Page 100
WHILE/WEND Page 100
WIDTH Page 101
ZBIT Page 101
ZMODE Page 102
8. Compatibility with BASICA/GWBASIC Page 103
9. Technical Details/Tips Page 106
10. Error Messages Page 111
Page - 2
A S I C
Chapter 1
Getting Started
INTRODUCTION
Welcome to ASIC!
ASIC is a "BASIC" programming language compiler for IBM PCs and
compatibles. It includes an integrated full screen editor, from which
you can edit, compile, and debug your programs. Or at your option, you
can use your own text editor, and compile your programs from the MS DOS
command line.
ASIC is a subset of BASICA and GWBASIC which supports over 80 BASIC
statements, integer and string variables, and integer arrays. It will
compile your programs at high speed, and the code it generates is fast
and compact. The syntax of each ASIC statement is generally a valid
subset of the syntax used by BASICA and GWBASIC (exceptions are noted in
Chapter 8.)
All you need to get started is:
1) ASIC
2) IBM PC or 100% Compatible
3) 305-405k Available Memory*
4) Two floppy disk drives
<or>
One hard disk drive and one floppy disk drive
The first step is to install ASIC as described below. Then,
proceed to Chapter 2 for a brief ASIC tutorial. Following that you can
read the remainder of the documentation straight through, or refer to it
as you need it. Have Fun!
* The ASIC Compiler will run in 305k of memory. The ASIC Editor
will run in less than 200k of memory, however, to compile and
debug within the editor, 405k of available memory is required.
If ASIC does not find sufficient memory to call the compiler
from within the editor, it will ignore the compile
request and return to the editor.
Page - 3
INSTALLATION
To install ASIC execute the following commands as appropriate for your
machine. The procedure to do so is provided below for both floppy
systems and hard disk based systems. Also refer to the README file on
your ASIC Diskette for additional information.
TWO-FLOPPY DISK SYSTEM INSTALLATION
1) Make sure that the following files are all on the same diskette (the
diskette that contains these files will be referred to in this manual as
the "Compiler" diskette):
ASIC.EXE
ASICC.EXE
ASIC.IDX (Optional)
ASICM.IDX (Optional)
ASIC.DOC (Optional)
(Note: The optional files are required if you wish to use the
extended online help feature).
2) Format one or more blank diskettes to hold your programs (these
diskettes will be referred to in this manual as your "Program"
diskettes):
Note: Whenever you see the symbol <enter> in this
document, this refers to the <enter> or <return> key
on your keyboard.
HARD DISK SYSTEM INSTALLATION
1) Type: C: <enter>
2) Type: MD C:\ASIC <enter>
3) The next step is to copy the ASIC software to the ASIC directory.
If your ASIC software is on a floppy, insert the floppy in Drive
A: then type the command:
COPY A:*.* C:\ASIC <enter>
If your ASIC software is already on a hard disk directory, copy
it to the ASIC directory with the command:
COPY C:\directoryname\*.* C:\ASIC <enter>
Note that ASIC will run from any subdirectory, however, the
tutorial assumes ASIC is under C:\ASIC
Note: Whenever you see the symbol <enter> in this
document, this refers to the <enter> or <return> key
on your keyboard.
Page - 4
A S I C
Chapter 2
Tutorial
ASIC programs look very much like regular "BASIC" programs which you are
probably already familiar with. The one very noticeable difference is
that ASIC programs have no line numbers. Let's take a look at a very
simple program written both in GWBASIC/BASICA and in ASIC:
GWBASIC/BASICA ASIC
--------------------------+----------------------------------
|
10 I=I+1 | ADDONE: I=I+1
20 PRINT I | PRINT I
30 IF I<100 THEN 10 | IF I<100 THEN ADDONE:
--------------------------+----------------------------------
Both of these programs do the same thing. They display the numbers
from 1 to 100. However, notice that ASIC allows you to use descriptive
labels (ADDONE) instead of a line number (10). These labels can be up
to 80 characters long! Also note that the ASIC "PRINT" and "IF"
statements were indented only for increased program readability. The
ASIC program could just as well have been written as:
ASIC
------------------------------
ADDONE:I=I+1
PRINT I
IF I<100 THEN ADDONE:
------------------------------
We could have made our variable names longer. Instead of "I" we
could have chosen "SECONDS" or "VELOCITY", or some other name up to 80
characters in total. In ASIC, variable names, labels, and string
constants can all be up to 80 characters in length.
Well, now that we've seen a basic ASIC program, let's try to enter
and run a slightly larger program. The program we will be working with
will print the message "HELLO yourname" in 256 color combinations. If
you have a monochrome display card, don't worry, the program will work,
but instead of seeing different colors you'll see characters with
different attributes, such as blinking, underlined, etc.
Let's get started. If you haven't done so already, install ASIC as
described in Chapter 1. Now then, writing an ASIC program involves
these three steps.
1. Write your program.
2. Compile your program.
3. Run/Test your Program.
Page - 5
These three steps can all be performed from within the ASIC
Integrated Environment. Before we proceed with our "Hello yourname"
Program, let's go over some conventions.
In the following section:
FLOPPY TYPE--> Means that only 2-floppy disk system users
should type this line.
HARD TYPE--> Means that only hard disk system users
should type this line.
TYPE--> Means that both floppy and hard disk users
should type this line.
X> This is a representation of the prompt from
PC-DOS or MS-DOS. Floppy Disk Users will
actually see "A>" for a prompt. Hard Disk
Users will see "C>" for a prompt.
<enter> Means that you should press the <enter>
or <return> key on your keyboard.
<?> Text enclosed between the "<" and the ">"
symbols indicate a key to type. Don't type
the "<" or ">" symbols. For example, if the
tutorial lists "<F1>", your should press the
"F1" key on your keyboard.
NOTE: Floppy Disk users need to insert their ASIC Compiler diskette in
Drive A: at this point, and a Program diskette in Drive B: (See the
Installation section for more information)
Let's begin:
FLOPPY TYPE--> A: <enter>
HARD TYPE--> CD C:\ASIC <enter>
The computer should respond:
X>
Now enter the command to invoke ASIC:
TYPE--> ASIC <enter>
You are now in ASIC. The top line is the Menu Bar. The bottom line is
the Status Line. Chapter 3 describes this in more detail. For now,
we'll just describe a couple of features on these lines.
The status line indicates that the current mode is "INSERT". This means
that any characters you type on a line will be inserted between the
existing characters. If you press the <INS> key on the keypad, ASIC
will toggle to its other mode, OVERSTRIKE. In this mode, when you type
Page - 6
a character, it overlays the character that was there before. Each time
you press the <INS> key, ASIC will toggle between the INSERT and
OVERSTRIKE modes.
You can open the menus listed on the "Menu Bar" by holding down the ALT
key while typing the Capitalized letter of the menu you wish to open.
For example, to open the File menu, press <ALT><F>. Try it now:
TYPE--> <Alt><F>
The "File" menu will pop open. You can select a menu option from that
menu by typing the capitalized letter of the option, or by using the
arrow keys on your keypad to highlight the option you want and then
pressing <enter>.
If you are not sure what the menu option will do, you can press <F1> and
ASIC will display some help information for the highlighted menu option.
When you opened the File menu, the first option on that menu, "Open" was
highlighted. Let's get some help on "Open":
TYPE--> <F1>
ASIC will display some help information on "Open". Let's close the help
window now:
TYPE--> <ESC>
The help window will close. The <ESC> key will always let you escape
from any menu or help screen in ASIC, without taking any action. Let's
also close the file menu for now:
TYPE--> <ESC>
The "File" menu should have closed. By the way, in addition to the menu
help, ASIC provides additional online help. If you need general ASIC
help, press the <F1> key for a quick summary of some of ASIC's features:
TYPE--> <F1>
ASIC will display some general help. From this screen, we can also
retrieve additional information about BASIC statements such as PRINT or
GOSUB. Let's bring up an index of these statements.
TYPE--> <F1>
ASIC has opened a help index screen. From this screen we can use the
arrow keys to highlight any ASIC keyword and obtain more information for
that keyword by then pressing enter. We won't do that now, but don't
forget that this screen is available. Chapter 3 of the ASIC Reference
Manual describes all of the online "HELP" features available in ASIC and
provides a full description of the ASIC Editor Commands which are
available. Exit the help menu:
TYPE--> <ESC>
Page - 7
Entering a program in ASIC is simplicity itself. We'll simply type in
each line, pressing <enter> at the end of each line. If you make a
typing mistake, just use the arrow keys to move to the error, and type
in the correction. Use the <DEL> or <Backspace> keys to delete any
unwanted characters from the screen.
Make sure the status line says "Mode: Insert". This is the default mode
in ASIC. If it doesn't, press the <INS> key until it does. Now let's
enter our program (the program below intentionally contains an invalid
ASIC statement. We'll correct the line later in the tutorial, for now,
type in the program exactly as it's listed below):
TYPE--> CLS <enter>
TYPE--> PRINT "Please enter your name"; <enter>
TYPE--> INPUT YOURNAME$ <enter>
TYPE--> FOR I=1 TO 16 <enter>
TYPE--> FOR J=1 TO 16 <enter>
TYPE--> COLOR I,J <enter>
TYPE--> PRINT "HELLO "; <enter>
TYPE--> PRINT YOURNAME$; <enter>
TYPE--> NEXT J <enter>
TYPE--> NEXT I <enter>
TYPE--> CLS <enter>
TYPE--> THE END <enter>
There, that was easy. Now, let's compile our program. To do it, we'll
open the "Compile" menu, and select the "Compile program" option:
TYPE--> <ALT><C>
The "Compile" menu will pop open. The first option, "Compile program"
can be selected by typing the option letter which is capitalized "C", or
by moving the highlight bar to this option and pressing the <enter> key.
Since the highlight bar is already on this option, let's just press
<enter>:
TYPE--> <enter>
Since we didn't specify a file name when we invoked ASIC, ASIC will now
ask for a file name (so it can save your program before calling the
compiler):
FLOPPY TYPE--> B:TUTOR.ASI <enter>
HARD TYPE--> TUTOR.ASI <enter>
Note that ASIC requires that your programs be stored in files ending
with the extension ".ASI". Had we entered "TUTOR" for our program name,
ASIC would have appended the letters ".ASI" for us. If we tried to
provide a different extension, such as "TUTOR.SRC", ASIC would display
an error message. Also, whenever you are presented a dialog box where
you are asked to enter text (such as file name, or Yes/No responses to
questions), you must press the <enter> key before ASIC will accept the
input.
Once you select the "Compile program" option, you'll see the ASIC
compiler screen appear. It will display a count of the lines compiled,
and when it is done, it will return to the ASIC editor.
Page - 8
If it detected any errors, it will display the first error message at
the bottom of the editor screen. It will also highlight the line in
your program which is in error. In this case the line "THE END" was
flagged with the error message "Syntax Error". Of course, that line
should have been entered simply as "END".
That should be easy enough to fix. Let's exit the error menu by
pressing the <ESC> key:
TYPE--> <ESC>
The error menu has disappeared, and our cursor is now on the erroneous
line. To fix the line:
TYPE--> <DEL><DEL><DEL><DEL>
That should do it. The last line of our program should now read "END".
Before we continue, let's assume we new the name of the END command, but
could not remember the proper syntax for it. ASIC provides an online
lookup for each ASIC statement. With the cursor positioned somewhere on
the word "END":
TYPE--> <Ctl><F1>
ASIC should have opened a help window describing the "END" statement.
To return to your program press the <ESC> key.
TYPE--> <ESC>
The help window should have disappeared and you should see your program
displayed again. Let's recompile the program:
TYPE--> <ALT><C>
TYPE--> <enter>
This time you should see the message "No Compiler Errors". If you
didn't, check your spelling and recompile the program until you receive
this message. Press <ESC> to remove the "No Compiler Errors" Window.
Now let's run the program. To do so, we'll open the "Run" menu, and
select the "Run your program" option.
TYPE--> <ALT><R>
TYPE--> <r>
This time, we just entered the capitalized letter from the menu option
"Run your program". Your computer screen should now prompt you to
"Please enter your name?". Go ahead and enter your name now:
TYPE--> yourname <enter>
You should see "HELLO yourname" printed in various color combinations,
and then the ASIC editor screen will reappear. Well, that's all there
is to writing, compiling, and running an ASIC program. Now, to exit
ASIC, open the "File" menu and select the "eXit" option.
Page - 9
TYPE--> <ALT><F>
TYPE--> <X>
You should see your MS DOS prompt once again. By the way, now that
you've successfully compiled the program, you can execute it directly
from MS DOS. Let's try it:
HARD TYPE--> TUTOR <enter>
FLOPPY TYPE--> B:TUTOR <enter>
Well, that's a brief introduction to ASIC! Next, you might want to read
Chapter 3, "Integrated Editor/Compiler Environment" to learn about the
many other features available in the ASIC editor. Following this you
should read Chapter 4 which explains how to use the ASIC Debugger.
Chapter 4 includes another short tutorial in which you debug a program.
The remaining chapters provide reference material which you can
either read, or just refer to as needed. Chapter 5 explains how to
compile programs directly from the command line of DOS. Chapters 6-8
describe the BASIC statements which are supported by ASIC. Chapter 10
provides more descriptive information for ASIC error messages.
Hope you enjoy programming in ASIC!
Page - 10
A S I C
Chapter 3
Integrated Editor/Compiler
Environment
INTRODUCTION
The ASIC integrated environment lets you edit, save, compile, and
debug your ASIC programs without ever leaving ASIC! This chapter will
explain the usage of the integrated environment.
ASIC SCREEN CONTENTS
ASIC divides the screen into three parts. The top line is called
the "Menu Bar". All of the menus available to you are listed on this
line. The bottom line is called the "Status Line". It continuously
displays some important program information. The middle 23 lines are
the "Edit Window". This is the section of the screen where you can make
changes or additions to your program.
MENU BAR PROCESSING
Currently, there are four menus available. The "File" menu allows you
to load/save your existing program files to/from disk. It is also used
to exit ASIC. The "Edit" menu contains various editing commands which
are available. The "Compile" menu is used to compile your program, set
compiler options, and to view compiler errors. The "Run" menu allows
you to run your programs, and test them using the ASIC debugger.
To open a menu, hold down the <ALT> key and type the first letter
of the menu. The menu will pop down and display the options available
on that menu. If you want to close the menu without taking any action,
press the <ESC> key. If you wish to open a different menu without first
closing the current menu, press the left or right arrow keys.
Otherwise, to select an option, type the capitalized letter of the
menu option. For example, on the "File" menu, to select the "eXit"
option, type an "X" or an "x". Another way to select an option is to
move the "Highlighted Bar" down to the option you wish to select, and
press the <enter> key.
Some functions may be accessed outside of the menus with function
keys. These are listed on the menus (eg. "search Again <F3>" on the
Edit Menu), however, these function keys do not operate when a menu is
open. (A list of these Function keys is presented later in this chapter
in the Keyboard Usage Section).
Page - 11
GETTING HELP
ASIC provides "online" help within the integregated environment to
assist you with keyboard usage, menu options, and ASIC keywords. This
section tells you how to access this online help.
General Help
General describes the usage of the keyboard in ASIC. Keyboard keys
which perform ASIC functions are described in this section. Access
general help by pressing Function key <F1>. Pressing <F1> a second time
will display an ASIC keyword index. You can get additional help on
individual ASIC keywords from this screen. This information includes a
description of what the keyword does, and the keyword syntax.
Menu Help
If you open a menu, but you are not sure what a certain menu option
does, you may display a description of the highlighted menu option by
pressing the <F1> key. Doing so will open a help window which describes
the menu option. Press <ESC> to exit the help screen and return to the
menu.
Keyword Help
Can't remember the syntax for a particular ASIC keyword? Well, help is
just a keystroke away. Position the cursor on the keyword in the edit
buffer. Then, hold down the <Ctl> key and press the <F1> key.
ASIC will display a description of the keyword, and describe proper
syntax for that keyword. For example, if you tried to compile a
program, but received a syntax error on the keyword "PRINT" in your
program, you could obtain help on the "PRINT" statement by using the
arrow keys to position the cursor anywhere on the word "PRINT" and then
pressing <Ctl-F1>. If ASIC cannot find the keyword (eg, say the cursor
was positioned on a variable called "APPLES", which is not an ASIC
keyword), then ASIC will display a list of valid keywords. Use the
cursor keys to highlight one of these keywords and press <enter> to
retrieve help for the highlighted keyword. You may also access this
keyword help list by pressing the <F1> key twice from within the editor.
Now let's describe the options available on each menu.
FILE MENU
"Open" Option
This option allows you to open an existing ASIC file and load it
into the ASIC edit buffer where you can modify it. If you select this
option another window will open to ask you the file name. If you don't
wish to open a file, you can press <ESC> to close the menu without
taking any action. Otherwise, enter an ASIC file name, and press the
<enter> key.
Page - 12
FILE MENU (Continued)
"Save" Option
This option allows you to write the changes you've made to your
program back to the file. Changes you enter in the ASIC editor are made
to memory only. You must select this option before your changes will
become permanent. Note: Your file is saved to disk automatically
whenever you compile it or run it, if the file modified indicator is
set.
"save As" Option
This option will allow you to write the changes you've made to the
program in the edit buffer to a new file. You will be prompted to
provide ASIC with a new file name.
"eXit" Option
This option will allow you to exit from ASIC back to MS DOS. ASIC
will ask you if you wish to save your file before you exit.
EDIT MENU
"Begin block" Option
This option will allow you to mark the beginning of a block of text
for use with the block delete, copy, and move commands. To mark a block
of text, move the cursor to the first line of the block, and then select
this option. The beginning line of the block will be highlighted on the
screen. Next, move the cursor to the ending line of the block, and
select the "End block" option from this menu. All of the lines in the
block will be highlighted. This block of lines can now be "moved",
"copied", or "deleted" using the block commands.
"End block" Option
This option will allow you to mark the end of a block of text.
Refer to the "Begin block" Option for more information.
"Search" Option
This option allows you to locate a string of characters in the edit
buffer. When you select this option, ASIC will ask you for a search
string which can be up to 30 characters in length. ASIC will then
search forward from the current line until it finds the string or
reaches the end of the edit buffer. If it finds the string, the cursor
will be placed on the line containing the string.
Page - 13
EDIT MENU (Continued)
"Replace" Option
This option will allow you to replace one or more occurrences of a
string of characters with another set of characters. When you select
this option, ASIC will ask you for a search string which can be up to 30
characters in length. ASIC will then ask you for the string of
characters which is to replace the search string. Finally, ASIC will
ask you to specify how many occurrences of this search string are to be
replaced (from 1-9999). ASIC will search forward from the current line,
and briefly display each line as it modifies it. If it reaches the end
of the edit buffer before it has replaced the number of occurrences
you've specified, ASIC will display an "End of Buffer" message, and
stop.
"Delete block" Option
This option will delete a block of lines. Refer to the "Begin
block" option for information on marking a block of lines. If you
haven't marked a block of lines, selecting this option will have no
effect.
"Move block" Option
This option will move a block of lines to a new location in the
edit buffer. Refer to the "Begin block" option for information on
marking a block of lines. If you don't mark a block of lines, selecting
this option will have no effect. Once you have marked a block of lines,
move the cursor to the location in the edit buffer where you want the
lines moved. Selecting the "Move block" option will result in the block
of lines being deleted from their current location, and moved to the
buffer at the line following the cursor. ASIC will not overlay lines,
it will insert enough blank space to hold the relocated text.
"Copy block" Option
This option is the same as the "Move block" option, with one
exception. After moving the block, ASIC does NOT delete the original
block of lines. Use this option to clone a block of text. Refer to the
"Begin block" option for information on marking a block of text.
"search Again <F3>" Option
This option will allow you to search for the next occurence of the
last string you searched for with the "Search" Option, without retyping
the previous search string. This option may also be selected outside of
the Edit Menu by pressing function key <F3>.
Page - 14
COMPILE MENU
"Compile program <F10>" Option
Use this option to have ASIC compile the program which is currently
loaded in the edit buffer. If the compile is successful, ASIC will
display the message "No Compiler Errors". Otherwise, it will display
the first error message (see "View compile errors" option). ASIC will
automatically save your program before calling the compiler. This
option may also be selected outside of the menu by pressing function key
<F10>.
"Full program listing" Option
This menu option, and the next four options are used to toggle
various compiler options on or off. When the option is on, you will see
a "check mark" symbol next to the option. This compiler option will
cause ASIC to display each source line as it compiles it. This option
will slow down the compile, but since ASIC also writes these lines to a
listing file, this option can be used to create a compile listing. The
compile listing will be contained in a file called "progname.LST", where
"progname" is the name of your program.
"Printer output" Option
This menu option will toggle the "Printer output" compiler option
on or off. When the option is on, you will see a "check mark" symbol
next to the option name. This compiler option will cause compiler
messages to be printed on your printer.
"Symbol table" Option
This menu option will toggle the "Symbol table" compiler option on
or off. When the option is on, you will see a "check mark" symbol next
to the option name. This compiler option will cause ASIC to create a
symbol table file called "progname.SYM", where "progname" is the name of
your program. The symbol table is a list of all variables, labels, and
internally created compiler addresses.
"Extended math" Option
By default, ASIC will permit regular integer variables. These
variables are very efficient and only require two bytes (or characters)
of memory storage. However, these integers can only hold numbers in the
range of -32767 to +32767. For many programs this is sufficient.
However, there may be cases when you want to represent larger integer
values. Because of this, ASIC provides a "long" integer data type. The
long integer requires four bytes of memory storage. However, it can
hold a much larger range of numbers. A long integer can store numbers
in the range of -2,147,483,647 to +2,147,483,647. When you need to use
long integers in your program, you need to turn on this option, so that
ASIC can generate the proper code. If this option is not turned on and
your program contains long integers, ASIC will generate a compiler
error. If this happens, just turn this option on, and re-compile your
program. To "create" a long integer variable or constant, simply append
the "&" character to the variable name or constant value(eg, SAMPLEVAR&
or 123456&). For further information on using long integers, refer to
Chapter 6, "Language Elements", of the ASIC Manual.
Page - 15
COMPILE MENU (Continued)
"Debugging code" Option
This menu option will toggle the "Debugging code" compiler option
on or off. When the option is on, you will see a "check mark" symbol
next to the option name. This compiler option will cause ASIC to
generate code required by the ASIC debugger to allow you to set
breakpoints, single step through your program, and view/modify program
variables. This option is "on" by default in the integrated
environment. You should leave this option on while you are debugging
your program. When you have everything working properly, you should
turn it "off" and recompile your program. This will reduce the size of
your program slightly, and will make it run faster (of course, you can't
use the debugger with it, since there is no debugging information
available to ASIC any more. If you need to debug your program again,
just recompile with the this option turned "on" again).
"View compile errors" Option
When you wish to examine the errors from a previous compile of your
program, select this option. If no errors exist, ASIC will so inform
you. Otherwise, ASIC will display the first error message at the bottom
of the screen, and it will highlight the line of your program which
corresponds to that error. If you wish to correct the program line,
press the <ESC> key. The cursor will be positioned at the beginning of
that program line. You may also view subsequent compiler errors by
pressing the <F10> key instead of the <ESC> key.
"Write options to disk" Option
Normally, when you set compiler options in the integrated
environment, they "exist" only for your editing session (ie, when you
leave the editor, ASIC resets the options to the defaults). If you
prefer, you may use this option to cause ASIC to write the current
session's options to a configuration file (ASIC.CFG). Then, when you
invoke the ASIC integrated environment, it will first check for this
configuration file. If found, it will use your saved configuration.
Otherwise, it will use the ASIC defaults. This configuration file is
not accessed by the command-line version of the compiler, so they only
take affect when you are inside the integrated environment.
Page - 16
RUN MENU
The "Using the ASIC Debugger" Chapter has additional information on
the debugger and it's options. You may wish to refer to it, should you
need more information than is provided below.
"Run your program <F5>" Option
After you have successfully compiled your program, you can select
this option to cause ASIC to load and execute your program. After your
program ENDs, ASIC will return you to the editor. ASIC will save the
edit buffer before loading and executing your program. If you are
running a program containing debugging code, this option will cause ASIC
to run your program up to the first breakpoint it encounters, or through
the end of your program if you haven't set any breakpoints. If you are
already "paused" at a breakpoint, selecting this option will cause your
program to resume execution at the statement following the breakpoint,
and run up to the next breakpoint or to the end of your program, if no
further breakpoints are encountered. This option may also be selected
outside of the "Run menu" by pressing function key <F5>.
"Breakpoint toggle <F9>" Option
If you have compiled your program with the "Debugging code" option
turned on, you may use this option to set breakpoints. You can have up
to 20 breakpoints active at a time. When you run your program with
breakpoints set, ASIC will pause your program when it tries to execute a
line on which you have set a breakpoint. At this time, you can view or
modify variables, or view the screen output produced by your program.
You can then resume program execution by selecting the "Run your
program" option from the run menu. If you select this option and the
current statement in the edit buffer already has a breakpoint set, then
the breakpoint for that source statement will be removed (toggled off).
Lines at which you have set a breakpoint will be displayed in reverse
video. Also, when you run your program and ASIC stops at a breakpoint,
ASIC will display the next line to execute in reverse video on the
second line of the screen with a red background (underlined if you have
a monochrome system). This option may also be selected outside of the
"Run" Menu by pressing function key <F9>.
"Trace <F8>" Option
If you have compiled your program with the "Debugging code" option
turned on, you may use this option to execute your program one statement
at a time. After you select this option, ASIC will execute the next
program statement in your program, and pause, displaying the next line
which will be executed in reverse video with a red background
(underlined if you have a monochrome system). At this time, you can
view or modify variables, or view the screen output produced by your
program. You can then resume program execution by selecting the "Run
your program" option from the run menu, or by selecting the "Trace"
option again. This option may also be selected outside of the "Run"
Menu by pressing function key <F8>.
Page - 17
RUN MENU (Continued)
"Modify variable" Option
If you have compiled your program with the "Debugging code" option
turned on, you may use this option to modify the contents of variables
in your program while your program is paused at a breakpoint or
following a "Trace" command. When you select this option, ASIC will ask
you for the variable name. After you enter the variable name, ASIC will
ask you for the new value to be stored in the variable. If the variable
is an array, ASIC will ask you which element of the array to modify.
"Watch variable <F6>" Option
If you have compiled your program with the "Debugging code" option
turned on, you may use this option to view the contents of variables in
your program, while your program is paused at a breakpoint or following
a "Trace" command. After you enter the variable name, ASIC will open a
"Watch" window at the bottom of the screen showing you the variable name
and the current value. As you continue execution of your program and
reach a new breakpoint, the values of variables will be updated to
reflect their new values. In this way you can watch the changing values
of variables in your program without inserting "PRINT variablename"
statements in your program. Up to 10 variables may be watched at a
time. If you enter a variable name which is an array, ASIC will ask you
which element of the array you wish to watch. This option may also be
selected outside of the "Run" Menu by pressing function key <F6>.
"Unwatch variable <F7>" Option
If you have compiled your program with the "Debugging code" option
turned on, you may use this option to remove variables from the "Watch"
window (see previous option). When you select this option, you will be
asked for a variable name to remove from the window. If the variable is
an array, you will also be asked which element of the array. ASIC will
then remove the variable from the watch window, and resize the window
accordingly. Since only 10 variables may be watched concurrently, you
may need to remove variables which are no longer needed from the "Watch"
Window using this command. This option may also be selected outside of
the "Run" Menu by pressing function key <F7>.
"Abort execution" Option
If you are running your program, and it is paused at a breakpoint,
you may select this option to abort the execution of your program. Your
program will be terminated immediately.
"Clear all break/watch" Option
If you have set breakpoints or watch variable options, you may use
this option to remove all of them at once, instead of removing them one
at a time using the "Toggle breakpoint" or "Unwatch variable" options.
Page - 18
RUN MENU (Continued)
"Program arguments" Option
This option allows you to pass command line arguments to your
programs, which may be retrieved by your program using the COMMAND$
statement. If you are testing outside the integrated environment, you
would normally specify the command line arguments by typing
"progname arguments". However, in the integrated environment, since
ASIC is executing your program for you, this option is a means to pass
the "arguments" to your program as if they had been typed on the command
line following your program name.
"Swap to user screen <F4>" Option
Whenever ASIC pauses your program at a breakpoint, it saves the
screen created by your program in a memory buffer. You may select this
option to view your program screen output. When you are done viewing
your program's output, press a key to return to viewing the ASIC editor.
This function may also be selected outside the "Run" Menu by pressing
the <F4> function key.
STATUS LINE
The bottom line of the ASIC screen is called the "Status Line". As
it's name implies, it is used to display various types of status
information. At the left of the status line "FILE: xxxxxxxx.xxx" will
display the name of the file which is currently loaded in the edit
buffer. If you haven't opened a file yet, the file name will be blank.
After the file name is the "File Modified Indicator". If you have
entered any changes in the edit buffer, and have not saved them to disk,
an "*" will appear to indicate this. If the edit buffer has not been
modified since the last save to disk, no "*" will be present.
The next piece of information is "Mode:". Mode will always display
one of two values: "Insert" or "Ovrstr". In "Insert" mode, any
characters you type in the edit buffer will be inserted at the cursor
position, and the characters to the right of the cursor will be shifted
to the right by one. In "Ovrstr" mode, any characters you type in the
edit buffer will overlay (and thus destroy) the character at the cursor
position. You can change back and forth between these two modes by
pressing the <INS> key on your keypad.
To the right of "Mode:" ASIC displays the number of bytes which it
allocated to the edit buffer. Divide this number by 81 to get a rough
idea of how many lines will fit in the edit buffer.
The "Line: nnnn" status indicator, will identify which line of the
file is being displayed. For example, if the display reads "Line: 100",
the line containing the cursor is the 100th line in the file. When ASIC
is reading or writing your program to/from disk, it will display a
running total of the number of records read/written in this field.
Page - 19
STATUS LINE (Continued)
The "Row:" and "Col:" numbers identify the relative position of the
cursor within the "Edit Window".
EDIT WINDOW
The edit window is the area of the screen where your program is
displayed. It displays up to 23 lines of your program at a time. You
can use the keys described below to manipulate the text in this window.
KEYBOARD USAGE
Most keys on the keyboard behave in ASIC just as you'd expect. The
key usages which might not be obvious are described here.
<ESC> Exit from any menu without taking any action.
<TAB> Move the cursor to the next "tab stop". Tab stops in
ASIC are fixed at every fourth column (4,8,12,etc).
<HOME> Move the cursor to the beginning of the current line.
<END> Move the cursor to the first blank character following
the last non-blank character on the current line.
<DEL> Delete the character at the cursor position.
<INS> Toggle between Insert and Overstrike Modes.
<PGUP> Display the previous "page" of the edit buffer.
<PGDN> Display the next "page" of the edit buffer.
<Ctl-PGUP> Display the first "page" of the edit buffer.
<Ctl-PGDN> Display the last "page" in the edit buffer.
<Backspace> Delete the character to the left of the cursor
position, and move the cursor one column to the left.
Page - 20
KEYBOARD USAGE (Continued)
<Up Arrow> Moves cursor up one line.
<Down Arrow> Moves cursor down one line.
<Left Arrow> Moves cursor left one column.
<Right Arrow> Moves cursor right one column.
<Alt-D> Delete the line containing the cursor.
<Alt-A> Add a line following the line containing the cursor.
<F1> Displays a help screen.
<CTL-F1> Displays help information for the keyword located at
the cursor postion.
<F3> Repeats the last "Search" command. See Edit Menu
Section of this chapter for more information.
<F4> Swaps the display to the output from your program
temporarily. See Run Menu Section of this chapter for
more information.
<F5> Runs your program. See Run Menu Section of this
chapter for more information.
<F6> Add a variable to the "Watch" Window. See Run Menu
Section of this chapter for more information.
<F7> Remove a variable from the "Watch" Window. See Run
Menu Section of this chapter for more information.
<F8> Execute a single statement of your program. See Run
Menu Section of this chapter for more information.
<F9> Toggle breakpoint on/off at the current edit buffer
line. See Run Menu Section of this chapter for more
information.
<F10> Compile your program. See Compile Menu Section of
this chapter for more information.
<enter> In Insert mode, pressing <enter> is identical to
pressing <Alt-A>. In OvrStr mode, pressing <enter>
is identical to pressing the <Down Arrow> key.
Page - 21
A S I C
Chapter 4
Using the Debugger
INTRODUCTION
The source level debugger in ASIC's integrated programming
environment helps you debug your programs by allowing you to "peek"
inside them as they're running. You can single step through your
programs, or select places in the program where you wish execution to
pause by setting breakpoints. Then, while the program is paused, you
can view or modify any of your program's variables, and also examine the
screen output created by your program.
All of the debugger's commands can be selected from the run menu,
and they are described in the "RUN MENU" Section of Chapter 3,
"Integrated Editor/Compiler Environment". Many of the debugger commands
may be selected outside the "Run" menu, by pressing a function key (eg,
<F5>,<F6>,etc). A complete list of the function keys available is
contained in Chapter 3, in the "KEYBOARD USAGE" Section.
This chapter explains how to use the debugger with a short tutorial
which guides you through a sample debugging session. The tutorial is
followed by a reference section which you should read after completing
the tutorial.
DEBUGGER TUTORIAL
The debugger tutorial follows the same format as the general
tutorial in chapter 2. You should complete (or at least review) the
general tutorial before taking the debugger tutorial.
This tutorial will use a program file provided with your ASIC
compiler package called "DBGTUTOR.ASI". If you are running from a hard
disk, make sure it is in the ASIC directory. If you are running from a
two-floppy system, make sure it is on the diskette in drive b:, with the
compiler in drive a:.
NOTE: Floppy disk users should verify that the ASIC compiler diskette
is in drive A: and the "DBGTUTOR.ASI" disk is in drive b: before
proceeding.
Let's get started:
FLOPPY TYPE--> A: <enter>
ASIC B:DBGTUTOR <enter>
HARD TYPE--> C: <enter>
CD C:\ASIC <enter>
ASIC DBGTUTOR <enter>
Page - 22
You should be in ASIC now, and you should see a source program. The
first few lines should contain:
dim scores(10)
data 55,33,877,99,44,101,21,88,105,1
rem DBGTUTOR.ASI
.
. (etc)
.
This sample program will sort an array of 10 scores into ascending
sequence. It uses a simple "bubble" sort algorithm. The "bubble" sort
algorithm simply steps through each element of the array and compares it
to its next higher neighbor. If its neighbor's value is less than its
own, the two values are swapped. It is necessary to execute this
process N-1 times where N= number of items to sort. Here's why. Let's
say the lowest value to be sorted was "1" and it is in array element
"10" (assume 10 numbers will be sorted). The first swapping pass will
result in the "1" being swapped from element 10 to element 9 of the
array. An additional 8 passes through the array are necessary to move
the "1" to array element number 1. This algorithm gets its name,
because the process of moving the elements has been compared to that of
bubbles slowly rising to the surface.
This program has a list of ten scores to be sorted. Line 5 of the
program will read the ten scores to an array called "Scores", and also
print the original values (before the sort) to the screen. Then two
loops will execute at statements 8 and 9 in the program to perform the
bubble sort as described above. Finally, after the sort is complete,
the sorted values will be displayed.
First, let's compile the program. When we plan to use the debugger, we
must set the "Debugging code" option on. This is done on the Compile
Menu. However, the default in the integrated environment is "Debugging
code" on. Let's take a look to be sure:
TYPE--> <Alt><c>
The compile menu should pop open, and you should see a check mark next
to the "Debugging code" option. If you don't, press the letter "D", and
a check mark should appear. Once you've verified that the option is on,
we can compile the program. Notice that there is an <F10> next to the
option. Instead of opening this menu and selecting the "Compile"
option, we could have pressed <F10>. Let's try it. First, let's close
the menu (Function keys don't work inside a menu):
TYPE--> <ESC>
The menu should have closed. Now let's compile using the function key:
TYPE--> <F10>
You should see the compiler screen pop up, and compile the program. No
errors should be detected. Now we're ready to test the program. First,
let's set a breakpoint so we can easily view the screen output, Use the
Page - 23
down arrow key to position the cursor on line 20 (the line number is
displayed on the ASIC status line). Line 20 should contain an "END"
statement. Let's open the run menu and set a breakpoint:
TYPE--> <Alt><r>
<b>
The "END" statement should now be displayed in reverse video. That
tells us that a breakpoint has been set there. Did you notice that the
breakpoint option on the menu also had a function key listed. We could
set a breakpoint without opening a menu, by pressing <F9> instead. Now
that we've set a breakpoint, let's run the program and see how it works:
TYPE--> <Alt><r>
<r>
Note that we could have pressed the short cut key of <F5> to run the
program instead of selecting the option from the menu. At this point
our program is running, but is paused at the breakpoint we set on line
20. When you reach a breakpoint, ASIC will position the breakpointed
line on the second line of the edit window, highlighted in red (or
underlined, if you have a monochrome system). ASIC has interrupted the
program before it executed the line with the breakpoint, in this case
"END". Let's take a look at the screen output of the program to see if
it worked:
TYPE--> <Alt><r>
<s>
Note we could also select the "Swap" function by pressing <F4> without
opening a menu. You should now see the output from the program on the
screen. It should look something like:
Original Scores:
55 33 877 99 44 101 21 88 105 1
Sorting...
Here are the sorted scores:
33 55 99 44 101 21 88 105 1 877
Well, that doesn't look quite right. Maybe we can use the debugger to
figure out what went wrong. First, let's allow the program to run to
completion (remember, we're paused at a breakpoint on the "END"
statement). Swap back to the ASIC screen from the user screen by
pressing any key:
TYPE--> <enter>
You should see the editor screen again. Now let's tell ASIC to resume
program execution:
TYPE--> <Alt><r>
<r>
ASIC has executed the END statement, and our program has terminated.
You should see the message "Program Terminated Normally (0)". (The "0"
is the return code set by the program. You can set return codes in your
Page - 24
programs using the END statement. Refer to Chapter 7 for details.).
Now we'll set another breakpoint in the program. Move the cursor to
line 7 (the status line should now say LINE: 7) using the arrow keys.
The cursor should now be positioned on the statement which says: PRINT
"Sorting...". Set a breakpoint here:
TYPE--> <F9>
The source statement should now appear in reverse video. We used the
shortcut key <F9> to set the breakpoint this time, but you could have
opened the Run Menu, and selected the Breakpoint option and done the
same thing. Let's remove the breakpoint:
TYPE--> <F9>
Line 7 should no longer be highlighted. The same command is used to
turn breakpoints on or off for a source line. ASIC just checks to see
if a breakpoint is already set at that source line when you select the
breakpoint command. If one is set, it "toggles" it off (ie removes it),
otherwise, it "toggles" it on (ie sets a breakpoint). This exercise was
just to show you how to remove a breakpoint, let's go ahead and set it
again:
TYPE--> <F9>
Line 7 should be highlighted again (the breakpoint is set).
It might be nice to see what's in some of our program's variables, so
let's "watch" some variables. Open the Run Menu, select the Watch
command, and tell ASIC you want to watch variable "I".
TYPE--> <Alt><r>
<w>
i<enter>
ASIC should have opened a "Watch" window at the bottom of the screen.
You should see the variable name "I" at the left, followed by a ":".
Following the ":" is the current value of that variable. The number
there now doesn't really mean anything, since our program is not
running. But once the we start the program, this number should
represent the actual value of the variable "I".
Let's watch a few more variables: j, j1, and scores(1). This time,
we'll use the shortcut key for the watch command:
TYPE--> <F6>
j<enter>
Variable "J" should now be in the watch window.
TYPE--> <F6>
j1<enter>
Variable "J1" should now be in the watch window. When we watch
"scores", we'll also have to tell ASIC which element we want to watch by
entering a subscript, since "scores" is an array. First ASIC will
prompt you for the variable name. Type it, without the subscript. ASIC
will prompt you for the numeric subscript.
Page - 25
TYPE--> <F6>
scores<enter>
<1><enter>
Scores(1) should now be in the watch window. Now we're ready to run the
program again:
TYPE--> <F5>
Again we selected the short cut key, you could have selected the "Run
your program" option from the "Run" Menu. The second line of the edit
screen should show the PRINT "Sorting..." statement (highlighted in red,
or underlined if you have a monochrome monitor). The variables in the
watch window should have the following values:
I: 11
J: 0
J1: 0
SCORES(1): 55
Let's execute the next statement by using the Trace command:
TYPE--> <Alt><r>
<t>
ASIC has executed the PRINT "Sorting..." statement and has paused
execution on the "FOR I" statement on line 8 of the program. Since the
PRINT statement did not modify any variables, the numbers in the watch
window should remain unchanged. Let's Trace one more statement, this
time, we'll use the short cut key:
TYPE--> <F8>
ASIC has executed the "FOR I" statement on line 8, and is now paused on
statement "FOR J" on line 9 of the program. Something looks wrong
though. Even though we executed the first "FOR I" statement, the
variable "I" still contains "11". It should contain "1". If you look
at line 8, you'll see that the FOR statement was mistyped, it reads:
"FOR I = I to 9", instead of "FOR I=1 to 9". Since the program also
used variable "I" to READ the data into the array, "I" still contains
the value "11". Since "11" is greater than the "TO" value of the "FOR"
loop, the FOR loop on line 8 is executed only 1 time instead of 9 times.
That's why the data is not being fully sorted. With the ASIC debugger,
we can continue testing without recompiling, by modifying the value of
"I" to "1", so we can see if the rest of our logic is correct. If
changing "I" to "1" works, then we can go back and modify the "FOR"
statement and recompile the program to correct the program permanently.
Modify the value of "I" to "1":
TYPE--> <Alt><r>
<m>
i<enter>
<1><enter>
Page - 26
The watch window should now show the value of "I" as 1. We can resume
program execution at this point by selecting the "Run your program"
option. We'll use the short cut key again:
TYPE--> <F5>
ASIC should pause the program at the next breakpoint, which is on line
20. This statement contains the "END" command. Now let's see if the
program worked, by swapping to the user screen:
TYPE--> <F4>
Again, we used the short cut key. You should see the following on your
screen:
Original Scores:
55 33 877 99 44 101 21 88 105 1
Sorting...
Here are the sorted scores:
1 21 33 44 55 88 99 101 105 877
It looks like the program worked. Let's return to the editor screen.
TYPE--> <enter>
Now we could press <F5> to resume execution and in this case terminate,
since the END statement is the next one to execute. But let's look at
another way to terminate a program. While at a breakpoint, you can
select the "Abort your program" option, which instructs ASIC to
terminate your program immediately, without executing any more of your
program. Let's try it:
TYPE--> <Alt><r>
<a>
ASIC should display the message "Program Terminated Normally (0)". At
this point, we'll just exit from ASIC, but normally, you would fix the
FOR statement using the editor, save the file, recompile the program,
and retest it to make sure the "bug" is really fixed.
TYPE--> <Alt><f>
<x>
You should be back at the DOS prompt now. That concludes the brief
introduction to the ASIC debugger. The rest of this chapter provides
some additional reference material for the debugger. Chapter 3 provides
additional information about each of the debugging commands.
Page - 27
DEBUGGER TIPS
1) WHEN YOU ARE DONE DEBUGGING YOUR PROGRAM, YOU SHOULD RECOMPILE
WITH THE "DEBUGGING CODE" OPTION TURNED OFF. Although your program
can run from the DOS command line with debugging code present, it
will increase the program size and execution times. Recompiling
with the "Debugging code" option off will insure your programs
will be smaller and faster.
2) Remember that the default option on the command line compiler is
"Debugging code" off. The default option in the integrated
environment is "Debugging code" on.
3) Breakpoints/Watches are automatically cleared when you
OPEN or COMPILE a file.
4) If you change source lines in a program while a program
is running, without recompiling, source statements will
not match executable code. Abort the running program
and recompile after making code changes.
5) Breakpoints are set in the edit buffer relative to the
beginning of the buffer. If you insert/delete lines in
the buffer, the breakpoints will still be set at the
same relative line number from the beginning of the
buffer.
6) ASIC takes over the INT 3 Interrupt vector for debugging
purposes. It re-installs the default vector when you
exit ASIC.
7) You must compile with the "Debugging code" option to use
source level debugging.
8) If you wish to run a program from the beginning again
while its already running, select the "Abort your
program" option from the Run menu. Then, select the
"Run your program" option.
9) If you select the Abort option from the Run menu, your
program's files will NOT be closed gracefully. That
is, data in the buffers will not be flushed to disk.
10) You may still run a program in the integrated environment that
has been compiled without the Debugging code option. You just
won't be able to use the debugging commands (eg,
Breakpoints/Watches).
11) Toggling a breakpoint on/off will clear any block of
text you had previously marked for editing (eg, MOVE,
COPY).
Page - 28
DEBUGGER TIPS (Continued)
12) When modifying array variables, make sure that the
subscript you specify is valid. For example, if you
"DIM A(10)", make sure the subscript you specify is in
the range of 0 to 10. ASIC does not check the range of
a subscript. If you specify a subscript that exceeds
the valid range for that variable, your program may
crash.
13) You can pass arguments to programs using the "Arguments"
option on the Run Menu. You may retrieve these options
in your program with the COMMAND$ statement. Using the
"Arguments" option is equivalent to specifying arguments
following the program name, when you run your program
from the DOS command line.
14) The compiler allows variable names up to 80 characters in
length. The debugger only uses the first 30 characters of a
variable name. When the debugger finds two variables whose names
are not unique within 30 characters, it will always select the
first one it finds (this applies to the Watch/Unwatch/Modify
Variables commands).
15) ASIC will allow you to set a breakpoint on a "FOR" statement.
However, you should be aware that the source statement containing
the "FOR" is executed only once (to initialize the loop). When
the "NEXT" statement executes, control transfers back to the line
following the "FOR", instead of the "FOR". For example, in the
following code fragment:
FOR I = 1 TO 3 <---Executes 1 time to initialize loop
PRINT I <---Executes 3 times
A=A+1 <---Executes 3 times
NEXT I <---Executes 3 times, loops back to
"PRINT I", not to "FOR I= 1 TO 3"
16) Because a single machine language instruction could span multiple
CODE statements, ASIC does not allow breakpoints on CODE
statements.
Page - 29
A S I C
Chapter 5
Compiler Options
COMMAND LINE SYNTAX
Invoke the command line version of the compiler as follows:
ASICC filename option1 option2 option3[...option7]
Where: filename is the name of the source program to be
compiled. This file must have the file
extension ".ASI", although the extension
may be omitted from the command line.
optionN specifies any options desired. No
options are required, but as many as
seven may be specified.
COMPILER OPTIONS
A total of six compiler switches are currently available for ASIC. Each
is described in detail below:
Switch Description
C CONTINUE--ASIC will not pause after messages are
issued, but will continue compiling.
Default: ASIC will pause after each error message.
Compilation will resume after you press
a key.
Page - 30
COMPILER OPTIONS (Continued)
Switch Description
L LIST ALL--ASIC will list each source line as it
compiles it.
Default: ASIC will list only source lines with
compile errors.
Comment: Use of this switch will slow compile
speeds slightly due to the additional
screen I/O.
P PRINTLIST--ASIC will echo all messages which
appear on the screen to the printer.
Output to the printer will be paged
with header lines identifying the
program name, and the date/time
compiled.
Default: ASIC will not send any messages to
the printer.
Comments: Even though output to the printer is
buffered, this option will slow compile
speeds considerably. The compiler typically
compiles only as fast as your printer
can print the messages. An alternative
to this switch is the DISKLIST option
described below.
D DISKLIST--ASIC will echo all screen messages to a disk
file named "progname.LST". The format is
the same produced by PRINTLIST. This allows
you to compile at higher speed, and print
the source listing later from the disk file
via the DOS print spooler.
Default: ASIC does not produce a ".LST" file.
S SYMTAB----ASIC will produce a formatted Symbol Table
in a file named "progname.SYM". The symbol
table contains a list of all variables,
labels, and internally created compiler
addresses.
Default: ASIC does not produce a ".SYM" file.
Page - 31
COMPILER OPTIONS (Continued)
E EMATH-----ASIC will enable the Extended Math Option.
When this option is selected, you may specify
long integers (eg, VELOCITY&, 123456789&,
etc) which can hold a larger range of values
(+2,147,483,647 to -2,147,483,647). This
option does increase the size of your ".COM"
file by a couple of hundred bytes.
Default: ASIC does not enable the Extended Math
Option.
X DEBUG-----ASIC will generate debugging code in the
".COM" file and a ".DBG" file for use by the
integrated environment debugger.
Default: ASIC does not generate debugging information.
Comment: If you are running from the integrated
environment, ASIC sets this option on by
default. You may turn it off in the Compile
menu, should you so desire.
COMPILE EXAMPLES
Example 1: Compile "MYFILE.ASI" with default compiler options:
ASICC MYFILE
Example 2: Compile "MYPROG.ASI", Listing all source lines, writing
a compile listing to a disk file for printing later. The
listing file will be called "MYPROG.LST":
ASICC MYPROG L D
Example 3: Compile "FILEX.ASI", don't pause for any errors, and
print the errors on the printer:
ASICC FILEX C P
Example 4: Compile "CRUNCH.ASI" and allow long (32 bit) integer
numbers:
ASICC CRUNCH E
Page - 32
A S I C
Chapter 6
Language Elements
CHARACTER SET
Symbol Description
* Multiplication
Example: A=B*C (multiply B by C, store result in A)
/ Division
Example: A=B/C (divide B by C, store result in A)
+ Addition
Example: A=B+C (add C to B, store result in A)
+ String Concatenation
Example: A$="AB"+"C" (A$ will contain "ABC")
= Assignment
Example: A=1 (A will be assigned the value 1)
= Equality testing
Example: IF A=1 THEN QUIT: (If the value stored in
(A equals 1 goto label QUIT)
- Subtraction
Example: A=B-C (Subtract C from B, store result in A)
" String Delimiter
Example: A$="the string is inside quote marks"
() Parenthesis -- Ignored by ASIC
Symbol Description
; Suppress Carriage Return/Line Feed with PRINT/LPRINT
# Used to identify file usage with PRINT#/INPUT#
, Comma, Ignored by ASIC
$ Distinguishes a String Variable from an Integer.
Example: ABC$ <---- String Variable
Example: ABC <---- Integer Variable
Page - 33
CHARACTER SET (Continued)
Symbol Description
: Distinguishes a Label from a variable name.
Example: START: <---Label name
& Distinguishes a "long" (32 bit) integer from a normal
integer (16 bit) variable or constant. Normal integers
can hold numbers in the range +32,767 to -32,767. Long
integers can hold numbers in the range +2,147,483,647
to -2,147,483,647. Note: You must compile with the
"Extended Math" Option enabled to use long integers.
Example: APPLES& <--Long Integer Variable
Example: ORANGES <--Normal Integer Variable
Example: 123457& <--Long Integer Constant
Example: 1234 <--Short Integer Constant
Page - 34
CONSTANTS, VARIABLES, AND LABELS
ASIC supports the following data types: Integer Constants, Integer
Variables, Long Integer Variables, Long Integer Constants, single
dimension Integer Arrays, single dimension Long Integer Arrays, String
Constants, and String Variables. Constants may be specified in decimal
(base 10), hexidecimal (base 16), or binary (base 2). The following
describes the restrictions for each data type.
INTEGER CONSTANTS Range +32767 to -32767
Example: -26
INTEGER VARIABLE Described by a variable name beginning with a
letter, followed by up to 79 additional letters
or numbers. It may contain a number in the range
+32767 to -32767.
Example: VELOCITY1
INTEGER ARRAY Described by a variable name beginning with a
letter, followed by up to 79 additional letters
or numbers. This name is followed by an
integer variable or constant for the dimension
of the array. Arrays must be dimensioned at the
beginning of the program. See the DIM statement.
Example: GROWTH (YEAR)
LONG INTEGER Range +2,147,483,647 to -2,147,483,647
CONSTANTS
Example: 3234457&
LONG INTEGER Described by a variable name beginning with a
VARIABLE letter, followed by up to 78 additional letters or
numbers terminated with a "&". Can contain
numbers in the range +2,147,483,647 to
-2,147,483,647.
Example: VELOCITY1&
LONG INTEGER Described by a variable name beginning with a
ARRAY letter, followed by up to 78 additional letters or
numbers, terminated with a "&". This name is
followed by an integer variable or constant for
the dimension of the array. Arrays must be
dimensioned at the beginning of the program.
See the DIM statement.
Example: GALAXY& (BILLIONSOF)
Page - 35
CONSTANTS, VARIABLES, AND LABELS (Continued)
HEXIDECIMAL Hexidecimal constants are constants which are
CONSTANT stated in base 16 instead of base 10 like normal
constants. These may be specified wherever you
can specify a decimal constant. Hexidecimal
constants in ASIC must be prefixed by "&hex". This
prefix should be immediately followed by a valid
normal or long integer constant. Hex constants
may contain up to 8 hexidecimal digits for long
constants, and 4 hexidecimal digits for normal
constants.
Example: &hexB000 <--equivalent to -20400
Example: &hexB& <--equivalent to 11&
Example: &hexFFFFFFFF& <--equivalent to -1&
Example: &hexB000& <--equivalent to 45056&
BINARY CONSTANT Binary constants are constants which are stated in
base 2 instead of base 10 like normal constants.
These may be specified wherever you can specify a
decimal constant. Binary constants in ASIC must
be prefixed by "&bin". This prefix should be
immediately followed by a valid normal or long
integer constant. Binary constants may contain
up to 32 binary digits for long constants or 16
binary digits for normal constants.
Example: &bin10 <--equivalent to 2
Example: &bin10101011& <--equivalent to 171&
STRING CONSTANT A group of 0-80 characters enclosed by quotation
marks.
Example: "This is a String Constant"
STRING VARIABLE Described by a variable name which begins with a
letter, followed by up to 78 additional
letters or numbers, terminated with a "$".
Can contain 0-80 characters.
Example: ADDRESS$
LABEL A Label is a location in your program you wish
to transfer to. It must begin with a letter,
and it may contain up to 78 additional letters
or numbers. It must be terminated with a ":".
Example: START:
Page - 36
VARIABLES VS. CONSTANTS
In general, ASIC will allow the use of either variables, arrays, or
constants as operands to any program statement. For example:
PRINT CASH
PRINT 20
PRINT A(10)
All three of the above examples are valid. The only case where a
constant cannot be used, is where the value is being modified. For
example:
A = A + B <----VALID
17 = A + C <----INVALID
Of course you must specify the correct data type for the ASIC keyword.
For example:
A = ABS("HELLO") <----INVALID
This statement is invalid because you cannot take the absolute value of
a string!
There are a few ASIC statements which will accept only integer constants
for some operands (DIM, OPEN, PRINT#, INPUT#). Refer to the individual
statement for more information.
Finally, there is a restriction on the use of subscripts for Arrays. A
subscript for an array cannot be another array. For example:
A(I(1)) <----INVALID
A(I) <----VALID
Page - 37
CONVERSION BETWEEN LONG/NORMAL INTEGERS
Long or normal integers may be used on any ASIC statement in any
combination. Consequently, in the "Keyword Reference" Chapter of this
is manual, operands are identified only as "integer". "Integer" in this
context should be interpreted as meaning that the operand for that
statement can be any of the following: integer constant, integer
variable, integer array, long integer constant, long integer variable,
or long integer array. Exceptions, if any, are noted in the
documentation for the statement.
If you do mix long and normal integers in a statement, you should be
aware of how ASIC converts between the two formats. The following two
rules are applied:
1) If a long integer variable or constant is being stored in a
normal integer variable, the long integer (32 bit) number
will ALWAYS convert correctly to a normal integer (16 bit)
value, provided the long integer variable contains a number
which will fit in a normal integer (ie, within the range of
+32767 to -32767). If, however, the number is outside of
this range, ASIC will truncate it to make it fit in a normal
integer. This truncation will cause some surprising (but
predictable) answers. For example if "A&" contained the
value "50000&", and the following ASIC statement was executed
"A=A&", then the value of "A" would be "-15536". The reason
that the overflow results in such a strange number is due to
the way the IBM PC stores numbers in binary format and is too
complicated to describe here. The important thing
to remember is, for ASIC to convert from long integers to
normal integers correctly, the value in the long integer
should be in the range of +32767 to -32767.
2) If a normal integer variable or constant is being stored in
a long integer variable, ASIC will always convert the number
correctly.
Page - 38
A S I C
Chapter 7
Keyword Reference
ABS
Format: integer1 = ABS (integer2)
Description:
This function returns the absolute value of integer2 which is then
stored in integer1.
Example:
A = ABS (-7)
After execution of this statement, "A" will contain 7.
ASC
Format: integer1 = ASC (string1)
Description:
This function returns the ASCII value of the first character of
string1, storing the result in integer1.
Example:
A = ASC("123")
After execution of this statement "A" would contain 49, which the is
ASCII value of "1".
Page - 39
BEEP
Format: BEEP
Description:
This statement will cause a short "beep" to be produced on the PC
speaker.
Example:
IF A>99 THEN
BEEP
PRINT "Number is too big!"
A=99
ENDIF
The preceding program fragment will check to see if variable "A"
contains a value less than 100. If it does not, it will produce a short
"beep", display a message, and set the value of "A" to 99.
Page - 40
BLOAD
Format: BLOAD string1, integer1, integer2
Description:
This function loads data previously saved by BSAVE from a file to
memory. String1 should be the name of the file previously created by
BSAVE. Integer1 should be the memory offset to load the data to.
Integer2 should be the number of bytes to read from the file (in the
range of 1 to 32767). If DEFSEG has been set, it will be used as the
data segment, otherwise, the default ASIC data segment will be used.
Example:
DEFSEG = &hexB800
BLOAD "SAVED.DAT" 0 100
After execution of these statements 100 bytes will be read from the file
"SAVED.DAT" and stored in memory start at 0 bytes from the start of the
override data segment (which in this case happens to point to the
beginning of video memory for a CGA card). Assuming a CGA card was
present, the first 50 characters on the screen would contain data read
from the file (don't forget that each screen character is represented by
two bytes data and attribute, that's why only 50 characters will be
displayed, assuming you are not in graphics mode).
Comments:
THIS FUNCTION IS RECOMMENDED ONLY FOR ADVANCED PROGRAMMERS. THIS
STATEMENT WILL ALLOW YOU TO OVERLAY ANY AREA OF MEMORY, AND IT IS VERY
EASY TO ACCIDENTALLY OVERLAY YOUR PROGRAM OR THE MEMORY USED BY DOS.
If ASIC detects an error executing this command, it will set the
system ERROR variable. These error codes are listed in the Error
Messages Chapter of the ASIC Manual
This statement is slightly different from GWBASIC/BASICA in that
you must specify how many bytes to read from the file. Also, the memory
offset is not stored in the file by BSAVE, so you must specify the
offset as integer1 in ASIC. Offset is optional in GWBASIC/BASICA.
ASIC uses a slightly different file format than GWBASIC/BASICA,
however, it is relatively easy to convert the GWBASIC/BASICA to ASIC
format. GWBASIC/BASICA files have a seven byte header that ASIC does
not have. If you strip off these 7 bytes and rewrite the file, ASIC
should be able to process the file.
See also:
DEFSEG,BSAVE
Page - 41
BSAVE
Format: BSAVE string1, integer1, integer2
Description:
This statement writes the block of memory beginning at offset
integer1 from the start of the data segment for a length of integer2
bytes to the file specified by string1. This data may be later loaded
by BLOAD. If DEFSEG has been set, it will be used as the data segment,
otherwise, the default ASIC data segment will be used.
Integer2 should be in the range of 1 to 32767.
Example:
DEFSEG = &hexB800
BSAVE "SAVED.DAT" 0 4000
After execution of these statements 4000 bytes at offset 0 bytes from
the start of the override data segment (which in this case happens to
point to the beginning of video memory for a CGA card) will be written
to the file "SAVED.DAT". Assuming a CGA card was present, the current
screen would be saved to disk, assuming you are not in graphics mode.
Comments:
If ASIC detects an error executing this command, it will set the
system ERROR variable. These error codes are listed in the Error
Messages Chapter of the ASIC Manual.
See also:
DEFSEG,BLOAD
Page - 42
CALL
Format: CALL (string1,string2)
Description:
This function can be used to load and execute other programs
compiled with ASIC or another compiler. String1 represents the name of
the program to execute. String2 contains any arguments to be passed to
the program (it may be NULL, ie ""). If an error occurs when ASIC
attempts to call the program, it will set the system ERROR variable to
255. Otherwise, the ERROR variable will be set to the value of the
return code of the called program (which is 0 unless the called program
specifies otherwise).
Example:
CALL ("MYPROG.COM","")
REM other code follows
This statement would cause ASIC to load and execute the program
"MYPROG.COM". No arguments will be passed to the program. When MYPROG
terminates, the calling program will regain control on the line
following the call, in this case the "REM" statement.
Example 2:
CALL ("COMMAND.COM"," /C WP.BAT")
In this example, a ".BAT" type file is executed called "WP.BAT". To run
".BAT" files, it is necessary to load a copy of COMMAND.COM as shown
above (COMMAND.COM contains the DOS code required to load and execute
".BAT" files). Using this format, you can also run some "built in" DOS
commands such as DIR or SORT. Using CALL with this format, is similar
to using the GWBASIC/BASICA SHELL command.
Comments:
String1 must contain the FULL pathname of the program
(ie,"\directory\progname.COM") only if the program is NOT in the current
directory. You must include the file extension on the file name (for
example, use "MYPROG.COM" instead of just "MYPROG", or use "MYPROG.EXE"
instead of "MYPROG").
If you wish to pass arguments to the program build it as follows:
YOURPARM$ = "arguments"
N = LEN(YOURPARM$)
A$ = CHR$(N)
A$ = A$ + YOURPARM$
B$ = CHR$(13)
A$ = A$ + B$
CALL "progname" a$
Page - 43
CALL (Continued)
The above creates an argument list according to the strict DOS
calling rules, however, you can just create the arguments in a string,
and precede them with a leading space. This will work for arguments up
to 32 characters in length (space character is ASCII 32). You might
want to try this short cut first, and only resort to the full formal
approach if you have problems with it, or need to specify longer
arguments:
CALL "progname" " arguments"
CAUTION:
You may use the debugger with programs which contain "CALL"
statements. However, the programs you call should not themselves
contain debugging code. For example, if A.ASI calls B.ASI, then make
sure you compile B.ASI with the "Debugging Code" option OFF before you
try to debug program A.ASI. Failure to do so will cause the debugger to
behave erratically. This also applies to programs you write using other
compilers, since they also use the same interrupt as ASIC (INT 3).
See also:
RUN,COMMAND$
CHDIR
Format: CHDIR string1
Description:
This statement will change the current directory to that specified
in string1. If an error occurs when ASIC executes this command, it will
set the System ERROR variable. A list of possible error codes is listed
in the Error Messages Chapter of the ASIC Manual.
Example:
CHDIR "\DOS"
IF ERROR = 0 THEN NOERROR:
If Drive "C" was the current drive, then this statement would change the
current directory to "C:\DOS".
CHDIR "C:\DOS"
This statement would change the current directory on drive C to "C:\DOS"
whether or not drive C is the current drive. It would NOT change the
default drive to "C". Note that DOS retains a current directory for
each disk drive on your computer.
See also:
MKDIR, RMDIR
Page - 44
CHR$
Format: string1 = CHR$(integer1)
Description:
This function converts an integer in the range of 0-255 to an
ASCII character, and stores in string1.
Example:
A$ = CHR$(49)
After execution of this statement, "A$" will contain "1", since "1" is
represented by ASCII 49.
Comments:
If integer1 is outside the range 0-255, then the least
significant byte of integer 1 is converted to string1.
CLOSE
Format: CLOSE integer1
Description:
This function closes the file number identified by integer1. If an
error is returned by DOS, the system variable "ERROR" will be > 0.
Example:
CLOSE 1
IF ERROR > 0 THEN CHECKERROR:
After successful execution of the CLOSE statement, the file previously
opened as file 1 will be closed. If an error is returned by DOS, the
ERROR variable will be set by ASIC to a non-zero value.
Comments:
IF YOU FAIL TO CLOSE AN OPEN FILE (WHICH WAS OPENED FOR WRITING),
YOU MAY LOSE DATA, SINCE FILE I/O IS BUFFERED, AND THE LAST BUFFER MAY
NOT HAVE BEEN FLUSHED.
Also, integer1 may only be a constant with the value of 1-3.
See Also:
OPEN,PRINT#,INPUT#
Page - 45
CLS
Format: CLS
Description:
This function clears the screen.
Example:
CLS
After execution of the above statement, the screen will be cleared.
CODE
Format: CODE integer1[,integer2...integerN]
Description:
This function may be used to insert machine language code directly
into your program. Integer1 through integerN should be constants in the
range of 0-255. At least one integer must be specified, however, ASIC
will allow up to 30.
Example:
CODE 205,5
This statement represent the machine code generated from the assembly
language statement "INT 5". INT 5 is the BIOS routine which will print
the screen to the printer. After execution of these statements in your
program, the current screen contents would be printed on your printer.
Comments:
THIS STATEMENT IS INTENDED FOR ADVANCED PROGRAMMERS. THIS
STATEMENT IS VERY POWERFUL, AND IF YOU DON'T UNDERSTAND MACHINE LANGUAGE
YOU COULD EASILY CRASH YOUR PROGRAM.
When you use this statement, be sure to save the contents of the
following 8088 registers if you plan to modify them, and restore them
before returning to ASIC. Otherwise the results may be unpredictable.
Registers: DS/CS/ES/SS. Also, make sure you clean up the stack before
you return (ie, if you push a value to the stack, make sure you pop it
before you return to ASIC) Failure to do so, will almost certainly
cause your program to crash.
Page - 46
COLOR
Format: COLOR integer1,integer2
Description:
This function is used to set the foreground and background screen
colors. The foreground color is specified in integer1, the background
color in integer2.
Valid Colors: Foreground Background
---------- ----------
Black 0 0
Blue 1 1
Green 2 2
Cyan 3 3
Red 4 4
Magenta 5 5
Brown 6 6
White 7 7
Dark Gray 8
Light Blue 9
Light Green 10
Light Cyan 11
Light Red 12
Light Magenta 13
Yellow 14
Bright White 15
Note: Colors 8-15 when specified for background color
result in blinking text.
Example:
COLOR 4,8
After execution of this statement, future characters written to the
screen will be Blinking Red on a Black Background.
Page - 47
COMMAND$
Format: string1 = COMMAND$
Description:
This statements retrieves any command line arguments that were
entered and stores them in string1.
Example:
If your program was invoked with: MYPROG XXX
And if your program MYPROG.ASI contained the following:
A$=COMMAND$
PRINT A$
After execution of these statements, the screen would display " XXX".
Comments:
In the integrated environment, you can specify command line
arguments on the "Run" Menu.
This statement is an extension over BASICA/GWBASIC.
Page - 48
COMSTAT
Format: integer1 = COMSTAT (integer2)
Description:
This statement returns the status of a com port. Integer2 should
contain "0" for COM1, or "1" for COM2. The status of that COM port is
returned in integer1. Each bit in integer1 represents a different piece
of information. These are described in the table below. Note that you
may test if a bit is on/off using the ZBIT command.
Example:
PORTSTAT = COMSTAT (0)
DATAREADY = ZBIT(8,PORTSTAT)
IF DATAREADY = 1 THEN GORECEIVE:
These statements do the following. The first retrieves the status of
COM1 to the variable PORTSTAT. The second checks to see if bit 8 is on,
DATAREADY will contain 1 if so, otherwise it will contain 0. Since Bit
8 is used to determine if data is waiting to be received from the port,
if DATAREADY = 1 then the program will transfer to the label GORECEIVE:
which would contain code to RECEIVE data from the port.
Comments:
Status Codes Returned by COMSTAT (Meaning when set to 1)
Bit 0 Delta clear-to-send
1 Delta data-set-ready
2 Trailing-edge ring detector
3 Delta receive line signal detect
4 Clear-to-send
5 Data-set-ready
6 Ring Indicator
7 Received line signal detect
8 Data Ready
9 Overrun error
10 Parity error
11 Framing error
12 Break-detect error
13 Transfer holding register empty
14 Transfer shift-register empty
15 Time-out error
See also:
OPENCOM,SEND,RECEIVE
Page - 49
CSRLIN
Format: integer1 = CSRLIN
Description:
This function returns row of the cursor.
Example:
LOCATE 10,20
A = CSRLIN
The locate command will have positioned the cursor in row 10, column 20.
After execution of the CSRLIN statement, "A" will contain the value of
10.
See also:
POS
Page - 50
DATA
Format: DATA constant1[,constant2,...,constantn]
Description:
This statement is used store integer and string constants in memory
for later retrieval by READ statements. At least one integer or string
constant must be specified, although multiples of each type are
permitted.
Example:
DATA 1,"APPLE",2&,"ORANGES"
READ A
READ A$
READ B&
READ B$
The above statements are equivalent of entering the following code:
A=1
A$="APPLE"
B&=2&
B$="ORANGES"
Comments:
All DATA Statements must be placed at the beginning of the program,
before all other statement types, except DIM or REM statements (or blank
lines). DIM statements, if specified, must precede all other statements
including DATA statements except REM statements (or blank lines). As
long as you follow these rules, you may specify an unlimited number of
DATA statements.
GWBASIC/BASICA does not require quotes around string constants in
some instances. ASIC always requires quotes around string constants.
See also:
READ,RESTORE
Page - 51
DATE$
Format: string1 = DATE$
Description:
This function returns the value of the system date in the format of
"MM-DD-YYYY".
Example:
A$=DATE$
PRINT A$
After executing these statements, the date stored in the PC
System Clock will be displayed on the screen.
Comments:
Note: if the date printed is wrong, you have probably not set the
system clock. Most older XTs and PCs do not have a battery to preserve
the DATE and TIME in the system clock, so you have to set them each time
you power up the PC. Most ATs and newer PCs have a battery backup, so
that the date is preserved for you.
Unlike GWBASIC/BASICA, you cannot set the system date with DATE$,
however, you can set the system date from DOS by typing DATE.
See also:
TIME$, TIMER
DEFSEG
Format: DEFSEG = integer1
This function is used the alter the default data segment used when
peeking and poking data with PEEK and POKE statements. DEFSEG, PEEK,
and especially POKE are not recommended for beginners. If integer1 =-1,
then the data segment address is set back to the ASIC default data
segment address.
Example:
DEFSEG = -1
Execution of the above statement would reset the default data segment to
the default ASIC data segment.
See also:
PEEK, POKE, BLOAD, BSAVE
Page - 52
DIM
Format: DIM variable(integer1)
Description:
This statement will create one dimensional arrays. An integer
variable name must be specified in variable. Integer 1 contains the
number of elements in the array.
Example:
DIM A(10)
DIM A&(20)
In this example an array of 10 normal integer variables is defined, and
an array of 20 long integer variables is defined.
Comments:
On the DIM statement, integer1 may only be a constant. Also, DIM
statements must appear before all other statement types in the program
except REM statements (or blank lines).
END
Format: END [(integer1)]
Description:
This statement causes your program to terminate and return to DOS,
optionally setting a return code. Integer1 may be optionally specified
to set the return code. If omitted, ASIC uses a return code of zero by
default.
Example:
END
In this example, the program will terminate and return to DOS with a
return code of zero.
END (20)
In this example, the program will terminate and return to DOS with a
return code of "20".
Comments:
The optional return code is an extension over GWBASIC/BASICA.
Page - 53
ENVIRON$
Format: string1 = ENVIRON$(integer1)
Description:
This statement will retrieve DOS environment strings. Integer1
identifies which string to retrieve. If found, the string is placed in
string1. If not found, a NULL string (length=0) is stored in string1.
Example:
FOR I=1 TO 5
A$=ENVIRON$(1)
PRINT A$
NEXT I
The above example will retrieve the first five DOS environment strings
and display them.
Comments:
If the requested DOS environment string entry is greater than 80
characters in length, ASIC will truncate it at 80 characters.
Environment strings may be set in DOS using the SET command.
Environment strings are one way of passing information to your program.
Refer to your MS DOS Manual for more information.
Page - 54
FILEPOS
Format: integer1 = FILEPOS (integer2,integer3) <--Format 1
integer1 = FILEPOS (integer2,EOF) <--Format 2
integer1 = FILEPOS (integer2,CURRENT) <--Format 3
Description:
This statement is used to set or retrieve the read/write position
for files opened in Random mode. In all three formats, integer2 is the
file number of the file. This file number must have been previously
opened for Random mode by the OPEN statement. Format 1 is used to set
the current read/write position of the file specified by integer2.
Integer3 should be the offset (in bytes) from the start of the file.
Format 2 is used to set a read/write position of a random file to the
end of the file. Format 3 is used to retrieve the current read/write
position (as a byte offset from the beginning of the file) of the file.
In all cases, if an error occurs, the system ERROR variable will be set.
A list of these codes is contained in the Error Codes Chapter of the
ASIC Manual. If no error occurs, then integer1 will be set to the
current read/write position of the file.
Example 1:
A&=FILEPOS(1, 100)
This example assumes that file 1 was previously opened for RANDOM I/O
using the OPEN statement. After execution of this statement, the
read/write position of file number 1 will be set to 100. Subsequent
PRINT # statements would write to the file starting at position 101.
Example 2:
A&=FILEPOS(1,EOF)
This example assumes that file 1 was previously opened for RANDOM I/O
using the OPEN statement. After execution of this statement, the
read/write position of file number 1 will be set to the end of the file.
Subsequent PRINT # operations to this file will result in data being
appended to this file.
Example 3:
A&=FILEPOS(1,CURRENT)
This example assumes that file 1 was previously opened for RANDOM I/O
using the OPEN statement. After execution of this statement, the
current read/write position of file number 1 will retrieved and stored
in integer1. The read/write position of file number 1 will NOT be
altered after execution of this statement.
Page - 55
FILEPOS (Continued)
Comments:
If you wish to use this command with files larger than 32767 bytes,
you should use long integers with this statement. If you set the
read/write position past the physical end of file and attempt to read
from the file, you will receive an error on the INPUT# command. If you
set the read/write position past the end of file and issue a PRINT#
command, the data will be correctly written at the position you
specified.