This section covers several new commands and their options. Some of these commands have been described -- in all or in part -- in other chapters, but this chapter should serve as a quick reference for the information. When you are finished, you should be able to:
- Use the ST command to enter Business Rules! from your operating system.
- Understand file structures and DIR listing.
- Use the CHDIR, MKDIR and RMDIR and HELP commands to organize your folders.
- Use the AUTO, DEL, RENUM, and CLEAR commands to edit your programs.
- Use the DATE and TIME commands.
- Understand the use of wildcard characters.
- 1 9.1 Differences between Commands & Statements
- 2 9.2 Memory Structures
- 3 The File Reference
- 4 9.3 Folder management commands
- 5 CHDIR command
- 6 DIR Command
- 7 MKDIR Command
- 8 RMDIR Command
- 9 9.4 The DIR command and results
- 10 More About Files
- 11 Copy Command
- 12 Wildcards
- 13 V option
- 14 D Option
- 15 Rename Command
- 16 FREE Command
- 17 The DROP command
- 18 The Auto Command
- 19 The RENUM Command
- 20 The DEL Command
9.1 Differences between Commands & Statements
Earlier in this tutorial you learned that you could use PRINT as a command. Although PRINT is most often used as a program statement, Business Rules! also lets you use it without a line number for immediate information about a variable or an arithmetic operation. PRINT works like a command in such cases.
Except when used within a PROC or with the EXECUTE statement, the commands that you will learn about in this chapter can only be used in immediate mode. This means that they are only commands and cannot be used as statements.
Entering and exiting Business Rules!
The BR command allows you to enter Business Rules! from your operating system, and the SYSTEM command offers you the best way to exit from Business Rules! to your operating system. It is also possible to exit some versions of Business Rules! with Ctrl-Alt-Del or by turning off your computer, but these methods are not recommended because they could result in loss of data from some data files (specifically from internal files, which will be discussed in a later chapter).
The BR command
Assuming that Business Rules! has already been installed to your system and assuming that you are accessing the folder which contains the files for Business Rules!. If you are using Windows, you enter Business Rules! simply by clicking on the BR Native icon, and you can skip this section, as it will benefit mostly Unix or Linux users. In DOS mode, BR used to be opened using the BR command following the prompt (such as A:>, B:>, or C:>) In Linux/Unix, it would follow the ($) sign.
There are three forms of the BR command. You should use the one which is designed for your operating system or Business Rules! version. If you are using the Unix or Linux operating systems, you will need to enter the command in lowercase letters: br, followed by the enter key. If you are using a version of Business Rules! which includes the math co-processor chip, you must enter br 8087 (ENTER). You may use br (ENTER) for all other operating systems or Business Rules! versions.
The BR command will cause your screen to go blank for a moment. You will see a sign-on screen with some information about Business Rules! and then the friendly READY prompt will appear in the left corner of the status line. Special technical note: On licensed versions of Business Rules!, this could take 20 seconds unless you hit one of the keys (just pick any one) when the licensing screen (the one with your address) is on the screen.
While the BR command is often used in the form described above, its syntax illustrated below also allows you to include up to three additional options. (These three options must be enclosed within quotation marks when you are using Unix/Linux versions of Business Rules!.)
BR instructions -id -file -ref
a) Instructions - With the “instructions” portion of the command, you can specify any Business Rules! command or statement. Business Rules! will then execute the specified command or statement immediately after the READY prompt appears on the status line. The CHAIN statement, which causes the system to load and begin executing the specified program, is often used as the instructions portion of the BR command. This is illustrated in the following example:
BR CHAIN “SHOESALES”
b) -id - The “-id” portion of the BR command is usually used with multi-user versions of Business Rules!. It allows you to specify a workstation identification number. The number must be two digits which represent an integer between 1 and 99, as in the following example:
c) Filename - The “-filename” portion of the BR command allows you to specify the configuration file that Business Rules! should use. (The configuration file provides Business Rules! with default information. If you wish to change the defaults that are natural to Business Rules!, you must do this by creating and using an alternate configuration file.) The following example shows how the BR command can be used to specify the configuration file CONFIG1:
If no -filename is specified, Business Rules! will look for a file with the special name BRconfig.sys; if BRconfig.sys cannot be found in the current folder, Business Rules! will use its own set of internal defaults (except for Unix, Linux, and network versions which must have a configuration file).
The BR command allows you to use one, two, or all three of the options described above. You can also condense all of the above options into one command, e.g.: BR “CHAIN SHOESALES -08 -CONFIG1”
The SYSTEM command
The proper way to exit from Business Rules! is to use the SYSTEM command. SYSTEM may only be used when the READY prompt is showing in the status line. When this command is used, Business Rules! returns you to the operating system. If no other file is active, the operating system prompt should appear. SY is the shortest allowable abbreviation of the SYSTEM keyword:
- Turning off the computer
If you do a great deal of experimenting with Business Rules!, it is possible that you will, at some point of other, get yourself into such a mess that you cannot even use Ctrl-Alt-Del to exit the system. In such a case, the only alternative is to turn off your computer. When you turn it back on again, the operating system will boot up.
Turning off your computer will have much the same effect as Ctrl-Alt-Del does. All information in temporary memory will be lost, and it is possible that files which were open at the time of exit will be corrupted. This method of exiting from Business Rules! should be used only when there is no other alternative.
Quick Quiz 9.1=
1. What does the BR command do?
a) Allows you to enter the operating system from Business Rules!.
b) Allows you to change the operating system prompt from $ to C>.
c) Allows you to enter Business Rules! from the operating system.
2. Which of the following commands allows you to enter Business Rules!, then automatically loads the program WELCOME?
a) BR LOAD WELCOME
b) BR -WELCOME
c) BR WELCOME
3. In which of the following instances can you use the SYSTEM command to exit Business Rules!?
a) Whenever program execution has been halted or is inactive.
b) When Business Rules! gets stuck in an infinite loop.
c) During READY mode.
9.2 Memory Structures
This explanation will cover the way that a computer stores information, or memory.
First off, it’s important for you to understand the difference between temporary memory (sometimes called Random Access Memory or RAM), and permanent memory. Temporary memory is the place where the computer holds information that you want to work with right now. You can LOAD information from permanent memory into this place, or you can use temporary memory to hold something entirely new (such as a program that you are creating) until you are ready to SAVE it. The key thing to remember is that the computer loses everything in its temporary memory as soon as you turn it off (or when the power fails). That’s why it’s important to frequently SAVE and REPLACE the files that you are working on.
Permanent memory is the place where the computer stores any information that you tell it to SAVE. The permanent memory in your computer is most often your hard drive. The rest of this section will explain the ways in which the information in permanent storage can be organized.
Many computers have more than one hard drive, in addition to other storage devices, such as DVD and Blu-ray readers, USB flash drives, etc. In order for the computer to be able to tell which device is where, each is assigned a drive letter. This drive letter is always a letter followed by a colon, such as C:, D:, or E:. (A: and B: are usually reserved for older floppy drives and are rarely used anymore.) However, Business Rules! also maintains its own listing of drive letters, and these are mapped to different locations, or folders, on your hard drive, using the DRIVE statement in the BRCONFIG.SYS file. For example, from within BR, drive C does not necessarily mean your computer’s drive C, but the folder designated to be C in BRCONFIG.SYS. The same goes for any folders designated as different drives within BRCONFIG.SYS. In the figure below, drive c: , . , \,\ means that the currect folder is designated C for BR.
Since hard drives (or BR folders designated to be drives) can hold trillions of bytes (or characters) of information, it is often helpful to organize their storage space into sections, or folders, just as you might divide a huge textbook into separate chapters. Depending on your needs, each of these folders can also be divided into subfolders, each of which can further be divided into more subfolders, and so on.
When diagrammed, the organizational structure of a memory device looks something like an upside-down tree. At the top of the diagram is the root folder. Its space encompasses the entire drive, and it often acts as sort of a table of contents for what is in that memory space. Unless an alternate folder has been specified as the default, it is possible to see a listing of this root folder by specifying the DIR command and the drive letter of the root folder you wish to see. Open windows explorer to where you have been saving the BR programs you’ve created in this tutorial to see what a tree looks like.
To see how folders appear from within BR, type in DIR. to list everything in your current drive.
Interpreting this listing will be discussed more in the next lesson, but for now notice how folders and files are displayed. Files and subfolders are listed, and the subfolders are identified by the symbol <DIR> in the second column of text.
These sub-folders divide the main folder into smaller pieces, just like chapters divide a book into smaller sections. The Business Rules! rules for naming a sub-folder are the same as the rules for naming a file (the folder name must start with a letter, with an optional period and three-character extension after the folder name). If file or folder names are longer than 8 characters, BR will use the first six characters followed by “~” and a number.
Look again at the contents of your current sub-folder of BR programs by listing them with DIR subfolder name -p to go page by page. In this figure, the subfolder is called Sample_Cd:
Notice that the location \sample_cd\ or folder name, is listed in the second line. In the next row, you see a single dot and the second row has two dots (in DOS). These two rows are designed to help you to keep track of the path, or lineage, of the files in the listing. The row with one period represents the root folder; the row with two periods represents the sub-folder. You should see then that the files are one level below the root folder.
All levels of folders may contain files as well as other sub-folders. From here on we will use the terms folder and sub-folder interchangeably -- after all, every folder is a sub-folder except the root folder.
The File Reference
The chain of folders that leads from the root folder to a particular file is called the path. A file reference (or file-ref) is the combination of drive letter, path, filename and extension (along with the appropriate punctuation). In the next lesson, you will learn how to use the CHDIR command to set the default drive letter and path. Business Rules! requires you to specify the file reference of any program that you wish to LOAD or SAVE. The syntax of this file reference is as follows:
a) Drive: The “drive” portion of the file-ref syntax indicates the letter of the drive where the file can be found. Remember, the colon is considered part of the drive; whenever a drive letter is used, it must be followed by a colon. If no drive is specified, the current default drive will be used.
b) Path: The “path” identifies the sub-folder in which you are trying to open. This must be specified by a list of folders starting with the highest-level parent folder (directly under the root folder) and ending with the parent folder of the file itself (if the file is in the root folder, the path will be empty). Each folder name must be followed by a backslash -- except the root folder. If this list of folders does not begin with a backslash, the path for the default folder is automatically inserted at the beginning of the specified path. In other words, you may omit the part of the file-ref that matches the default path; for instance, if the default path is “C:\brfiles”, then “myfiles\file.brs” would be a legal file-ref for the file located at “C:\brfiles\myfiles\file.brs”.
c) \filename: The “filename” portion indicates the name of the file you are looking for. Sometimes, you may use wildcard characters (* and ?) instead of the actual file name (read on to find out more about these creatures).
d) .ext:The “.ext” portion tells Business Rules! what the three-letter extension of the file name is. It must be preceded with a period, and wildcard characters may be used. The above information is required within the syntax of a number of commands and statements, but it is usually referred to only as the file-ref. If you forget what information should be included in a file-ref, you should refer back to this lesson or to the rest of the wiki.
Quick Quiz 9.2
1. In which of the following examples will your temporary memory (RAM) be saved?
a) When you shut off your computer without using the SAVE or REPLACE commands.
b) When you SAVE and or REPLACE your files that you have been working with before you turn your computer off.
c) The power fails and your computer is shut off.
2. The file reference (or file-ref) is...
a) A special feature of Business Rules! that you will rarely ever use.
b) The trail of folders that leads to a particular file.
c) A combination of drive letter, path, filename and extension (along with the appropriate punctuation) that leads to a particular file.
9.3 Folder management commands
Now that you know all about the concepts of folders and sub-folders, it’s time to learn how to set defaults, list, create, and remove folders. Four commands which will help you do this are CHDIR, DIR, MKDIR and RMDIR.
When we say that you are in a particular folder or sub-folder, we mean that this is the folder that Business Rules! is currently accessing. This folder is often referred to as the current folder or the default folder. The CHDIR command (for changing folders) does two jobs: it displays the current default drive and folder, and it changes the current default folder and drive.
The CHDIR command may be abbreviated CH or CD. It is used to change the drive as well as change the folder, but not both at the same time.
It is very easy to use the CHDIR command to display the current defaults, so let’s do it. Let’s find out which drive and folder Business Rules! uses immediately after it starts up.
If your computer is already running Business Rules!, please exit and restart Business Rules! (just in case the defaults may have changed somehow since your system was started). If your computer is not already running Business Rules!, then please start it now.
Make sure that your status line says READY. Now type the following command: CHDIR
It is important to remember that, for this command, there are lots of possible correct replies that your system may return. Your screen will probably look like this:
If your computer has loaded Business Rules! from drive D:, your screen will have a D instead of a C.
This simple form of the CHDIR command is like a “where am I” command because it is always available to tell you the drive and the path of the folder you are currently in.
The second use of the CHDIR command is to change the current folder. The basic syntax is:
For example, to change the default folder to a folder called CHAP9. Type in: CHDIR CHAP9
(Notice that the drive: portion of the syntax above is ommitted. It’s optional and doesn’t need to be typed every time).
After this command has been entered, Business Rules! automatically accesses the CHAP9 folder unless it is explicitly told to do otherwise. For example, enter the command DIR The system will automatically give you a listing of the CHAP9 folder.
Suppose you want to get a listing of the root folder again. There are two ways to do it. To do it with one command, you must now specify DIR c:\ . Alternatively, you could enter two commands. First, to change the default folder back to the root folder again, you must enter:
Just type DIR C: to see the listing for the root folder.
The purpose of the DIR command is to provide information about files and sub-folders in a specified folder. The simplest form of this command is DIR which lists the current folder.
How do I stop DIR from going off the top of the screen? Often the DIR listing fills up more than one screen, and the first part may scroll off the top of the screen before you can read it. To stop DIR (or any screen output) from scrolling, you can hit the ESC key; this puts Business Rules! in HOLD status. When you are ready to continue, you can take your screen off of HOLD by hitting ESC again to get it restarted.
Another way to stop scrolling is to add the “-p”, the pause option on the end of the DIR command. Try it by typing the following:
DIR C: -P
This option controls scrolling by only showing you a screen full of information at a time. As soon as the screen fills up, it stops automatically, then waits for you to press a key (any key will restart it) before it shows the next screen.
The basic syntax of DIR is:
After the keyword DIR, any or all three parts are optional. In general, if drive or path is omitted, the drive or path for the current default folder will be used. Here are some common forms of the DIR command.
DIR - Lists all files and sub-folders from the current default folder and drive.
DIR \ - Lists all files and sub-folders from the root folder of the current default drive.
DIR a: - Lists all files and sub-folders from the current default folder on drive A.
DIR SUBDIR - When SUBDIR is a valid sub-folder found in the current default folder and drive, this command lists all files and sub-folders in SUBDIR; if SUBDIR is not a valid sub-folder, error 4152 occurs; if only a file is found, only the file is listed. Use DIR with any subfolder name in the current folder to list its contents.
DIR FILE.EXT - If FILE.EXT is a valid filename found in the current default folder and drive, only this one file is listed; if not found, error 4152 occurs; if found but is a folder, it’s contents are listed (current default drive and folder are not used).
DIR D:\SUBDIR\FILE.EXT - If FILE.EXT is a file in SUBDIR immediately below the root folder, only this one file is listed; if not found, error 4152 occurs (current default drive and folder are not used).
DIR FILENAM* - If you can remember the first part of a program name, you can search using the wildcard asterisk (*) to mean “everything else”. This command will list all files or folders that begin with the letters “filenam.” In another example, DIR CHAP* will list everything that begins with CHAP.
One important pattern in these examples is that the current folder and drive are not used when a drive letter is followed by a colon and a backslash. This distinction can be applied to many Business Rules! commands and statements. The principle is that there are two ways to specify a file reference (folder names are included in file-ref, too).
One type of file-ref uses absolute paths. An absolute path starts with the root folder and provides a complete list of folders that must be accessed to locate the specified folder or file. Absolute paths always start with a backslash for the root folder. Because an absolute path provides a “complete” road map to the desired file or folder, it does not matter what the current default folder is (provided you are accessing the correct drive).
The other type of file-ref uses relative paths. A relative path starts with the current default folder; it is a shorter list of folders (maybe none) that are needed to locate the specified folder or file. A relative path never begins with a backslash. Because a relative path uses the current default folder, a command using a relative path may or may not succeed depending on what the default folder is.
Let’s try a few examples, using the programs you’ve created already. Can you write and enter a DIR command with an absolute path to list the contents of the folder you’ve stored them in? Don’t forget to include the drive letter. One example might be:
To change it to a different subfolder, you might type:
Now what would happen if we entered the same DIR command with an absolute path that you just wrote and entered? Would it show us the same information? Something else? An error? The answer is that it should work the same from any folder. If you had trouble writing one, first list all subfolders and files in your current drive and then choose one to use.
Now let’s try to get the same information from our current folder with a DIR command that uses a relative path. You may want to read the definition again. A hint is to try just typing DIR to see how close you are.
Well, if you haven’t got it yet, here is the answer for our example. The folder Programs can be listed with a DIR command using a relative path by typing DIR programs. Try it!
Finally, let’s test this relative DIR command from another folder. What CHDIR command will take you back to the root folder on drive c? Here are two correct answers from our current folder:
CHDIR C:\ CHDIR \
The second one changes only the default folder and keeps the same default drive; it works when the default drive is already drive C. The first one takes you to the root folder of the drive you are currently working in.
As a final step in these examples, try the same relative DIR command from this folder that you used before changing folders. For our example, type DIR Programs. You should get error code 4152. The reason is that the current drive and folder are always added to the front of anything that does not start with a backslash; the system cannot find any field or folder with the resulting name D:\Programs. It is not in the root folder with the resulting name D:\Programs.
How to get DIR (and friends) on the printer
The output of any DIR command can be sent to the printer by adding the keyword PRINT to the end of the command. For example,
DIR C:NEWDIR PRINT <------- listing to printer
The ouput can also be saved in a different file, for example:
DIR C:NEWDIR >file-ref <------- listing saved in a file with filename specified by file-ref
Notice that using either “PRINT” or “>file-ref” is called output re-direction (because it re-directs or changes the output from the screen to another place that you specify). Output re-direction is also available with the LIST, RUN and TYPE commands and with limited parts of the output from some other commands (Consult syntax diagrams in the wiki).
One special case may cause a problem. The system looks for the keyword PRINT only as the third part of a DIR command.
CHDIR D:\ <--- Change to root folder of drive D
DIR <--- Listing of root folder of drive D on screen
DIR PRINT <--- Error code 4152; file not found
DIR D: PRINT <--- Listing of root folder of drive D on printer
You might think that the DIR PRINT command would produce the same listing that the DIR command produced, except on the printer. The reason that DIR PRINT gives an error is that the system always uses the second part of this command (after the blank space after the keyword DIR) as a filename or folder name. Since there is no file called PRINT in the current defaultfolder and drive, an error occurs for file not found.
The solution is to put a valid folder name or filename after the keyword DIR, then put the keyword PRINT on the end (that is, make it the third part of the command). By the way, this problem does not occur with >file-ref; can you figure out why?
The very first time that a memory device such as a hard disk is used it has only one folder, the root folder. If you wish to use additional folders or sub-folders, you must tell Business Rules! to create them. The MKDIR (make directory) command does just this. Its general syntax is:
“drive:” tells Business Rules! which memory device it should use when creating the new folder or sub-folder. The drive letter must be followed with a colon (:). The parameter “drive:” is optional; if it is omitted, Business Rules! will use the current default drive.
“path” specifies the name of the new folder to be created. It may be either an absolute path or a relative path. Remember, absolute paths start with a backslash to indicate that the path you are specifying begins at the root folder. Also, relative paths do not start with a backslash; the system assumes that the current default folder is the starting point and that the “path” that you provide tells where to go from there.
Here are some examples. Remember, paths that start with a backslash have effects independent of the current default folder, but effects of relative paths depend on the default folder.
MKDIR TEST - Makes a new folder called TEST, which is a sub-folder of the current default folder on the current default drive.
MKDIR \TEST - Makes a new folder called TEST which is a sub-folder of the root folder on the current default drive.
MKDIR C:\TEST\NEXTTEST - Looks for a sub-folder called TEST (which must be a sub-folder of the root folder on drive C) and gives an error if there isn’t any such folder. If TEST is found, this command makes a new folder called NEXTTEST, located on drive C, in a sub-folder called TEST which is a sub-folder of the root folder (current default drive and folder are not used).
MKDIR TEST\NEXTTEST - Looks for a sub-folder called TEST (which must be a sub-folder of the current folder) and gives an error if it doesn’t exist. If TEST is found, it makes a new folder called NEXTTEST, which is a sub-folder to TEST, which is a sub-folder of the current default folder on the current default drive.
MKDIR D:SUBDIR\TEST - Looks for a sub-folder called SUBDIR (which must be a sub-folder of the current folder) on drive D, and gives an error if it doesn’t exist. If SUBDIR is found, this command makes a new folder called TEST, which is a sub-folder to SUBDIR, which is a sub-folder of the current default folder on drive D (current default drive is not used, but the current default folder is used).
Now, let’s experiment. Enter the following command: MKDIR C:\NEWDIR
When the system has finished responding, take a new look at the root folder listing for drive C. (Enter the command DIR C:)
You have just created NEWDIR as a sub-folder of the root folder; its name should appear in alphabetical order of the folder listing.
Now enter this command:
If you enter a DIR C: command when the computer finishes processing the MKDIR command, you should find that nothing seems to have changed. SECDIR does not appear in this listing because the above command indicated that it should be made as a sub-folder of the NEWDIR folder. Enter the command DIR C:\NEWDIR to see a listing of the entire folder within which SECDIR is located.
If you wish to see a listing of the contents of the SECDIR folder (since you haven’t created any sub-folders for it or saved any files to it, it will be empty), you can enter the command DIR D:\NEWDIR\SECDIR.
When you no longer have a need for a particular folder or sub-folder, you can remove it with the RMDIR command. RMDIR works only when the folder contains no other sub-folders or files. The basic syntax of this command is:
Once again, the drive is optional if you wish to refer to the current drive. The other rules and definitions described with the MKDIR command apply to RMDIR as well. Also, the examples given for MKDIR would have similar effects -- except that the specified folder would disappear rather than appear!
Let’s experiment with this command by removing the sub-folders you created with the MKDIR command. You must remove the SECDIR folder first, since Business Rules! will not allow you to remove NEWDIR until you remove SECDIR first. A folder must be empty (contain no files or folders) before it can be removed. To remove SECDIR, enter:
Now enter a DIR D:\NEWDIR command to see if the SECDIR sub-folder is really gone. If so, then enter the command that will remove the \NEWDIR folder (you figure it out this time).
Quick Quiz 9.3
Refer to the folder containing your programs. Can you enter a DIR command with an absolute pathname to list the folder information for the file NEWSAL? Don’t forget to include the drive letter.
9.4 The DIR command and results
You have already used the DIR command and studied the DIR listing a number of times, but let’s go through its parts now.
The first line of the listing, Directory of C:\*.*, is the file reference of the folder. You did not specify the \*.* portion of this file reference in your DIR command, but Business Rules! inserted it anyway--it simply indicates that all files on the directory, no matter what their name or extension, are represented in this listing.
The following lines of the listing give information about the files and sub-folders of this folder. The name is in the first column. Notice that if names were longer than 8 characters, they last two spaces are a ~ symbol and number. The second column contains the extension (if there is an extension) of each file or sub-folder. The third column shows the file size, in bytes, (or kilobytes, if labeled KB). If the item in the first column is a sub-folder, the phrase <DIR> appears in this column instead. The fourth column lists the date of the sub-folder's creation (or the date that a file was most recently changed), and the fifth column lists the time at which that creation or last change occurred. The last column lists the complete name and extension of each file. Once you’ve scrolled through the entire list, it should look like this:
The last line of the listing tells you how many files and sub-folders exist in this folder, the total number of kilobytes that these files and sub-folders take up, and the total number of kilobytes that are still available for use.
More About Files
Although you have so far only learned how to create program files, there are many other types of files that a computer can store. You will learn about all these file types and more when you get into the file processing chapters of this tutorial.
File management commands:
You have already learned how to SAVE and REPLACE program files, but there also will be times when you’ll want to copy, rename, or get rid of some files. Four commands that should help you fill these needs are COPY, RENAME, DROP, and FREE. “FILE NOT FOUND” errors:
When you first learned to save a file, you found out that Business Rules! automatically appends an extension of .BR onto all program filenames that are not given another extension. You also found out that you could continue to load, save and replace your fields without specifying this extension: Business Rules! automatically did it for you.
But if you now try out some of the commands in this section (COPY, RENAME, DROP or FREE), you’ll find out that you’ll get “File not Found” errors when you forget to include a .BR extension. This is because the commands in this section are very critical: an error about exactly which file you are referring to could cause lasting damage here. Business Rules! makes no assumptions about the name of a file with any of these commands except current folder and drive.
The COPY command copies one or more of your files from one spot in memory to another (the original file stays where it is, and a duplicate is placed in the location you specify). The general syntax of this command includes the COPY keyword, a “from file-ref” portion that specifies the current location of the file to be copied, and a “to file-ref” portion that specifies where the newly copied file should be placed, and the -D and -V options (DV isn’t required): COPY from file-ref to file=ref -DV
The following example specifies that the file EGGROLL.CST, which is located in the sub-folder RSTRUNT on drive C: should be copied to the subfolder and saved in drive D:
COPY C:\RSTRUNT\EGGROLL.CST D:\FOODCOST
The use of the asterisk (*) as a wildcard character also allows you to copy groups of files -- or even all the files in a sub-folder -- from one spot to another. Just as wild deuces can represent any card you want when you’re playing poker, the * can represent any type or any number of characters that you wish to specify in filenames.
As an example, let’s imagine that you would like to copy the complete contents of a diskette in drive D to the sub-folder WASHO on drive C. One way would be to copy each file individually. A much quicker way however, would be to use the following command:
COPY d:\*.* C:\WASHO\*.*
This statement tells Business Rules! to copy every file in drive D, no matter what its name is, to the sub-folder WASHO in drive C. The copied files will retain the same names as the originals.
Another wildcard character, the question mark (?), fills in the character for any one position that you specify. As an example, imagine that you have been working on the program SHAD.BR all day. Each time that you made changes to it however, you replaced it with a new name; you now have four files--SHAD1.BR, SHAD2.BR, SHAD3.BR and SHAD4.BR--that you would like to copy onto a diskette. To do this all with the same command, you could specify:
COPY C:SHAD?.BR d:SHAD?.BR
When Business Rules! executes the above command, it compares the specified file-ref to all the files in the root folder on drive C. Anytime that it finds a file with a name consisting of SHAD followed by one character (any character) and the extension BR, it copies the file to the specified location. This command would also copy SHAD.BR which also matches the description.
Wildcard characters can even be specified together to specify the name of a file. In the following example, all files in the sub-folder VOL on drive D that have a name consisting of JAME followed by one character and any extension will be copied to the sub-folder UNIT on drive d:
COPY d:\VOL\JAME?.* d:\UNIT
An important consideration about using wildcard characters with COPY (and other commands such as RENAME, DROP, and FREE) is that you may not always want the entire group of files that is denoted with the wildcard character to be processed with the command. To prevent mistaken processing of files, you can specify the V option so that the system requires you to verify that a particular file should be included. This option must be separated form the rest of the command with a hyphen (-).
To see an example of the V option at work, acess your folder of BR programs. Use the DIR command to find out what files are listed. Now create a subfolder called CHAP9 as described earliers, and enter a command to copy some files into it: COPY c:\FOLDER\EXAMP*.BR c:\CHAP9 -v
Business Rules! will now display the name for the first file it can find that fits the description you entered. You are asked to verify whether or not the file is to be copied. If you enter “n”, the system will simply go on to find the next listing that fits the description. If you enter “y”, the system will copy the listed file to the CHAP8 sub-folder and then go on to find any others. If you enter “all”, the system copies the listed file and all remaining files that fit the description (it no longer asks for verification).
You may also use the -D option with the COPY command. This option tells the system to omit deleted records from the copy procedure. The -D option is used only with internal files, and will be discussed in greater detail in a later chapter.
Business Rules! RENAME command provides a simple way to change a file’s file-ref or file name. The format of this command is as follows:
RENAME current file-ref new file-ref -V (The V part is optional) RENAME current file name new file name -V
In other words, you enter the RENAME keyword, the current name (or file-ref) of the file you wish to change, and the new file-ref or name that you wish to assign to the file. Business Rules! then assigns a new name to the file without making any changes to the file’s contents; the file’s old name will no longer exist. If you specify a current file name, you must specify a new name only (not a file-ref). Likewise, if you specify a current file-ref, you must specify an entire file-ref (either relative or absolute).
Notice that the RENAME command allows you to change a file’s full file-ref. This means that the command can be used to rename the file or to reassign it from one sub-folder to another. An example is the following, where the file ESTIMATE, which has a file-ref of D:\FINANCE\ESTIMATE, is moved from the FINANCE sub-folder to the BUDGET sub-folder:
RENAME D:\FINANCE\ESTIMATE D:\BUDGET\ESTIMATE
Since Business Rules! allows you to use wildcard characters (* and ?), you may also rename or reassign a group of files with the RENAME command. As an example, imagine that you have named all six programs that you wrote in October with a .10 extension, and you decide to move these files to a sub-folder called OCT. The following RENAME command, which uses an asterisk in the file name position, reassigns the entire group:
RENAME D:*.10 D:\OCT\*.10
As with the COPY command, the V option can be used with RENAME so that all RENAME actions must be verified by the operator (see the COPY command in this chapter, for more information). The use of the V options is strongly recommended for all RENAME, DROP, FREE and COPY commands that utilize wildcard characters. It must always be separated form the rest of the command with a hyphen (-), or do a DIR with the same file spec. to visually verify all files displayed are the ones to be renamed, copied or deleted.
FREE is used to delete one or more files from the system. Its general syntax includes the FREE keyword, the file-ref of the file to be deleted (wildcard characters may be used), and the V option:
FREE file-ref -v
You must be extremely careful with your use of the FREE command; files cannot be recovered again once the system has freed them. The following example of FREE causes the file LEVELOR.WB, in the WINDOWS sub-folder, to be deleted:
The DROP command
The DROP command deletes the contents of a file. The file will still exist (a DIR listing will display the names of all dropped files), but it will be empty. The syntax of this command includes the DROP keyword, the file-ref of the file to be dropped (wildcard characters may be used) and the V parameter, which is optional:
DROP file-ref -v
The contents of a file that have been dropped cannot be recovered, so you must be careful when using this command. The following example of DROP causes the contents of the file MANGER.WB to be deleted. The file’s name will continue to be reserved:
Quick Quiz 9.4
1. What command should you use to move a file from one sub-folder to another?
2. What command should you use to put a duplicate of a file onto a floppy diskette?
3. Which of the following file names would match the file reference CLA*.WB?
d. All of the above.
4. Which of the following file names would match the file reference WHIST?.WB?
d. All of the above.
5. When is it recommended that you use the V option with the COPY, RENAME, DROP and FREE commands?
b. Whenever a wildcard character is used in the file-ref.
c. whenever you know of two or more files that could fit the file-ref description.
The Auto Command
You’ve probably learned by now how tedious it can be to keep track of line numbers and type new ones in at the beginning of each program line. The AUTO command tells Business Rules! to automatically number the lines in your program for you. Every time you finish typing in a program line and press ENTER, the computer will give you a new number to start your next program line with. Each new number will be ten greater than the last number (so that there will be room to insert extra program lines later).
Once you have specified the AUTO command, Business Rules! will automatically continue to supply you with a new line number each time you press ENTER until one of the following occurs:
1. The next line number would exceed 99,999. 2. You press ENTER before typing a statement. 3. You erase the supplied line number. 4. You move the cursor up or down to another line.
The syntax of the AUTO command is(Line# and increment are optional) :
AUTO line# increment
The syntax of the AUTO command includes two optional parameters. The “line#” parameter allows you to tell Business Rules! which number to start with in its automatic numbering. The “increment” parameter allows you to specify the amount to be added to each line number when the next line number is being produced (this second parameter can be used only when the first one is also used). The following AUTO command causes automatic numbering to begin at line 900 with an increment of 100 between each program line: AUTO 900 100
The RENUM Command
At the beginning of this tutorial, you learned that programmers typically increment their line numbers by ten or more so that there is room for later insertions. Now that you’ve had the chance to work on a few programs of your own, you’re probably aware that insertions are very common. You may even have found that an increment of ten was not enough for all the insertions you decided to make, or you may have decided that your revised programs need to be renumbered so that all the program lines are neatly incremented again. The RENUM command allows you to do just this. It takes a group of line numbers that you specify and renumbers them, using the increment you specify. The general syntax of this command is as follows (all four of these parameters are optional):
RENUM -starting line# -ending line# first line# increment
The RENUM command without any parameters will renumber the entire program so that it begins with line 10 (the default for “first line #”) and all following line numbers are incremented by 10 (the default value for “increment”).
The RENUM command with “first line #” and “increment” will also renumber your entire program, but allows you to specify the new numbers. The “increment” parameter allows you to indicate how many line numbers that should be skipped between each assigned line number. When “increment” is not specified, Business Rules! uses a default increment of ten.
For example, RENUM 1000 50 will produce a program starting with line 1000, and the following lines will be incremented by 50 (e.g., 1050, 1100, 1150, 1200, etc). If only the “first line #” was specified, RENUM 1000 would renumber the entire program to start with line 1000, but increment by the default of 10.
If you want to renumber a group of lines within the middle of a program, you may also specify the “-starting line#” and the “-ending line#”. These two refer to the start and end of the block of lines to be renumbered. If “-starting line#” is specified, you’ll probably have to specify the “first line#” since the default of starting with line number 10 might generate an error code 2020 (illegal RENUM range) because the new line numbers overlap with existing line numbers.
The following RENUM command for instance, causes lines 330 to 480 to be renumbered; line 330 is assigned the new line number of 500, and the rest are assigned numbers in increments of ten:
RENUM -330 -480 500
It is important to know that the RENUM command will also automatically adjust all line numbers in branching statements like IF, GOTO, GOSUB, ON GOTO and ON GOSUB. If only a block of lines in the middle of a program is renumbered, lines in other parts of the program are also checked so that line numbers in branching statements are correctly adjusted wherever necessary.
The DEL Command
The DEL command allows you to delete lines from a program. The syntax is as follows:
DEL first line number last line number
You can delete them one at a time, for example:
This will delete line 350 only. Or, you can delete several lines at once, for example, from 350 to 380:
DEL 350 380
Quick Quiz 9.5
1. What is the best way to erase a program line?
a. Use the delete key (or its equivalent).
b. Use the backspace key (or its equivalent).
c. Use the DROP command.
d. Use the DEL command.
2. What does the following AUTO command do?
AUTO 40 50
a. Causes line numbers 40 to 50 to be renumbered using the default increment of 10.
b. Causes automatic line numbering to begin at line 40 and end at line 50.
c. Causes automatic line numbering to begin at line 40 and use an increment of 50.
3. What does the following RENUM command do?
RENUM -30 -400 10 40
a. Causes line numbers 10 through 40 to be renumbered. The first new line number will be 30 and the last new line number will be 400.
b. Causes line numbers 30 through 400 to be renumbered. The increment will be 10 and the first new line number will be 40.
c. Causes line numbers 30 through 400 to be renumbered. The first new line number will be 10 and the increment will be 40.
4. What happens when you type a new line number over the line number of a current statement in a program?
a. The current line is deleted and the new line is inserted into the program. Only the new line will appear in the next program listing.
b. Neither line is valid.
c. The current line is copied for use with the new line number. Both lines appear in the next program listing.
5. Which statement is true about the following DEL command?
DEL 70 130
a. Causes all lines between 70 and 130 to be deleted.
b. Causes lines 70, 130, and all lines in between to be deleted.
c. Causes lines 70 and 130 to be deleted.