Please enable JavaScript to view this site.

R:BASE 11 Help

Navigation: Command Index > R

RUN

Scroll Prev Top Next More

Use the RUN command to run command blocks, command files, and command files requiring passed parameters.

 

RUN

 

Options

 

cmdfile

Specifies the name of the command block or command file to execute.

 

On a workstation with multiple drives (local or mapped), especially when the files are on the different drive, it is always the best practice to define a drive letter when copying, deleting, renaming or running files, unless the specified files are located in the working directory. You will not need to specify the drive letter if all of the files are located in the default directory when using the copy, delete, rename or run commands.

 

IN procfile

Specifies the name of a procedure file. A procedure file is a compiled binary file that contains stored menu, screen, and command blocks. Include a drive and path name if the procedure file is not on the current drive and directory.

 

password

Specifies the file password if encryption was specified when the file was saved or created. See OUTPUT for the command syntax to encrypt database information output. See R:BASE Editor for information on saving encrypted command files.

 

SELECT VARCHAR clause

Specifies a column defined with the VARCHAR data type from a table, then you can run the contents. The SELECT clause must limit the data to only one row; otherwise, an error is returned.

 

USING parmlist

Lists the values the command file uses when it runs. The parameter list can contain up to 18 values. The first value in the list is referenced in the executed file as %1, the second as %2, and so on through %9. They are treated just like other variables. To reference the contents of these variables, preface the variable name with a dot (.); for example, SET VAR v1 =.%1.

 

About the RUN Command

 

The RUN command must be on a line by itself and not combined with other commands.

 

Examples

 

The following command runs a file named MYCMD.CMD in the current working directory.

 

RUN mycmd.cmd

 

The following command runs a command block named mycmdfilin the MYPROCFL.APX procedure file.

 

RUN mycmdfil IN myprocfl.apx

 

The following command executes the mycmdfil command block in the MYPROCFL.APX procedure file, placing the parameter values, Display This Message and 10, into parameter variables %1 and %2, respectively.

 

RUN mycmdfil.rmd USING 'Display This Message' 10

 

The following commands, which use the system variable #time, make up a timing procedure called mycmdfil.rmd. This procedure displays the message passed as parameter %1 for the length of time indicated in parameter %2. When executing the RUN command at the R> Prompt, it causes mycmdfil.rmd to display the message for 10 seconds.

 

--mycmdfil.rmd

SET VARIABLE vstart TIME = .#TIME

SET VARIABLE vwait INTEGER = 0

WHILE vwait < .%2 THEN

  SHOW VARIABLE %1

  SET VARIABLE vwait = (.#TIME - .vstart)

ENDWHILE

CLS

CLEAR VARIABLES vstart, vwait, %1, %2

RETURN

 

With applications that frequently pass parameters with the RUN command, it is recommended to set variables to the value of the passed parameters within the command file being RUN, and then clear the passed parameters. This practice will help avoid data type conflicts and assists in clearing parameter variables.

 

The CLEAR VAR command below will clear all existing % variables (assuming your SINGLE character setting is an underscore). The CLEAR VAR uses 2 underscores, a dash, and an underscore. The passed parameter variables will display in TRACE mode as %1-1 in a single nesting level. If a called command file calls another, the variable would then be %1-2. The x in "%1-x" is the variable nesting level.

 

RUN cmdfile.rmd USING 'Display This Message' 10

 

--cmdfile.rmd

SET VARIABLE vstart TIME = .#TIME

SET VARIABLE vwait INTEGER = 0

SET VARIABLE vmessage TEXT = .%1

SET VARIABLE vmax INTEGER = .%2

CLEAR VAR __-_

SET VARIABLE

WHILE vwait < .vmax THEN

  SHOW VARIABLE .vmessage

  SET VARIABLE vwait = (.#TIME - .vstart)

ENDWHILE

CLS

CLEAR VARIABLES vstart, vwait, %1, %2

RETURN

 

The following RUN command executes the command syntax with the CmdData VARCHAR data field inside the table IntrnlCmd.

 

RUN SELECT CmdData FROM IntrnlCmd WHERE CmdName = 'NewKey'