USING COMMANDS -------------- Although many operations within True BASIC may be performed by using menus and fast key equivalents, the same may be duplicated with commands typed into True BASIC's COMMAND window. Depending on your skill and the situation, you may find this quicker and easier, although it is also a matter of personal taste. In a few cases, COMMANDS can perform operations not available from pull-down menus. This document is intended as a reference, so the commands are described in alphabetical order. See the Regular Edition Reference Manual for additional discussion of the commands grouped according to their function. True BASIC's commands are intended to be entered into the COMMAND window, not into your programs. Note also that they may be abbreviated by entering only their first three characters. True BASIC's commands may be combined onto a single line using semicolons as separators, in which case they will then be executed as listed from left to right. For example, entering: REPLACE; COMPILE; SAVE; RUN ... will save the changes to the currently visible program file, compile it, save the compiled version with the same name but a "*" character on the end, and finally execute it. ALIAS The ALIAS command allows you to define pseudo names to help True BASIC locate different types of files. This is an indespensible feature when your program uses LIBRARY files. To begin with, True BASIC defines for itself four alias names: {library}, {help}, {script}, and {do}. These names define the default locations on your system where these resources can be found. Said another way, alias names tell True BASIC where to look for certain types of files whenever it needs them. Do not confuse True BASIC's alias feature, which is used at the command level of a programming environment, with AmigaDOS' alias feature, which is used at the command level of your computer. The following instruction within your program: LIBRARY "GraphLib" ... will cause True BASIC to look for the file called GraphLib within the various locations specified by its {library} alias definition. Similarly, the following COMMAND: DO PAGE ... will cause True BASIC to look for the DO program called PAGE in the various locations specified by its {do} alias definition. To examine the locations corresponding to whatever alias names are currently defined on your system, enter into the COMMAND window: alias That is, enter the word alias with no argument. You will see a list of them scroll by. To inspect the complete list resize the COMMAND window and scroll up in it. The alias names are reported in braces (curly brackets) followed by the locations they represent listed in the order that True BASIC will access them. The first four on the list are True BASIC's default alias names, the one I mentioned earlier. They define the locations where True BASIC will look for whatever files it needs to access when you invoke certain standard operations. The first one on the list is {help}, and it is defined as: {help} True BASIC:TBHelp/, True BASIC:, "" ... assuming that you are running True BASIC from a floppy disk whose volume name is True BASIC. Note that the reference to "" means "the current directory". The above definition causes True BASIC to look first in the directory "True BASIC:TBHelp/" for its related files whenever you press the [HELP] key. Try this out yourself. Press [HELP] and you will see a dialogue box open with the location of the help files in the upper string gadget, and the files themselves listed in the lower file window, ready for selection. This happens no matter what your current working directory is because when you invoke the help facility True BASIC looks specifically at the location defined by the {help} alias name. If you are running True BASIC from a hard drive the same thing will occur except that the actual location name in the upper string gadget will correspond to where you have installed the help files in on your particular system. If you enter HELP into the COMMAND WINDOW, followed by the name of a topic, True BASIC will look, in addition to "True BASIC:TBHelp/", into the other locations specified by the above definition, "True BASIC:", followed by the current directory. True BASIC assumes that any LIBRARY statement within a program, or any LOAD command entered into the COMMAND window that does not specifically use an alias name will cause True BASIC to look for the specified file in the {library} alias name, which is the TBLibrary drawer. However, you can specify other locations by using alias names of your own creation. A new alias name can be created by entering the alias command, along with some required information, into the COMMAND window: alias {MyLibs}, True BASIC:MyLibs/, "" From that point on, the following LIBRARY statement within your program: LIBRARY "{MyLibs}MyGraphLib" ... will cause the language to look for the library file called MyGraphLib in the directory "True BASIC:MyLibs/", and if it can't find it there, in the current directory. Remember, True BASIC will look into the various locations in the same order that they appear in the alias name definition. It is sometimes important to have True BASIC look at these locations in some particular order. For example, suppose that you want to perform some modifications to True BASIC's GraphLib library file, which is located in TBLibrary. For your convenience you will want to copy GraphLib into your current working directory and make your modification at that location. That way you can be sure that your modifications work as intended before putting the library into service. However, when you execute a driver program to test it, the language will read the GraphLib library file, not from your current directory where you have just modified it, but from the TBLibrary drawer. Thus you will get the orginal, unmodified copy, not the one you are working on. To correct this situation you simply enter the following alias definition into the COMMAND window: alias {library}, "", True BASIC:TBLibrary/, True BASIC: Now the language will look first in your current working directory for any library file. When you have finished your work on the GraphLib library file, and you are sure that it operates the way you want it to, copy it into TBLibrary, overwriting the old version. Finally change the library alias definition back to: alias {library}, True BASIC:TBLibrary/, True BASIC:, "" When you create libraries that you think will be useful to a variety of projects, you should place them in a drawer called UsrLib, meaning "User Defined Libraries". In fact, you will notice that UsrLib is one of the alias names reported when you enter the alias command with no argument. To refer to any file at that location, like the ButtonLib* library for example, from within your programs you would write: LIBRARY "{UsrLib}ButtonLib*" Note that there are actually two alias names defined to represent the same thing: {UsrLib} and {UserLib}. This was done to show you how to deal with certain alias names whose exact spelling you often forget. Thus, whether you use {UsrLib} or {UserLib} within your programs, True BASIC will find the files it needs. Alias names can be defined automatically when the language starts up by entering them into a special file, called TBStartup, located in the TBDo drawer. In fact, that is how the {UsrLib} and {UserLib} alias names got defined on your system. They are not a default alias name to the language itself, but defined by you, the user, in the TBStartup file. You can load the TBStartup file into your True BASIC editor to see how that is done. Notice also the other alias names, like {DevToolKit}, {3DGraphLib}, ... etc. These represent other products available from True BASIC, Inc., that extend the language to facilitate the development of certain kinds of applications. If you ever decide to purchase any of these products, and if you have a hard drive, you should install them at the locations indicated. On a floppy drive system they would be redefined as the volume names of the related disks. Alias names can be used within your programs where ever files are specified. For example: OPEN #1: NAME "{DBaseData}Addresses" ORGANIZATION RECORD Once an alias name is defined, either by the TBStartup file, a script, or directly from the COMMAND window, it will stay in effect until a new alias command is executed for the same name. If you are not using alias names in your programs, you are giving up a lot of the organizational advantages of using True BASIC. BYE This is the command used to exit True BASIC. When you enter the BYE command, True BASIC will close the currently open file, notifying you if it needs to be saved. CD or ENTER The CD command is used to change the currently active directory. True BASIC assumes that all files named within commands or program statements, and without an explicit alias name, are located in the current directory. The CD command will take any valid path as its argument. It is also possible to specify the argument "/" which has the same effect within True BASIC as it does within AmigaDOS, which is to move you to the parent directory. To switch to a subdirectory of the current directory, simply follow the CD command with the subdirectory's name. To change the currently active drive, follow the CD command with the drive itself, or the volume name of the floppy disk that is mounted in it, followed by a colon. You can use the word ENTER instead of CD if you like. Both words mean the same thing to True BASIC. CHANGE and TRY The CHANGE command is used to make changes of words and phrases within a program currently in the editor window. The CHANGE command usually affects the entire file. However, if one or more lines of text have been marked, or if the EDIT command is in effect for a portion of the program, the CHANGE command is restricted in scope to that portion. When entering the CHANGE command, specify the string to search for followed by what you want it changed to, separated by a comma. CHANGE search phrase, replacement phrase These strings follow the same rules used with the FIND pull-down menu item. See the Editor.DOC file. The CHANGE command makes the requested changes automatically, and does not ask you to verify them. If you are unsure what effect this may have on your program text, you might prefer the TRY command, which will prompt you before making each change. COMPILE The COMPILE command instructs True BASIC to compile the program currently visible in the editor. This process checks the program's syntax and changes the name by appending a "*" character to the end. The COMPILE command does not run or save the newly compiled program. It is up to you to perform these actions separately as desired. When the compilation process is complete, True BASIC displays the message "(Compiled program.)" in the editor window. Note that once a file has been compiled, it can no longer be viewed or edited. To make a modification to a compiled program you must change the uncompiled, source code version and recompile it. Therefore, it is very important to always save a copy of the latest source code before compiling a program. It is impossible to reverse the compilation process. If you have forgotten to save before compiling, True BASIC will alert you to the fact and offer the opportinity to do so. CONTINUE The CONTINUE command instructs True BASIC to resume the execution of the current program after a break has occurred, either as a result of a breakpoint, or the use of the [RIGHT AMIGA]-[.] interupt. If the program has not been modified after it was interupted, execution will continue from where it left off. DO The DO command is used to invoke a preprocessor, a program that is executed in the background while something else is in the editor. These DO programs are most useful as utilities to operate on the contents of the editor. True BASIC preprocessors are written according to the guidelines specified in the "Regular Edition Reference Manual". Several such preprocessors have been supplied with your True BASIC Language System: PAGE FORMAT XREF NUM RENUM UNUM ... and it is easy to write your own. In fact, if you design one and save it as UsrDo (meaning User Defined Do) in the TBDo directory, you will be able to execute it directly from a pull-down menu in the editor. You can call any preprocessor by entering the DO command followed by the name of the preprocessor file, as follows: DO PAGE This example would send a paginated listing of the current file to the printer. ECHO This command instructs True BASIC to duplicate the textual output of subsequent programs either on a printer or in a file. Note that this does not apply to graphics output. To duplicate the output on a printer, use: ECHO To duplicate the output in a file, specify the name of the file after the ECHO command, as follows: ECHO to MyOutputFile The echoing of output will continue to be directed as specified until it is redirected by another ECHO command, or until it is turned off. To turn off the echoing use: ECHO OFF It is also possible to echo the results of only a single command. To do so, type ">>" after the command. If no file name is specified the results of that command will be echoed to the printer, otherwise the results will be echoed to the named file. Thus: RUN >> ... echoes the results of the next run to the printer, avoiding the need for an ECHO OFF command. Similarly: FILES >> ListFile ... echoes a list of the True BASIC FILES in the current directory to a file named "ListFile". EDIT The EDIT command allows you to restrict editing to a single block of lines. The block can be specified as a subroutine or function name, or it can be marked using the mouse. Entering the EDIT command followed by a subroutine name, or by itself after marking a block of lines in your program, will restrict editing to that particular subroutine or block. This feature is especially useful for working on large program that consist of many functions, subroutines, or pictures. When a block is being edited, it will be the only text visible in the editor window. Editing features like [F-5], for moving the cursor to the top of the program will now move it only to the top of the section of code being edited. However, the rest of the program is still in memory. To return to editing the entire program, first ensure that no lines are currently marked, then enter the EDIT command without any block specification. ENTER See CD FILES This command is used to list the files in the current directory. Note that if you enter the word FILES with a comma at the end, like this: FILES, ... True BASIC will report file sizes as well as file names. FORGET This command is used to release any memory which has been previously allocated as workspace using the LOAD command. This is a handy means of obtaining the most memory possible for running a large program, but it is important to be aware of what is lost. FORGET removes all loaded libraries from memory, discards the historical contents of the COMMAND window, and erases any active variables currently stored in memory. HELP This command allow you to invoke a short explanation of a particular topic in the True BASIC language. To see a list of which topics are available, type: HELP topics Any topic displayed in this list may be used after the HELP command in order to obtain related information. INCLUDE The INCLUDE command inserts the contents of a saved file on the lines immediately following the most recent position of the text cursor in the editor window. Simply enter the INCLUDE command followed by the name of the file to be included. Note that the related KEEP command, described below, is useful for creating limited files for use with the INCLUDE command. INFO The INFO command provides you with useful information concerning your current True BASIC environment. Issuing the INFO command will display the size in lines and bytes of your current program, the number of the line on which the text cursor is currently located, the name of the current directory, the amount fo memory available in bytes, and, if relevant, the point at which the current program was stopped during the last run. This information will be listed in the COMMAND window. KEEP The KEEP command is used to retain only the currently marked lines of a program. When issued, the KEEP command isolates the marked lines by discarding all unmarked ones. The remaining lines then become the current contents of the editor window, which you can then save under a different name. Be careful not to save them under the same name or you will lose parts of your original program. KEY This command is used to redefine the meaning of any key, or combination of keys on your keyboard, making it equivalent to some often used sequence of key strokes. This is known as a MACRO to users of popular wordprocessors, like WordPerfect, or ProWrite. Note that you can only redefine non printing keys, like [CTRL]-[some other key], or [ALT]-[some other key]. Redefining standard printing keys would not make sense. Thus you may redefine [ALT]-[J], but not [J] itself. Be warned that you should not redefine keys that True BASIC itself already uses for some other purpose. When issued, the KEY command will ask you to type the key you wish to redefine. Once you have pressed the desired key, you will be prompted to type the new definition. The new definition may be any sequence of printing or non-printing keys. Non printing keys will appear as asterisks. To signify the end of the new definition, use [CTRL]-[A]. Once a key has been defined in this way, the sequence you have associated with it will be typed at the current position in the text editor, or in the COMMAND window, which ever is active, whenever you press that key. As an example let's redefine the key sequence [CTRL]-[L] to mean the popular key word LET followed by a single space. This will be handy when entering assignment instructions. 1 - Enter the command KEY in the COMMAND window and press [RETURN]. True BASIC will respond by giving you the prompt: Press key to redefine:. 2 - Press [CTRL]-[L]. That is, press and hold the [CTRL] key, then with the [CTRL] key still pressed, press the [L] key. Finally, release both keys. True BASIC responds with the prompt: Define it as:. 3 - Enter the key word LET, a space, then press [CTRL]-[A]. Do not press [RETURN]. From now on whenever you press [CTRL]-[L] with either the editor or the COMMAND windows active, the word LET followed by a space will appear. You can define other keys to represent often used phrases. How about [CTRL]-[P] for PRINT, [CTRL]-[F] for FOR, and [ALT]-[L] for LIBRARY ". You can also redefine keys to represent often used commands. How about [ALT]-[R] for SAVE; COMPILE; SAVE; RUN. Keys redefined in this way will remain in effect until that key is redefined, or until you exit True BASIC. You can nullify any key definition without affecting the others by redefining it to be itself. You may desire to build up a collection of commonly used key sequences. To avoid having to repeat the redefinition process each time you start True BASIC, it is possible to save the currently active key definitions to a file and restore them as a group later. To do so, make sure that you have redefined the desired keys and type: KEY to True BASIC:MyKeys (The device name True BASIC: is needed) The above example would save the current key definitions to a file named "MyKeys". You may use any file name you like. To restore the definitions of these keys at a later time, use: KEY from True BASIC:MyKeys It is possible to save several combinations of key definitions into files with different names for use with particular projects. To get you started defining keys with this Amiga "Student Edition" the following keys have been defined for you and saved in the file called "True BASIC:MyKeys". In addition, the KEY command has been placed in the TBStartup file, making these key definitions active whenever you start up True BASIC. [CTRL]-[L] ...... LET [ALT]-[L] ....... LIBRARY " [CTRL]-[D] ...... DECLARE FUNCTION [CTRL]-[P] ...... PRINT LIST This command sends a listing of your current program to the printer, assuming, of course, that the printer is properly connected and is on. If a block of lines is currently marked, only that portion of the text will be printed. The LIST command does not do any formatting or pagination of the text. If you want that you should use the preprocessors (DO programs) designed for that purpose, FORMAT and PAGE. LOAD and FORGET This command is used to make any library act as if it were part of the True BASIC language itself in executable memory. The concept is called "LOADING a workspace". If you run a program that uses routines within a particular library, simply load that library into your workspace and True BASIC will no longer have to refer to disk when one of your programs need it. You can try this out yourself by entering: LOAD {AmigaTools}IFF* ... then opening and running the Demo_IFF.TRU program in the Demos drawer. That program calls the Read_IFF_Image() routine of the IFF* library, a routine of considerable size. Yet, with it loaded in your workspace is executes almost instantly. To remove libraries from your workspace enter FORGET. Try this out on the above example and confirm that it will then take much longer to execute the same Demo_IFF.TRU program. You should be aware that not all libraries are single, self contained units. That is, any one could call up the resources of any others. An example of this is the FontLIB* in the AmigaTools drawer. You will want to use this library to spruce up the appearance of your programs, but you will also find out that it requires a noticable amount of time to execute. Part of the reason is that it uses the resources of four other libraries: exec*, graphics*, diskfont*, and amiga*. Thus to load the complete FontLIB* into your workspace you will want to load those libraries as well. Before you get discouraged by the thought of having to remember all those library names, simply enter into the command window: SCRIPT LOAD_FONTS ... and you will witness all the required libraries loaded before your eyes. LOAD_FONTS is a script file (explained below), which is saved in your TBDo directory. After the script executes, the various routines of that library, plus all the required supporting libraries, will be in your workspace, and they will act as if they were part of the True BASIC language itself. You can have True BASIC automatically LOAD the complete FontLIB* and its required support libraries every time you start up the language by INCLUDING the contents or the LOAD_FONTS script into the TBStartup file. Simply place the cursor in the TBStartup file one line before where you want the new commands to appear, how about the line starting with the word KEY, then enter: INCLUDE LOAD_FONTS Presto! LOCATE The LOCATE command is used to list the lines in the current program that contain a specific word or phrase. The lines are printed to the COMMAND window, but they can be duplicated in a file or sent to the printer by using the ">>" operator. For example: LOCATE LET >> ... will send every line containing a LET statement to the printer. LOCATE LET >> Output ... will send the same information to the file called "Output". MARK This command allows you to mark a block of lines specified by a subroutine, function, or picture name. To unmark the lines, select anywhere in the editor window with the mouse. MOVE This command instructs True BASIC to move a block of lines specified by subroutine, function, or picture name elsewhere in a program. This is especially handy when arranging the order of your subroutines, or for making them external after initially designing them as internal. MOVE MySubOne, MySubTwo ... moves the subroutine called "MySubOne" to the lines immediately following the subroutine "MySubTwo". NEW The NEW command tells True BASIC that you want to clear the editor window in order to begin writing a new program. If you have not saved your work, True BASIC will ask you if you want to. OLD This command is used to retrieve a file from disk and make it appear in the editor window. It is equivalent to the OPEN item available from the "Project" pull-down menu. RENAME This command is used to change the names of programs. If one name is given, True BASIC will will assume that you want to change the name of the program that is in the editor. For example, the command: RENAME MyProgram ... will change the name of the program that is currently in the editor to "MyProgram". If two names are specified separated by a comma, the first is assumed to apply to a file in the current directory, and the second is the new name that you want given to the file. In this case the file to be renamed must not be currently open, or an error will be generated. REPLACE (see also SAVE) The REPLACE command saves the program visible in the editor window to a disk file of the same name, assuming that it has been proviously saved. If the file does not already exist, you are given the option of creating it. Use this command to save changes made to previously written programs. You can also follow the REPLACE command by an existing filename and True BASIC will replace it with the one in the editor window. RUN and CONTINUE The RUN command is used to execute a program. When issued, the RUN command instructs True BASIC to compile the program, checking for syntax errors along the way. If an error is encountered, the process is halted, and the error is displayed in the Command Window. If no errors are encountered, True BASIC begins executing the program. The program will then run until a STOP or END statement is executed, or until a fatal error occurs. If you need to stop a program during a run, use [RIGHT AMIGA]-[.], or select the STOP item from the appropiate pull-down menu. You will be returned to the editor. If desired, you may use the CONTINUE command to resume the run. SAVE (see also REPLACE) The SAVE command saves the current program to a disk file of the same name. If the name is "Untitled", True BASIC will ask you to supply a name. If a file with the specified name already exists, you will be asked if you want to overwrite it. If you do not, answer "No" and try SAVE using a different name. SCRIPT The SCRIPT command is used to execute a script file. A script file is a text file containing one or more valid True BASIC commands. When the script is executed, the commands will be auromatically entered into the COMMAND window in the order in which they appear in the file, just as if you had entered them yourself from the keyboard, and True BASIC will execute them. You can use the True BASIC editor to write and save your script files. Note that to be sure that a script file will get executed from any directory, you must save it in the "True BASIC:TBDo" directory. One name is reserved for a special True BASIC script file, called TBStartup. This file is executed every time the True BASIC language is started up. Enter into that file whatever commands you want True BASIC to execute every time it is started. For example, you could enter commands to LOAD the FontLIB* and its related resource files into your workspace. Note that you can include comments within a script file by inserting the key word "REM" at the beginning of each comment line. This is very handy when you want to temporarily remove the effect of any lines within a script, while at the same time not have to re-enter them at a later time. Simply place a REM in front of them and they will not get executed. To return their effect, remove the REMs. TRY See CHANGE. UNSAVE The UNSAVE command is used to delete a saved file from the disk. Simply specify the name of the file you want to delete after the UNSAVE command, and it will be removed from the disk. The UNSAVE command does not ask you to verify its action, so use it with caution.