Miscellaneous Commands and Other Information

Recovery From Catastrophe

If by some misfortune you are thrown out of G7 against your will, you can continue right from where you were. Start G7 again and recover the workspace of the previous run of G7 by typing “wsb ws”. If you then issue a “lis w” command you should see that you still have all of the variables that you created before G7 died. Repeat any necessary limits, mode, dates, or other settings.

(q)uit
Quit, that is, close up shop in G7. This is equivalent to picking File | Exit from the menu.
time
Display the date and time.
dos
dos [options] <arguments>
dos [options] [batch file arguments] { ... }
The dos command passes instructions to the operating system. Three versions are offered, along with an important option.

To open a DOS window, simply enter dos with no arguments. G7 pauses until the window is closed. The window may be closed by clicking the button in the upper right-hand corner or by typing “exit”.

To pass single commands to the system, type the desired system commands after dos. For example, to save the workspace bank as “newws”, enter the following:

dos copy ws.* newws.*

To pass a group of commands to the operating system, use the dos{} command. The brackets tell G7 to create a temporary batch file containing the system commands between the brackets. The temporary file is destroyed automatically upon completion. Arguments may be passed to the batch file by listing them after dos and before the open bracket. Here is an example that again copies the workspace.

dos ws newws{
   rem Copying bank %%1 to %%2.
   copy %%1.ind %%2.ind
   copy %%1.bnk %%2.bnk
   }

Note that the syntax required for text within the dos{} command is the same syntax required elsewhere in G7. In particular, in order to pass a ‘%’ character to the system, “%%” must be specified in the G7 script as is shown in the example above.

When the dos command is given with arguments (i.e. as in the second and third cases listed above), the output is captured that otherwise would appear in the DOS window. When the window closes, this output is displayed in the G7 window. No output is displayed on the DOS window. While this often is acceptable and desirable, it is not suitable for running programs or commands that require user input. For this reason, an option is given to execute the dos command in interactive mode. Specify the option by entering “-i” (for interactive) immediately after dos. For example,

dos –i idbuild master

opens a command window and executes the program IdBuild with “master” as a command-line argument. This command is displayed in the DOS window, together with output from IdBuild. If IdBuild requires user input (for example if no configuration file is available), the user will see the prompt in the DOS window and can enter a response. The same option is available in batch mode.

dos -i ws newws{
   rem Copying bank %1 to %2.  Type <ctrl> c to cancel.
   pause
   copy %1.ind %2.ind
   copy %1.bnk %2.bnk
   pause
   }

Multiple commands may be entered on a single line. The commands must be separated by a semicolon and enclosed with brackets. This capability works when there is only one line of G7 input; everything, including the brackets, must be entered on the same line. In particular, this is useful for entering multiple DOS commands in the G7 command box. The following command opens a DOS window, displays the contents of the directory one page at a time, and pauses at the end:

dos –i {dir /p; pause}

Note that the command interpreter also may offer the ability to enter more than one command per line. In Windows 2000, multiple commands may be separated with an ampersand (&). The above command may be entered as

dos –i dir /p & pause
findmode < m|a>
This command controls the search for a series when more than one databank is assigned. Normally, the mode is set to ‘m’, or manual. By default, the bank at position ‘a’ and the default vam file are searched. Series in any other banks may be searched by including the series name with the bank letter and a period. For example, if three banks are assigned, ‘a’, ‘b’, and ‘c’, and a series called “gnp” is in bank ‘c’, then you must specify “c.gnp”. If findmode is set to ‘a’ (automatic), then G7 will search sequentially through each bank in turn until it finds a series named “gdp”.
vammode <s|a>

The vam mode may be set either to ‘s’ (simple) or ‘a’ (advanced). In the simple mode, when a Vam file is assigned, only that file is assigned. The ‘a’ option is used by builders and users of InterDyme models, for which there is a G bank containing the macrovariables of the model in addition to the Vam bank that stores the vectors and matrices. Each time a new simulation is made, both a Vam file and a G bank are created with the same root name. When vammode is ‘a’ and a Vam file is assigned, G7 looks to see if there is a G bank with the same name. If the G bank exists, then G7 loads both banks as a single unit.

For example, if there is a vam file named HIOIL.VAM, with associated macro bank HIOIL.BNK, the following code will assign the two files as a unit:

vammode a
vam hioil a   # Load both hioil.bnk and hioil.vam

If the series “gnp” is in the G bank, you can view the macro series “gnp” with “ty a.gnp”. If the Vam bank contains a vector output, then the vector can be shown with “show a.output”. Note that both commands refer to bank ‘a’. The user alternatively might want to load the banks separately. The following code will load the banks separately.

vammode s
vam  hioil a   # Load hioil.vam only
bank hioil b   # Load hioil.bnk
seed <integer>

The seed command allows the user to initialize the random number generator. The random number generator is used with the @rand() and @normal() functions. The @rand() function provides draws from the uniform (0,1) distribution and the @normal() function provides draws from the standard normal (0,1) distribution. If the seed command with identical arguments is employed between calls to @rand() or @normal(), then these random number generators should return identical series.

For example, the G7 script

seed(20707)
f uni1 = @rand()
seed(20707)
f uni2 = @rand()

will produce series uni1 and uni2 that contain identical elements.

dir [arguments]

The dir command prints the contents of the working directory. <arguments> are legal DOS arguments for the dir command. Note, however, that any ‘#’ characters are interpreted as the G7 comment flag, and so any text after # are ignored.

For example, to display the listing of files beginning with ‘t’, enter

dir t*.*  # This command displays file beginning with 't'

Note that the dir command does not accept the options permitted in the DOS dir command, such as “/w” or “/p”. If such options are necessary, the following G7 entries will allow them:

dos dir t*.* /Os
dos –i { dir t*.* /w & pause }
cd [path]
The cd command allows users to change the working directory. By default, G7 looks to the current directory to read and write files.
pwd
The pwd command prints the path of the present working directory.
break
The break command terminates execution of an add file. If an add file calls a second add file, and the second contains the break command, then upon processing the break command G7 will return to the first add file.
beep
This command typically is used to signal the end of a long script.

Previous topic

Drawing Graphs

Next topic

Regression in G7

This Page