Please enable JavaScript to view this site.

R:BASE 11 Help

Navigation: Command Index > W

WRITE (Short Name: WRI)

Scroll Prev Top Next More

Use the WRITE command to send a message to an output device, write binary or large ASCII data to a file, or to display a message on the R> Prompt screen.

 

In regards to displaying a message to the screen output, the WRITE command was primarily used with R:BASE for DOS to utilize the background. Utilizing a screen background in R:BASE for Windows applications is no longer available. To display a message in R:BASE for Windows, use the PAUSE command. To display a series of messages within an application, use a form.

 

WRITE

 

Options

,

Indicates that this part of the command is repeatable.

 

'message'

Specifies a message to be displayed. The use of quotes for the message value preserves added spaces. When omitting quotes, the WRITE command will truncate extra spaces automatically.

 

CONTINUE

Suppresses the carriage return line feed.

 

filename

The name of the file for writing binary or large ASCII variable data.

 

USING format

Specifies a display format for the message or variable.

 

.var

Specifies a dot variable of any data type, which can be used instead of a message.

 

=w

Specifies the display width for the variable.

 

 

About the WRITE Command

 

The WRITE command allows concatenation of several items in one command with embedded variables.

 

The WRITE command displays a message or variable that you place within the current QUOTES character. The default QUOTES character is the single quote ('). The quotes are not displayed when WRITE runs.

 

After you place binary or large ASCII data into your R:BASE database, the original file can be recreated at any time using the WRITE command. The data is read from the table into a variable, then the variable is written to a file. This process recreates the file exactly.

 

To display a message or variable containing line end characters, you must specify a width to write multiple lines.

 

Symbols for Formatting the Display

 

You can specify a format for displaying either a message or a variable. When using a display format, you can only display one item, and you must allow enough space between the quotes to properly display the formatted information. For example, if you wanted to center a text message, the format must include the centering symbol ([^]) and the space within which the text will be centered. The following tables summarize the formatting symbols.

 

String Modifiers for All Messages

 

Use this symbol...

To do the following...

[<]

Left justify the data in the field.

[>]

Right justify the data in the field.

[^]

Center the data in the field.

 

String Modifiers for Messages with Numbers

 

Use this symbol...

To do the following...

[-]

Place a negative sign to the right of a negative number.

[CR]

Place "CR" to the right of a positive number.

[DB]

Place "DB" to the right of a negative number.

[()]

Enclose a negative number in parentheses.

 

Character Modifiers for Text Messages

 

Character Modifier

If character is a letter

If character is a number

If character is neither

_

uppercase

blank

blank

|

lowercase

blank

blank

%

uppercase

number

character

?

lowercase

number

character

 

Character Modifiers for Numeric Messages

 

Character Modifier

If character is a number

If character doesn't fill the specified format

9

number

blank

0

number

0

*

number

* if blank

 

Examples

 

The following command automatically concatenates the items and puts a space between them. An ampersand (&) or plus (+) character cannot be used for concatenations.

 

WRITE 'Today's date is',.#DATE

 

The following command displays the contents of the vmsg variable.

 

WRITE .vmsg

 

In the following example, var1 is a numeric data type (CURRENCY, NUMERIC, INTEGER, REAL, SMALLINT, or DOUBLE). If var1 has a negative value, the number displays with DB following it to indicate a debit. The greater than symbol (>) right justifies the output.

 

WRITE .var1 USING '[DB,>]$99,999.99'

 

If the value of var1 is -$49,999.22, then the above command displays:

 

$49,999.22 DB

 

In the following example, var2 is a TEXT data type. The contents of var2 displays in uppercase and is centered in the space defined by the _ characters .

 

WRITE .var2 USING '[^] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _'

 

If the value of var2 is warning, then the above command displays:

 

WARNING

 

The following command displays the entire contents of var3, wrapping the text after the twelfth character. If SET WRAP is off, only the first 12 characters of text would be displayed.

 

WRITE .var3 = 12

 

The following command writes variable VARCHAR data to a text file:

 

WRITE .vVarcharData TO File.txt