INTERMEDIATE SECTION A FILE INTER.A General Commands **************** Most keywords can be associated with subjects and can be placed into groups on that basis, but there are those which have a more general usage, and which cannot be demonstrated directly in a BASIC listing. All can be used in a program, but the more common usage for some is from direct mode, to affect the program as a whole. Here I discuss their uses and indicate how they are used (syntax). Some you will have met already in the course; others may be new to you.I recommend that you try these out as soon as possible. SYSTEM This is the command which puts you back to CP/M from BASIC. ====== Simply type it at the prompt and press [RETURN], but before you do make sure that you have saved any BASIC program that you have been working on or it will be lost. SAVE To save a program to disc use SAVE "progname". This is the ==== simplest form of the command and saves the program as 'PROGNAME.BAS' in a processed form for economic storage. Should you wish to save the listing with a suffix other than .BAS then you must use the full name ;e.g SAVE "PROGNAME.PIC". A refinement is to place a letter A or P after the command, separated by a comma. SAVE "progname",a saves the program in readable form (ASCII) , whilst SAVE "progname",p saves the program in protected form, so that it cannot be listed or changed. Use this latter form only when your program is complete to your satisfaction and remember to keep an unprotected copy for future use. A program can be SAVEd to any available drive by specifying that drive in the SAVE command; for example SAVE "M:progname",a would save the program,in ASCII format, to drive M (Note the colon after the drive letter). You will have noticed that I have used upper and lower case letters indiscriminately in the commands. BASIC doesn't mind this at all. LOAD LOAD is the reverse to save in that it puts a copy of a ==== program on disc into the transient program area (TPA) of the computer. The command is LOAD "progname" as long as the file extent is .BAS otherwise the full filename must be given. Note that the end quote marks can be left off and the command will still work, but don't think that you're getting away with anything because the carriage return [RETURN] acts as understudy. You only load a copy of the program; the original program remains on the disc. If you change the program you must SAVE the revised program to disc if you want to keep it. The act of LOADING a program clears the TPA so you will lose any program already in the TPA - BE WARNED. If you want to combine progs. in the TPA you don't use LOAD but a similar command such as MERGE ERA ERA is used to delete an unwanted file and must be used with === care. The command is ERA progname.ext : As you see, no quotation marks are used but the full filename must be quoted. "Wild cards" * and ? can be used to represent a word or a letter respectively. For example ERA *.* would erase all files , ERA *.BAS would erase all .bas files. ERA tom?.bas would erase files such as toma.bas, tomc.bas etc. NEW Typing NEW at the prompt and pressing [RETURN] clears the TPA === in readiness to receive a new program. Be careful with this command because you can be in trouble two ways. If you use it before SAVING your previous masterpiece, you will lose said work of art. On the other hand, if you don't use it before starting a new program, any lines that you don't overwrite will remain and possibly cause much mystification if not trauma. PRINT Although we have already met this command, it is used so ===== often and in so many ways that a recap will not come amiss. 1) PRINT " wfxrge56mo! " , will print anything between the quote marks to screen, including spaces. 2) PRINT 6+4 will print the answer to the addition,i.e 10 3) PRINT on it's own will print a blank line 4) PRINT cls$ will print the variable, be it number,text or action 5) PRINT. PRINT is used before some functions such as PRINT TAB, PRINT VERSION AND PRINT FN ** NOTE **. You can type ? in place of PRINT - BASIC will read it as PRINT - try it. LPRINT Used similarly to PRINT, but directs output to the printer. ====== Seldom used in Direct Mode REM REM (REMark) tells BASIC to ignore anything that follows it on === that line. It is used to add notes to a program, which is good programming practice. Although such notes do use up memory, they do not affect the speed of working of the program. The single quote ' can be used in place of REM and is often used to hold a line blank to act as a marker to physically separate parts of a listing, as to some, including me, it looks neater than REM. REM is also useful in debugging. Placed at a strategic point in a program it causes BASIC to ignore any command later in the line. You will see the use for this when you start debugging programs. STOP A bit unusual, this one, in that as well as being spelled out ==== in a program, it also has a key dedicated to it. Let's look at the key first. It can be pressed at any time to stop a program and you are greeted with the message "Break in 340" or whatever line is relevant. If you don't alter the program, you can restart it by typing CONT (continue) at the prompt and pressing [RETURN]. If you are unsuccessful you get the message "Cannot CONTinue". The typed command STOP is most useful when testing or debugging a program. STOP will halt a program wherever it is inserted, and puts the "break" message on screen. When tracing an error STOP can be used to break a program at strategic points, and CONT can start it again, see above. END This command is similar to STOP, but more refined. It signifies === the end of the program although it may appear several times if the program has several potential ends. It finishes the program more tidily than STOP, closing all files, tying loose ends etc., and does not display a "Break" notice. END is used in preference to STOP in a written program (listing). LIST Normally used from the prompt in Direct Mode to display the ==== program listing, it can also be used from within a program, as it is extensively in this course. When invoked from within the program it performs the listing, then goes to Direct Mode. Part only of a listing can be displayed when needed as below; 1) LIST 560 will display line 560 only 2) LIST 300-600 will display lines 300 to 600 inclusive 4) LIST -1000 will list all lines up to line 1000 5) LIST 30000- will list all lines from 30000 onwards. LLIST Uses the same forms of command as LIST, but lists to the ===== printer. DELETE is used to delete a line or lines from a program. The command ====== can be used as follows:- DELETE 200 deletes line 200 DELETE -300 deletes lines up to 300 DELETE 45-100 deletes lines 45 to 100 inclusive DELETE 30000- deletes lines above 30000 RENUM From time to time you will need to renumber BASIC program ===== lines and when you do this is the command to use from the prompt (Direct Mode.) When a program is in memory (LOADed),it can be simply renumbered just by typing RENUM then pressing [RETURN]. When listed the program will be seen to now start at line 10 and each line will increase in increments of 10. In addition all line numbers referred to in the program and which form part of the program, such as GOTO and GOSUB commands will be changed to conform with the new line numbers. Clever, init?, but line numbers referred to in REM statements or in strings e.g PRINT " Why not list lines 50 to 70" will not be corrected as they do not form a working part of the program. Other forms of the command are ; 1) RENUM 200 when renumbering will start at 200 and increment in 10's. 2) RENUM 3000,80 In this case renumbering will start at 3000, but will start at the old line number 80, ignoring lines below 80 and increase in 10's. This is useful if you have written a program and need to insert some lines. 3) RENUM 3000,80,20 This command is the same as 2) but the ,20 shows that the numbers will be incremented in 20's 4) RENUM 200,,12 This command is the same as 1) but increments in 12's. Note the two commas between 200 and 12. You can easily relate this form to type 3) The commas are obligatory and leaving them out will cause problems. They are called separators and similar separators are used in other commands. If RENUM discovers a reference to lines that do not exist (perhaps you are renumbering a program not yet complete), it will provide an error message such as 'Undefined line 3420 in 4480' , and leave the number unchanged. REN is used to REName a file. The command is REN new-name =old-name === The new name cannot be the same as that of a file already existing on the disc or the command will fail. The file does not have to be in memory. AUTO A very useful command with several uses. At first glance this ==== command is used to provide automatic line numbering when writing a program. commands are as follows; 1) AUTO typed at the BASIC prompt will put the line number 10 at the left of the screen when [RETURN] is pressed, ready for a program line to be added. At each subsequent press of [RETURN] a further number is generated, incremented by 10 producing a 'standard' program numbering. 2) AUTO 200 is the same as above except that the numbering starts at 200 3) AUTO 1000,5 (Note the comma) This command starts the numbering at 1000 and increases in increments of 5 AUTO used as in 1) above can be useful, not only for writing new programs, but in copying programs from magazines,etc. As used in 2) and 3) it can also be of great value in editing programs. When AUTO generates a line number which is already in use, that line is printed to screen in EDIT mode. If several lines with the same numerical spacing are to be edited, a single AUTO command can call them up one at a time, instead of calling each up separately with the EDIT command. A further bonus is that the lines are immediately one below the other, making it simpler to line up menus and similar tables. To get out of AUTO, just press [STOP]. The line being displayed at that time won't be changed. ******************************************************************* End of file INTER.A e changed.