SQR Command Reference

This chapter describes and demonstrates each command in the SQR lexicon.

SQR Command Overview

The commands in this section follow the conventions listed in the section “SQR Syntax Conventions” in the previous chapter,
and use the abbreviations described in the following table:

Warning! If you are copying code directly from the examples in the PDF file, make sure you change the slanted quotes to regular quotes
or you will receive an error message.

Abbreviation

Description

Example

txt_col

Text column retrievable from a database.

&address

num_col

Numeric column retrievable from a database.

&price

date_col

Date or datetime column retrievable from a database.

&date1

txt_var

String variable defined in a program.

$your_name

num_var

Numeric variable defined in a program.

#total_cost

date_var

A variable explicitly defined as a date variable.

$date1

any_lit

A literal of any type.

'abc' 12

any_var

A variable of any type.

$string #number $date

any_col

A column of any type.

&string &number &date

txt_lit

Text literal defined in a program.

'Company Confidential'

num_lit

Numeric literal defined in a program.

12345.67

int_lit

Integer literal defined in a program.

12345

nn

Integer literal used as an argument to a command.

123

position

The position qualifier, which consists of the line, column, and length specification. The minimum position, (), means to use
the current line and column position on the page for the length of the field being printed.

(5,10,30)

SQR Commands

The following sections discuss the SQR commands in alphabetical order.

ADD

Syntax

ADD{src_num_lit | _var |
_col} TO dst_num_var
[ROUND=nn]

Description

Adds one number to another.

The source value is added to the destination variable and the result is placed in the destination. The source is always first
and the destination is always second.

When dealing with money-related values, use decimal variables rather than float variables. Float variables are stored as double precision floating point numbers, and small inaccuracies can appear when adding many numbers in succession. These inaccuracies can appear due to the way floating
point numbers are represented by different hardware and software implementations and also due to inaccuracies that can be
introduced when converting between floating point and decimal.

Parameters

src_num_lit | _var | _col

Source number literal, variable, or column.

dst_num_var

A numeric destination variable that contains the result after execution.

ROUND

Rounds the result to the specified number of digits to the right of the decimal point. For float variables, this value can be from
0 to 15. For decimal variables, this value can be from 0 to the precision of the variable. For integer variables, this argument
is not appropriate.

ALTER-COLOR-MAP

The ALTER-COLOR-MAP command is allowed wherever the PRINT command is allowed. This command enables you to dynamically alter
a defined color. You cannot use this command to define a new color.

Parameters

NAME

Defines the name of the color you want to alter. For example, light blue.

VALUE

Defines the RGB value of the color you want to alter. For example, (193, 233, 230).

{color_name_lit | _var | _col}

The color_name is composed of alphanumeric characters (A-Z, 0-9), the underscore (_) character, and the hyphen (-) character. It must start
with an alpha (A-Z) character and is not case-sensitive. The name 'none' is reserved and cannot be assigned a value. A name
in the format (RGBredgreenblue) cannot be assigned a value. The name 'default' is reserved and may be assigned a value. 'Default'
is used during execution when a referenced color is not defined in the runtime environment.

{rgb}

red_lit | _var | _col, green_lit | _var | _col, blue_lit | _var | _col where each component is a value in the range of 000 to 255. In the BEGIN-SETUP section, only literal values are allowed.

Selects a locale or changes locale parameters used for printing date, numeric, and money data and for data accepted by the INPUT command. A locale is a set of preferences
for language, currency, and the presentation of charts and numbers.

The SYSTEM locale represents the behavior of older versions of SQR prior to Version 4.0. When you install SQR for PeopleSoft Version 4.0 or
later, the default locale is set to SYSTEM. This provides upwards compatibility for older SQR programs. This table describes
the SYSTEM locale settings:

Keyword

Value

NUMBER-EDIT-MASK

The PRINT command prints two digits to the right of the decimal point and left justifies the number in the field. The MOVE,
SHOW, and DISPLAY commands format the number with six digits to the right of the decimal point and left justify the number.

MONEY-EDIT-MASK

SQR uses the same default as the NUMBER-EDIT-MASK keyword.

DATE-EDIT-MASK

SQR uses the default database date format. See the Date Time section for more details.

INPUT-DATE-EDIT-MASK

SQR uses a default date edit mask with the INPUT command. See the Sample Date Edit Masks table for a listing of the date
edit mask.

Note. Many of the settings can have a value of DEFAULT or SYSTEM. For a given setting, specifying DEFAULT retrieves the value from the corresponding setting of the default locale as identified in the Default-Settings section of the sqr.ini file. Similarly, specifying SYSTEM retrieves the value
from the corresponding setting of the system locale. You can alter the system locale using the ALTER-LOCALE command; however, you cannot define it in the sqr.ini file.

LOCALE

Specifies the name of the locale to use. This name must be defined in the sqr.ini file. If this field is omitted, then the
current locale is used. The locale name is not case-sensitive and is limited to the following character set: A-Z, 0-9, underscore,
and hyphen. The current locale can be determined by printing the reserved variable $sqr-locale.

NUMBER-EDIT-MASK

Specifies the numeric edit mask to use with the keyword NUMBER in a PRINT, MOVE, SHOW, or DISPLAY command.

MONEY-EDIT-MASK

Specifies the numeric edit mask to use with the keyword MONEY in a PRINT, MOVE, SHOW, or DISPLAY command.

DATE-EDIT-MASK

The default date edit mask to use with the keyword DATE in the PRINT, MOVE, SHOW, or DISPLAY command, or the LET functions datetostr() or strtodate().

INPUT-DATE-EDIT-MASK

The default date format to use with the INPUT command when TYPE=DATE is specified with the command or the input variable is a date variable. For
information about Edit Masks, see PRINT.

MONEY-SIGN

Specifies the characters that replace the $ or other currency symbol used in edit masks.

MONEY-SIGN-LOCATION

Specifies where to place the MONEY-SIGN characters. Valid values are LEFT and RIGHT.

THOUSAND-SEPARATOR

Specifies the character to replace the ',' edit character.

DECIMAL-SEPARATOR

Specifies the character to replace the '.' edit character.

DATE-SEPARATOR

Specifies the character to replace the '/' character.

TIME-SEPARATOR

Specifies the character to replace the ':' character.

EDIT-OPTION-NA

Specifies the characters to use with the 'na' option.

EDIT-OPTION-AM

Specifies the characters to replace 'AM'.

EDIT-OPTION-PM

Specifies the characters to replace 'PM'.

EDIT-OPTION-BC

Specifies the characters to replace 'BC'.

EDIT-OPTION-AD

Specifies the characters to replace 'AD'.

DAY-OF-WEEK-CASE

Specifies how the case for the DAY-OF-WEEK-FULL or DAY-OF-WEEK-SHORT entries is affected when used with the format codes 'DAY'
or 'DY'. Valid values are UPPER, LOWER, EDIT, and NO-CHANGE. UPPER and LOWER force the output to either all uppercase or lowercase, ignoring the case of the format code in the edit mask.
Use EDIT to follow the case specified with the format code in the edit mask. Use NO-CHANGE to ignore the case of the format
code and output the day of week explicitly listed in the DAY-OF-WEEK-FULL or DAY-OF-WEEK-SHORT entries.

DAY-OF-WEEK-FULL

Specifies the full names for the days of the week. SQR considers the first day of the week to be Sunday. You must specify
all seven days.

DAY-OF-WEEK-SHORT

Specifies the abbreviated names for the days of the week. SQR considers the first day of the week to be Sunday. You must specify
all seven abbreviations.

MONTHS-CASE

Specifies how the case for the MONTHS-FULL or MONTHS-SHORT entries is affected when used with the format codes 'MONTH' or
'MON'. Valid values are UPPER, LOWER, EDIT, and NO-CHANGE. UPPER and LOWER force the output to either all uppercase or lowercase,
ignoring the case of the format code in the edit mask. Use EDIT to follow the case specified with the format code in the edit
mask. Use NO-CHANGE to ignore the case of the format code and output the month explicitly listed in the MONTHS-FULL or MONTHS-SHORT
entries.

MONTHS-FULL

Specifies the full names for the months of the year. SQR for PeopleSoft considers the first month of the year to be January.
You must specify all 12 months.

MONTHS-SHORT

Specifies the abbreviated names for the months of the year. SQR for PeopleSoft considers the first month of the year to be
January. You must specify all 12 abbreviations.

You can place the ALTER-PRINTER command in any part of an SQR program except the SETUP section.

ALTER-PRINTER attempts to change the attributes of the current printer for the current report. If an attribute does not apply to the current printer, it is ignored. For example, ALTER-PRINTER is ignored if it specifies proportional fonts for a report printed on
a line printer. When your program is creating multiple reports and the printer is shared by another report, the attributes are changed for that report as well.

Parameters

POINT-SIZE

Specifies the new font point size.

FONT-TYPE

Specifies the new font type. Values are PROPORTIONAL or FIXED.

SYMBOL-SET

Specifies the new symbol set identifier.

FONT

Specifies the new font as a number. (For example, font=3 for Courier and font=4 for Helvetica.)

PITCH

Specifies the new pitch in characters per inch.

See the DECLARE-PRINTER arguments table for information about these arguments.

Example

Change the font and symbol set for the current printer:

alter-printer
font=4 ! Helvetica
symbol-set=12U ! PC-850 Multilingual

If the output prints to a PostScript printer, the SYMBOL-SET argument is ignored; however, if the .spf file is kept (-KEEP)
and later printed on an HP LaserJet, the symbol set 12U can be used.

This command gives you the ability to dynamically change the heading or footing sections that are active for the current report.
You can also change how much space the heading or footing sections occupy.

If the HEADING or FOOTING value is set to NONE, the section is disabled for the current report.

If the HEADING or FOOTING value is set to DEFAULT, the section reverts to the setting that were in effect when the report
was initiated.

If no HEADING or FOOTING value is set, the HEADING-SIZE or FOOTING-SIZE values affect the HEADING/FOOTING currently being
used.

If the ALTER-REPORT command was not invoked from within a BEGIN-HEADING or BEGIN-FOOTING section and the page has not been
written to, the assignment takes effect immediately; otherwise it takes effect for the next page.

Parameters

HEADING

Specifies the name of the BEGIN-HEADING section to use.

HEADING-SIZE

Specifies the amount of space the BEGIN-HEADING section occupies on the page.

FOOTING

Specifies the name of the BEGIN-FOOTING section to use.

FOOTING-SIZE

Specifies the amount of space the BEGIN-FOOTING section occupies on the page

These four commands perform arithmetic on one or more elements in an array.

The following information applies to the array arithmetic commands:

The array must first be created using the CREATE-ARRAY command.

The four array arithmetic commands perform on one or more source numbers, placing the result into the corresponding field
in the array.

Array element and field occurrence numbers can be numeric literals (123) or numeric variables (#j) and can be from zero (0)
to one less than the size of the array.

If fields are not listed, the results are placed into consecutively defined fields in the array. If fields are listed, results
are placed into those fields, at the specified occurrence of the field. If an occurrence is not specified, the zeroth (0)
occurrence is used.

All fields must be of type number, decimal, float, or integer. They cannot be of type date, char, or text.

If division by zero is attempted, a warning message appears, the result field is unchanged, and SQR continues executing.

Parameters

src_num_lit|_var|_col

Source values are added to, divided into, multiplied times, or subtracted from the respective destination array fields. All
variables must be numeric in type.

The CLEAR-ARRAY command for information about clearing or initializing an array.

The GET, PUT, and LET commands for information about using arrays.

ASK

Syntax

ASK substitution_variable [prompt]

Description

Retrieves values for a compile-time substitution variable. The retrieval can be by user input, command-line arguments, or as entries in the @file on the command line.

The value of the substitution variable replaces the reference variable in the program. Variables are referenced by enclosing the variable name in braces, for example, '{state_name}'. When the
substitution variable is text or date, surround the brackets by single quotes. Substitutions are made when the program is
compiled and are saved in the .sqt file. Each variable can be referenced multiple times.

ASK is used only in the SETUP section and must appear prior to any substitution variable references.

You cannot break the ASK command across program lines.

Parameters

Substitution_variable

The variable to be used as the substitution variable.

Prompt

An optional, literal text string to be displayed as a prompt if the value for the substitution variable is not entered on
the command line or in an argument file.

Example

In the following example, state takes the value entered by the user in response to the prompt Enter state for this report:

begin-setup
ask state 'Enter state for this report'
end-setup
...
begin-select
name, city, state, zip
from customers where state = '{state}'
end-select

BEGIN-DOCUMENT

Syntax

BEGIN-DOCUMENT position
END-DOCUMENT

Description

Begins a document paragraph. A document paragraph enables you to write free-form text to create form letters, invoices, and so on.

You can reference database columns, SQR variables, and document markers within a document. Their locations in the document determine where they print on the page. You should not use tabs inside
a document paragraph. To indent text or fields, use the spacebar. Note also that if the variables being printed inside a document
paragraph are variable in length, you might needto manipulate the variable outside the document paragraph.

Note. A document must be executed before you can reference its document markers. Because documents can be printed at relative positions
on the page, the actual location of a document marker may not be known by SQR until the document itself has been executed.

Parameters

position

The location on the page where the document begins. The position can be fixed or relative to the current position. See the
POSITION command for a description and examples of the position parameter.

Begins a new construct. In a BEGIN-EXECUTE paragraph, the syntax of BEGIN-SELECT varies as shown in the following syntax:

Parameters

CONNECTION

Identifies a name previously specified using the DECLARE-CONNECTION construct. If you do not specify a name, SQR Server uses
the default connection. The default connection is defined by the command-line entries for datasource (DSN), username (USER),
and password (PASSWORD). Name is not case-sensitive.

ON-ERROR

Declares the procedure to execute if an error occurs.

RSV

Row Set Variable. A global SQR variable containing the row set being retrieved.

STATUS

Identifies a list or scalar variable that receives the status of the stored procedure.

SCHEMA

Identifies the location in the datasource of the object being queried.

PROCEDURE

The name of the datasource-stored procedure to be executed. The name may include spaces. If the datasource is SAP R/3, this
procedure is a BAPI.

PARAMETER_LIST

Scalar and/or list variables of the form list_var | num_lit | txt_lit | txt_var | num_var | any_col. If you do not specify
the keywords IN or INOUT, the default value is IN. Specify all parameters in order; leaving any parameters unnamed causes
a syntax error. To ignore a parameter, fill its position with the keyword NULL. This results in a null value for that parameter
position.

COMMAND

A text string you pass to the datasource without modification by SQR. This string can include embedded SQR variables.

BEFORE/AFTER

Names an SQR procedure to be executed before or after the row set. The procedure is not performed unless at least one row
is returned from the specified row sets.

FROM ROWSET

Special case addition to the BEGIN-SELECT syntax. Available for use with all datasource types, including SAP R/3 and JDBC.
Names the row sets from which to retrieve the column variables. If you specify more than one row set, use identical column
name/type signatures. Row set numbers must be sequential from left-to-right within the parentheses, and they must not overlap
as in this example: (1-3, 2-4). Numeric literals or #variables are allowed.

FROM PARAMETER

Special case addition to the BEGIN-SELECT syntax. Available only for SAP R/3 datasources. Use only with the PROCEDURE keyword.
This argument names an output parameter containing one or more rows from which the column variables are to be retrieved.

Specifies a set of keyword-value pairs that represent modifications to be made to the Properties of the datasource (specified
by the CONNECTION = statement). An arbitrary number of such pairs can be specified.

Note. This is a similar concept to the PARAMETERS = statement in DECLARE-CONNECTION, with the minor difference being that the properties
specified here alter the flow of returned information, as opposed to just setting login properties. Can be used in conjunction
with any data-access model (Procedure, Command, Getdata). An application of this statement would be in the MDB setting, where
it might be used to specify such things as Level, Generation, or Include-Column. For example, PROPERTIES = ( 'SetColumn' =
5 )

The FOOTING section defines and controls the information to be printed at the bottom of each page.

You must define the report_name in a DECLARE-REPORT paragraph. If you do not use DECLARE-REPORT, the footing is applied to all reports. You can also specify
FOR-REPORTS=(ALL). Note that the parentheses are required.

You can specify more than one BEGIN-FOOTING section; however, there can be only one for each report. A BEGIN-FOOTING section
with FOR-REPORTS=(ALL) can be followed by other BEGIN-FOOTING sections for specific reports, which override the ALL setting.

You must define the toc_name in a DECLARE-TOC paragraph. You can also specify FOR-TOCS=(ALL). Note that the parentheses are required.

You can specify more than one BEGIN-FOOTING section; however, there can be only one section for each table of contents. A
BEGIN-FOOTING section with FOR-TOCS=(ALL) can be followed by other BEGIN-FOOTING sections for a specific table of contents,
which override the ALL setting.

The BEGIN-FOOTING section can be shared between reports and tables of contents.

You can print outside the footing area of the report—that is, in the body area—from the footing, but you cannot print in the
footing area from the body.

Parameters

footing_lines_int_lit

The number of lines to be reserved at the bottom of each page.

FOR-REPORTS

Specifies the reports to which this footing applies. This argument is required only for a program with multiple reports. If
you are writing a program that produces a single report, you can ignore this argument.

FOR-TOCS

Specifies the table of contents to which this heading applies.

NAME

Specifies the name to be associated with this footing section. Use this parameter with the ALTER-REPORT command. The name
cannot be NONE or DEFAULT.

The HEADING section defines and controls information to be printed at the top of each page.

You must define the report_name in a DECLARE-REPORT paragraph. If you do not use DECLARE-REPORT, the heading is applied to all reports. You can also specify
FOR-REPORTS=(ALL). Note that the parentheses are required.

You can specify more than one BEGIN-HEADING section; however, there can be only one for each report. A BEGIN-HEADING section
with FOR-REPORTS=(ALL) can be specified followed by other BEGIN-HEADING sections for specific reports, which override the
ALL setting.

You must define the toc_name in a DECLARE-TOC paragraph. You can also specify FOR-TOCS=(ALL). Note that the parentheses are required.

You can specify more than one BEGIN-HEADING section; however, there can be only one section for each table of contents. A
BEGIN-HEADING section with FOR-TOCS=(ALL) can be specified, followed by other BEGIN-HEADING sections for specific tables of
contents, which override the ALL setting.

The BEGIN-HEADING section can be shared between reports and a table of contents.

You can print outside the heading area of the report—that is, in the body area—from the heading, but you cannot print in the
heading area from the body.

Parameters

heading_lines_int_lit

The number of lines to be reserved at the top of each page.

FOR-REPORTS

Specifies the reports to which this heading applies. This is required only for a program with multiple reports. If you are
writing a program that produces a single report, you can ignore this argument.

FOR-TOCS

Specifies the table of contents to which this heading applies.

NAME

Specifies the name to be associated with this heading section. This option cannot be used if FOR-REPORTS or FOR-TOCS is also
specified. Use this parameter with the ALTER-REPORT command. The name cannot be NONE or DEFAULT.

BEGIN-PROCEDURE

Begins a procedure. A procedure is one of the most powerful parts of the SQR language. It enables modularized functions and provides standard
execution control.

The procedure name must be unique. The name is referenced in DO commands. Procedures contain other commands and paragraphs
(for example, SELECT, SQL, DOCUMENT).

By default, procedures are global. That is, variables or columns defined within a procedure are known and can be referenced outside of the procedure.

A procedure is local when the word LOCAL appears after the procedure name or when the procedure is declared with arguments. That is, variables
declared within the procedure are available only within the procedure, even when the same variable name is used elsewhere
in the program. In addition, any query defined in a local procedure has local database column variable names assigned that
do not conflict with similarly named columns defined in queries in other procedures.

SQR procedures can be called recursively. However, unlike C or Pascal, SQR maintains only one copy of the local variables and they are persistent.

Arguments passed by a DO command to a procedure must match in number:

Database text or date columns, string variables, and literals can be passed to procedure string arguments. If passing a date
string to a date argument, the date string must be in the format specified by the SQR_DB_DATE_FORMAT setting, or a database
dependent format, or the database-independent format SYYYYMMDD[HH24[MI[SS[NNNNNN]]]].

See the Default Database Formats table in the PRINT command description.

Numeric variables (DECIMAL, INTEGER, FLOAT) can be passed to procedure numeric arguments without regard to the argument type of the procedure. SQR automatically converts the numeric values upon entering and leaving
the procedure as required.

Date variables or columns can be passed to procedure date or string arguments. When a date variable or column is passed to a string argument, the date is converted to a string according to the following
rules:

For DATETIME columns and SQR DATE variables, SQR uses the format specified by the SQR_DB_DATE_FORMAT setting.

If this has not been set, SQR uses the first database-dependent format as listed in the Default Database Formats table.

For DATE columns, SQR uses the format specified by the SQR_DB_DATE_ONLY_FORMAT setting.

If this has not been set, SQR uses the format listed in the Default Database Formats table.

For TIME columns, the format specified by the SQR_DB_TIME_ONLY_FORMAT setting is used.

If this has not been set, SQR uses the format listed in the TIME Column Formats table.

To reference or declare global variables from a local procedure, add a leading underscore to the variable name, after the
initial $, #, or &. (Example: #_amount)

Note. All the SQR reserved variables, such as #sql-status and $sql-error, are global variables. Within a local procedure, they must be referenced using the leading underscore: #_sql-status or $_sql-error.

Parameters

procedure_name

Specifies a unique name for this procedure. Procedure names are not case-sensitive.

LOCAL

Specifies that this is a local procedure.

arg1 [, argi]...

Specifies the arguments to be passed to or returned from the procedure. Arguments can be string variables ($arg), numeric
variables (#arg), or date variables ($arg). If you want to return a value passed back to the calling DO command, place a colon (:) before the variable name. The arguments of the BEGIN-PROCEDURE and DO commands must match in number,
order, and type.

Example

The following example shows a procedure, main, that also executes the procedure print_list, for each row returned from the Select statement. No parameters are passed to print_list:

begin-procedure main
begin-select
name
address
phone
do print_list
from custlist order by name
end-select
end-procedure ! main

In the following example, five arguments are passed to the Calc procedure:

BEGIN-PROGRAM

Syntax

BEGIN-PROGRAM
END-PROGRAM

Description

Begins the PROGRAM section of an SQR program.

After processing the any commands in the SETUP section, SQR starts program execution at the BEGIN-PROGRAM section. The PROGRAM
section typically contains a list of DO commands, though other commands can be used. This is the only required section in an SQR program.

Begins a SELECT paragraph. A SELECT paragraph is the principal means of retrieving data from the database and printing it in a report. A SELECT paragraph
must be inside a PROCEDURE or BEGIN-PROGRAM section.

Note that SELECT * FROM is not a valid SQR SQL statement. BEGIN-SELECT can be placed inside a BEGIN-PROGRAM section.

Parameters

The table describes the parameters:

Note. The arguments can span multiple lines; however, the first character position cannot be used unless the continuation character
terminated the previous line. If the first character position is used with arguments spanning multiple lines, the argument
will be misconstrued as a Select column.

DISTINCT

Specifies that duplicate rows be eliminated from your query.

-Cnn

(Oracle) Sets the context area size (buffer size for query) to larger or smaller than the default. This option is rarely needed.

-Bnn

(Oracle, ODBC, Sybase CT-Lib) Sets the number of rows to retrieve at one time. This is for performance purposes only. Regardless of this setting, all rows are selected. The default, without using -B,
is 10 rows. An overall setting for a program can be indicated on the SQR command line with -B, which can be overridden by
a separate -B flag on each BEGIN-SELECT command.

-XP

(Sybase) Prevents the creation of a stored procedure for the SELECT paragraph. When -XP is specified, SQR generates a new SQL statement using the current value of any bind variables each time the BEGIN-SELECT
is executed. This disables the potential performance optimization created by stored procedures. Use this flag if you change
the variables frequently during execution and you do not want SQR to automatically create stored procedure. You can also use
-XP if the username/password to your program does not have permission to create stored procedures.

If you do not change variables frequently during execution, the use of stored procedures may optimize your program's performance.
In that case, do not use this argument. Note also that -XP is available as a command-line flag.

-XP improves performance when you use bind variables and dynamic query variables in the same query. Each time the dynamic query variable changes in value, a new stored procedure
is created. If the dynamic query variable changes often and the query contains bind variables, you create many stored procedures
if you do not use -XP.

-DBconnectionstring

(ODBC) Specifies the ODBC connection string for this SELECT paragraph only. A connection string has the following syntax:

DSN=data_source_name[;keyword=value[;keyword=value [;...]]]

This option enables you to combine data from multiple databases in one program. For example, a connection string for an Oracle
database named ora8 might look like this:

'DSN=ora8;UID=scott;PWD=tiger'

where DSN, UID, and PWD are keywords common to all drivers (representing: name, user ID, and password, respectively). Connection
string options are always separated by a semicolon (;). Other driver-specific options may be added to the connection string
using driver-defined keywords. See your ODBC driver documentation for available options.

LOOPS

Specifies the number of rows to retrieve. After the specified number has been processed, the SELECT loop exits.

ON-ERROR

Declares a procedure to execute if an error occurs due to incorrect SQL syntax. Error trapping should be used with dynamic query variables. SELECT paragraphs without dynamic variables are checked for errors before the
program is processed and therefore do not require a special error procedure.

Optionally, you can specify arguments to be passed to the ON-ERROR procedure. Arguments can be any variable, column, or literal.

Example

In this example, duplicate rows are not selected for the city, state, and zip columns because of the distinct keyword. The numbers within parentheses accompanying city, state, and zip define the column positions of these rows. Column
names can not have spaces in front of them.

begin-select distinct
city (1,1,30)
state (0,+2,2)
zip (1,+3,6)
from custlist order by city
end-select

In this example, the first two columns may, or may not, be present when the statement is compiled. The column cust_id is declared
to be a number. A runtime error is produced if the database table, as identified by the variable $table_name, declares it to be something other than a number.

BEGIN-SETUP

Begins a SETUP section. This optional section is processed prior to the BEGIN-PROGRAM, BEGIN-HEADING, and BEGIN-FOOTING sections.

The SETUP section should be the first section in the program.

The SETUP section contains commands that determine the overall characteristics of the program. The commands used in the SETUP
section cannot be used elsewhere unless specified. The SETUP section can include the following commands:

ASK
BEGIN-SQL

(The BEGIN-SQL command can also be used in BEGIN-PROCEDURE paragraphs.)

CREATE-ARRAY

(The CREATE-ARRAY command can also be used in the other sections of an SQR program.)

Begins an SQL paragraph. This paragraph can reside in a BEGIN-PROCEDURE, BEGIN-SETUP, or BEGIN-PROGRAM section.

BEGIN-SQL starts all SQL statements except SELECT, which has its own BEGIN-SELECT paragraph. If a single paragraph contains
more than one SQL statement, each statement except the last must be terminated by a semicolon (;).

If a single paragraph contains more than one SQL statement, and the -C flag is used, all are assigned the same context area
size or logical connection number.

Only non-SELECT statements can be used (except SELECT INTO for Sybase and Microsoft SQL Server). Columns and variables can
be referenced in the SQL statements.

Stored Procedures

For Oracle, stored procedures are implemented using PL/SQL in the BEGIN-SQL paragraph. For Sybase and Microsoft SQL Server,
SQR supports stored procedures with the EXECUTE command.

For some databases, such as Oracle, using DDL statements within a BEGIN-SQL paragraph causes a commit of outstanding inserts,
updates, and deletes and releases cursors. For this reason, ensure that these are done in the proper order or unpredictable
results may occur.

Oracle PL/SQL

For Oracle, PL/SQL is supported in a BEGIN-SQL paragraph. This requires an additional semicolon at the end of each PL/SQL
statement.

(Oracle) Sets the context area size (buffer size for query) to larger or smaller than the default. This option is rarely needed.

-XP

(Sybase) Prevents the creation of a stored procedure for the SQL paragraph. When -XP is specified, SQR generates a new SQL statement using the current value of the bind variables
each time the BEGIN-SQL is executed. This disables the performance optimization created by stored procedures. Use this flage
if you change the variables frequently during execution and you do not want SQR to automatically create stored procedures.
You may also use it if your program does not have permission to create stored procedures.

If you do not change variables frequently during execution, the use of stored procedures optimizes the performance of the
program. In that case, do not use this argument.

-XP improves performance when you use bind variables and dynamic query variables in the same query. Each time the dynamic
query variable changes in value, a new stored procedure is created. If the dynamic query variable changes often and the query
contains bind variables, you create many stored procedures if you do not use -XP.

-DBconnectionstring

(ODBC) Specifies the ODBC connection string for this SQL paragraph only. A connection string has the following syntax:

DSN=data_source_name[;keyword=value[;keyword=value[;...]]]

This option enables you to combine data from multiple databases in one program. For example, a connection string for an Oracle
named ora8 might look like the following:

'DSN=ora8;UID=scott;PWD=tiger'

where DSN, UID, and PWD are keywords common to all drivers (representing name, user ID, and password, respectively). Connection
string options are always separated by a semicolon (;). Other driver-specific options may be added to the connection string
using driver-defined keywords. See your ODBC driver documentation for available options.

ON-ERROR

Declares a procedure to execute if an error occurs due to incorrect SQL syntax except when executed in a BEGIN-SETUP section.
By default, SQR reports any error and then halts; if an error procedure is declared, you can trap errors, report or log them,
and continue processing. The procedure is invoked when an error occurs in any SQL statement in the paragraph. After the error
procedure ends, control returns to the next SQL statement.

Optionally, you can specify arguments to be passed to the ON-ERROR procedure. Arguments can be any variable, column, or literal.

If ON-ERROR is used in the SETUP section, it is a condition flag supporting the following conditions:

The CALL SYSTEM is a special subroutine that is provided as part of SQR to enable the program to issue operating system commands.
Its arguments, command, status, and WAIT|NOWAIT are described below.

The values of the source and destination variables and the parameter's literal value are passed to your subroutine. Upon return
from the subroutine, a value is placed in the destination variable.

You must write the subroutine and call it in one of the supplied UCALL routines. Optionally, you could rewrite UCALL in another
language instead.

The source file UCALL.C contains sample subroutines written in C. The UCALL function takes the following arguments:

Argument

Description

How Passed

callname

Name of the subroutine.

By reference with a maximum of 31 characters, null terminated.

strsrc

Source string.

By reference with a maximum of 255 characters, null terminated.

strdes

Destination string.

By reference with a maximum of 255 characters.

dblsrc

Source double floating point.

By reference.

dbldes

Destination double floating point.

By reference.

param

Subroutine parameter string. It must be a literal.

By reference with a maximum of 80 characters, null terminated.

When you use the CALL command, your arguments are processed as follows:

Calling arguments are copied into the variables depending on the type of argument. Strings are placed into strsrc and numerics are placed into dblsrc.

Return values are placed into strdes or dbldes depending on whether your destination argument for CALL is a string or numeric variable.

The destination arguments can also be used to pass values to your subroutine.

To access your subroutine, add a reference to it in UCALL and passing along the arguments you need.

You must relink SQR to CALL after compiling a user-defined function that becomes another SQR function.

If you have created a new object file, you must add your subroutine to the link command file: in UNIX/Linux it is called SQRMAKE; in Windows it is called SQREXT.MAK. (Alternatively, you could add your routine to the bottom of the UCALL source module that is already included in the link).

Your subroutine and calling SQR program are responsible for passing the correct string or numeric variables and optional parameter
string to the subroutine. No checking is performed.

Parameters

subroutine

Specifies the name of your subroutine.

src_txt_lit|_var|_col

Specifies a text column, variable, or literal which is to be input to the called subroutine.

src_num_lit|_var|_col

Specifies a numeric column, variable (decimal, float, or integer), or literal that is to be input to the called subroutine.

dst_txt_var|_num_var

Specifies a text or numeric variable (decimal, float, or integer) into which the called subroutine is to place the return
result.

param

Specifies an optional alphanumeric string of characters to be passed as a parameter to the subroutine.

SYSTEM

Specifies that this CALL command issues an operating system command.

command

Specifies the operating system command to execute. The command can be a quoted string, string variable, or column.

status

Contains the status returned by the operating system. The status must be a numeric variable. The value returned in status
is system-dependent as follows:

UNIX/Linux: Zero (0) indicates success. Any other value is the system error code.

PC/ Microsoft Windows: A value less than 32 indicates an error.

WAIT|NOWAIT

(Microsoft Windows only): WAIT specifies that SQR suspend its execution until the CALL SYSTEM command has finished processing.
NOWAIT specifies that SQR start the CALL SYSTEM command but continue its own processing while that command is in progress.

For Microsoft Windows, the default is NOWAIT. On UNIX\Linux operating systems the behavior is always WAIT.

The following example uses the SYSTEM argument to issue an operating system command. Some operating systems let you invoke
a secondary command processor to enter one or more commands and then return to SQR.

The following step-by-step example shows how to add a user-defined subroutine to SQR so that it can be invoked from SQR using
the CALL command. For this example, the C function initcap, which makes the first letter of a string uppercase, is added. The function accepts two parameters. The first parameter is
the string to which the initcap function is applied. The second is the resultant string.

To add initcap function to SQR, the following modifications are needed to the UCALL.C file that was provided with SQR:

Add the prototype for the initcap function:

static void initcap CC_ARGS((char *, char *));

Modify the UCALL routine in the UCALL.C file.

Specifically, add an else if statement at the end of the if statement to check for the initcap function:

Note. The CC_ARG macros are defined in the UCALL.C source module. The macros give the programmer the ability to define a fully-prototyped
function without having to worry if the C compiler supports the feature.

After these modifications, recompile UCALL.C and relink SQR. See the programming manual for your particular machine for details.

Finally, the following is an example of a simple SQR program which uses the initcap function:

begin-program
input $name 'Enter the first name '! Get the first name from the user
lowercase $name ! Set the first name to all lowercase
call initcap using $name $capname ! Now set the first character to uppercase
input $last 'Enter the last name ' ! Get the last name from the user
lowercase $last ! Set the last name to all lowercase
call initcap using $last $caplast ! Now set the first character to uppercase
.
.
.

See Also

The LET command for information about user-defined functions using UFUNC.C that can be used in the context of an expression
and that can pass and/or return any number of arguments.

CLEAR-ARRAY

Syntax

CLEAR-ARRAY NAME=array_name

Description

Resets each field of an array to its initial value.

The CLEAR-ARRAY command resets each field of the named array to the initial value specified for that field in the CREATE-ARRAY
command. If no initial value was specified, numeric fields are reset to zero, text fields are reset to null, and date fields
are reset to null. CLEAR-ARRAY also releases all memory used by the specified array and returns it to its pristine state.

Parameters

NAME

Specifies the name of the array to be cleared.

Example

The following example illustrates the CLEAR-ARRAY command

clear-array name=custs

See Also

CREATE-ARRAY

CLOSE

Syntax

CLOSE {filenum_lit|_var_col}

Description

Closes a file, specified by its file number.

Closes a flat file that has been previously opened using the OPEN command.

Parameters

filenum_lit|_var_col

Specifies the number assigned to the file in the OPEN command.

Example

The following example illustrates the CLOSE command

close 5
close #j

See Also

OPEN, READ, WRITE

COLUMNS

Syntax

COLUMNS {int_lit|_var|_col}[int_lit|_var|_col]...

Description

Defines logical columns to be used for PRINT commands.

COLUMNS defines the leftmost position of one or more columns within the current page layout. It sets the first column as current.

COLUMNS can be used for printing data either down the page or across the page, depending on how you use the NEXT-COLUMN and
USE-COLUMN commands.

The COLUMNS command applies only to the current report. If you want to print columns in more than one report, you must specify
the COLUMNS command for each report.

The USE-COLUMN 0 turns off columns. See USE-COLUMN.

Parameters

int_lit|_var|_col

Specifies the left margin position of each column.

See Also

NEXT-COLUMN, NEXT-LISTING, NEW-PAGE, USE-COLUMN, USE-REPORT.

COMMIT

Syntax

COMMIT

Description

Causes a database commit.

COMMIT is useful when you are doing many inserts, updates, or deletes in an SQL paragraph. A database commit releases the
locks on the records that have been inserted, updated, or deleted. Used with some databases, it also has other effects. For
this reason, it should not be used within the scope of an active SELECT paragraph or unpredictable results may occur.

When the application completes, a commit is performed automatically unless a ROLLBACK was done or, for callable SQR, the -XC flag was set.

Other commands or options, such as the CONNECT command and the use of DDL statements for some databases with a BEGIN-SQL paragraph, can also cause the database to do a commit.

COMMIT is an SQR command and should not be used within an SQL paragraph. If COMMIT is used in an SQL paragraph, unpredictable errors can occur.

Note. The COMMIT command can be used with SQR servers for Oracle, DB2, Informix, and ODBC. For Sybase and Microsoft SQL Server,
use BEGIN TRANSACTION and COMMIT TRANSACTION within SQL paragraphs as in the following code segment.

Warning! Any data being changed by a current transaction is locked by the database and cannot be retrieved in a SELECT paragraph until
the transaction is completed by a COMMIT or ROLLBACK statement (or COMMIT TRANSACTION or ROLLBACK TRANSACTION statement for
Sybase or Microsoft SQL Server).

CONCAT

Syntax

CONCAT {src_any_lit|_var|_col} WITH
dst_txt_var[[:$]edit_mask]

Description

Concatenates a variable, column, or literal with a string variable.

The contents of the source field are appended to the end of the destination field.

CONCAT can optionally edit the source field before appending it. Edit masks can be changed dynamically by placing them in
a string variable and referencing the variable name preceded by a colon (:).

Also, the source can be a date variable or column. If an edit mask is not specified, the date is converted to a string according
to the following rules:

For DATETIME columns and SQR DATE variables, SQR uses the format specified by the SQR_DB_DATE_FORMAT setting.

If this has not been set, the first database-dependent format as listed in the Default Database Formats table is used.

For DATE columns, SQR uses the format specified by the SQR_DB_DATE_ONLY_FORMAT.

If this has not been set, the format listed in the Default Database Formats table is used.

For TIME columns, SQR uses the format specified by the SQR_DB_TIME_ONLY_FORMAT.

If this has not been set, the format as listed in the Time Column Formats table is used.

Parameters

src_any_lit|_var|_col

Specifies the source field to be concatenated with the dst_txt_var field.

The PRINT command for information about the Default Database Formats table, the Time Column Formats table, and edit masks.

The LET command for string functions.

STRING, UNSTRING

CONNECT

Syntax

CONNECT {txt_lit|_var|_col}[ON-ERROR=procedure[(arg1
[, argi]...)]]

Description

Logs off the database and logs on under a new username and password.

The new username and password can be stored in a string variable, column, or literal.

Warning! The username/password is not encrypted, so beware of security issues.

After each CONNECT, the reserved variable $username is set to the new username.

All database cursors or logons are closed before the CONNECT occurs. You should not issue a CONNECT within a SELECT or an
SQL paragraph while a query is actively fetching or manipulating data from the database.

Parameters

txt_lit|_var|_col

Specifies a username and password for the logon.

ON-ERROR

Specifies a procedure to be executed if the logon fails. If no ON-ERROR procedure is specified and the logon fails, SQR halts
with an error message.

Note. You can optionally specify arguments to be passed to the ON-ERROR procedure. Arguments can be any variable, column, or literal.

Example

The following example illustrates the CONNECT command

connect $new-user on-error=bad-logon($new_user)
connect 'sqr/test'

CREATE-ARRAY

You can define arrays to store intermediate results or data retrieved from the database. For example, a SELECT paragraph can
retrieve data, store it in an array, and gather statistics at the same time. When the query finishes, a summary could be printed
followed by the data previously stored in the array.

SQR creates arrays before a program starts to execute. The CREATE-ARRAY command can be used in any section of a program.

The name is a simple field (one occurrence), rate has two occurrences, and phone is a simple field. Both array elements and field occurrences are referenced beginning with zero (0). The rate is referenced by rate(0) or rate(1). The emps array will contain 10 elements, 0 through 9. All name fields are initialized to Unknown, all phone fields are initialized to None, and all rate fields are initialized to 10.50.

Parameters

NAME

Names the array. The name is referenced in other array commands.

SIZE

Defines the number of elements in the array.

FIELD

Defines each field or column in the array. Each field must be defined as type:

DECIMAL[(p)]: Decimal numbers with an optional precision (p).

FLOAT: Double precision floating point numbers.

INTEGER: Whole numbers.

NUMBER: Uses the DEFAULT-NUMERIC type. See the DECLARE-VARIABLE command.

CHAR (or TEXT): Character string.

DATE: Same as date variable.

You can specify an initialization value for each field. Each field is set to this value when the array is created and when
the CLEAR-ARRAY command is executed. If no initialization value is specified, numeric fields (DECIMAL, FLOAT, INTEGER) are set to zero, character
fields are set to null, and date fields are set to null. All occurrences of a multiply occurring field are set to the same
value. For dates, the initialization string must be formatted as 'SYYYYMMDD[HH24[MI[SS[NNNNNN]]]]'.

OCCURS

Fields can optionally have a number of occurrences (occurs ), that is, they can be repeated any number of times.

CREATE-COLOR-PALETTE

This command enables you to create a palette of colors. There is no limit to the number of palettes that can be defined in
a program. No gaps are permitted in the palette.

Parameters

NAME

Specifies the name of the color palette.

COLOR_1

Specifies the first color in the palette.

COLOR_2

Specifies the second color in the palette.

COLOR_n

Specifies the n'th color in the palette. You can specify up to 64 colors in the palette.

{rgb}

Designates a color reference. This can be expressed as (r,g,b) where r, g, and b are either a numeric literal (0 to 255), a numeric variable, or a numeric column. It can also be expressed as a (c) where c is a string literal, column, or variable that is the name of a color.

#DEBUG

Syntax

#DEBUG[x...]SQR_Command

Description

Causes the current command to be processed during a debugging session.

A -DEBUG[xx] flag in the SQR command line enables conditional compilation of SQR commands. When this flag is used, any command (including other
compiler directives) preceded by the word #DEBUG is processed; other commands are ignored.

This is useful for placing DISPLAY, SHOW, PRINT or other commands in your program for testing and for deactivating them when
the report goes into production.

The -DEBUG flag can contain a suffix up to 10 letters or digits. These characters are used to match any letters or digits
appended to the #DEBUG preprocess command inside the program. #DEBUG commands with one or more matching suffix characters
are processed; other commands are ignored. Commands without any suffix always match.

In addition, for each -DEBUGxx letter, a substitution variable is defined. For example, if the flag -DEBUGab is used on the command line, three substitution
variables are defined: debug,debuga, and debugb. These variables can be referenced in #IFDEF commands to turn whole sections of code on or off for debugging.

Parameters

x

Represents any letter or digit.

Example

The following SQR command line contains the -DEBUG flag with no suffixes:

sqr myprog sammy/baker -debug

The following SHOW command in the program executes if invoked with the previous command line because the -DEBUG flag was used:

#debug show 'The total is ' #grand-tot 999,999,999

In the following code example, the command line contains the -DEBUG flag with the suffixes a, b, and c:

sqr myprog sammy/baker -debugabc

In the following code example, the first three #DEBUG commands are compiled, but the fourth, beginning #debuge, is not because its suffix does not match any of the suffixes on the -DEBUG flag:

Note. If CHART-SIZE is not defined, it must be defined in PRINT-CHART.

Description

Defines the attributes of a chart that can later be displayed using PRINT-CHART.

The DECLARE-CHART command can define the attributes of a chart to be printed as part of a report.

This command may only appear in the SETUP section.

A chart defined using DECLARE-CHART is printed by referencing its name in the PRINT-CHART command. Some or all of the chart
attributes may be overridden at runtime with the PRINT-CHART command. As such, DECLARE-CHART is useful when the basic properties
of a chart are common to many PRINT-CHART commands.

Note. All DECLARE-CHART attributes can be overridden as part of the PRINT-CHART command. Columns are not supported within the DECLARE-CHART
command or the PRINT-CHART command. Attributes that are specified more than once produce a warning, and the first instance is regarded as the actual value.
Attributes can be used in any order, with the exception of chart-name, which must follow the DECLARE-CHART keyword.

Also, the FILL specification in the DECLARE-PRINTER command can influence the appearance of the chart. The following table lists the final appearance of the chart with a combination
of values for PRINTER.COLOR and CHART.FILL options.

CHART.FILL=

PRINTER.COLOR=Y

PRINTER.COLOR=N

GRAYSCALE

GRAYSCALE

GRAYSCALE

COLOR

COLOR

GRAYSCALE

CROSS­HATCH

COLOR-CROSS­HATCH

CROSSHATCH

NONE

NONE

NONE

Specifying Chart Data Series Colors

Color palettes are used in the new graphics to set the colors of each data point in a data series. You specify the color palette to be used
in a business chart by creating an SQR COLOR-PALETTE using the CREATE-COLOR-PALETTE command. The following code demonstrates
how to create the color palette:

Users can specify any number of palettes, with up to 64 colors defined in each palette. If there are more data points in the
data sets than defined colors in the palette, the palette resets and continues to set the data point colors from Color_1 to
Color_n.

After a color palette has been defined, it can be used within the DECLARE-CHART and PRINT-CHART commands to specify the color
palette to be used. The following code example demonstrates the use of a color palette:

Print-Chart test_Chart
COLOR-PALETTE = 'Test-Palette'

Specifying Chart Item Colors

Users can specify the foreground and background colors of the individual areas within a business chart using ITEM-COLOR = (rgb-value) within the DECLARE-CHART and PRINT-CHART commands. The following is a list of chart item keywords that are valid for ITEM-COLOR:

ChartBackground—Background color of entire chart area.

ChartForeground—Text and Line color of chart area.

HeaderBackground—Area within the text box specified for the Title and Subtitle.

HeaderForeground—Text color of the Title and Subtitle.

FooterBackground—Area within the text box specified for the X Axis label.

FooterForeground—Text color of the X Axis label.

LegendBackground—Area within the box defining the legend.

LegendForeground—Text and outline color of the legend.

ChartAreaBackground—Area that includes the body of the chart.

ChartAreaForeground—Text and line colors of the chart area.

PlotAreaBackground—Area within the X and Y Axis of a chart.

PlotAreaForeground—Text and line colors of the plot area.

Parameters

chart_name

A unique name to be used for referencing a chart.

CHART-SIZE

The size of the chart frame in standard SQR coordinate units.

The following DECLARE-CHART Command Arguments table describes other arguments for the DECLARE-CHART command.

Note. PeopleSoft does not currently support setting NewGraphics to Yes. You should not use the DATA-LABELS, COLOR-PALETTE, and ITEM-COLOR
attributes listed below as they are only valid when NewGraphics=Yes.

Argument

Values

Description

DATA-LABELS

Yes|No

If NewGraphics is set to Yes, use this argument to specify whether SQR prints the numeric value above the individual data
points. Specify NO to suppress the numeric values.

COLOR-PALETTE

palette_name

If NewGraphics is set to Yes, use this argument to specify the name of the color palette to be used to color the individual
data points in each chart (example: bar, slice, point). A valid SQR color-palette must be defined to use COLOR-PALETTE.

ITEM-COLOR

ChartBackground|ChartForeground

HeaderBackground|HeaderForeground

FooterBackground|FooterForeground

LegendBackground|LegendForeground

ChartAreaBackground|ChartAreaForeground

PlotAreaBackground

If NewGraphics is set to Yes, use this argument to specify the color of an individual item in a chart. Specify a chart item
and a valid (r,g,b) color to set the color of the chart item.

TITLE

NONE | text

Specifies a title for the chart. That text is placed at the top of the chart.

SUB-TITLE

NONE | text

Specifies a subtitle for the chart. That text is placed below the title regardless of whether TITLE is specified.

FILL

GRAYSCALE | COLOR | CROSS­HATCH | NONE

Specifies the type of filling that is applied to the shapes (bars, pie-segments, and so on.) in the chart. GRAYSCALE varies
the density of black dots. COLOR sends color instructions to the current printer. If the current printer does not support
color, then color can appear in a GRAYSCALE fashion. CROSSHATCH uses patterns to fill the shapes representing each data set.
With NONE, all graph shapes are filled with white.

3D-EFFECTS

YES | NO

Specifies whether the chart depth appears with 3-D effects. If set to NO, the chart is displayed in the default 2D mode.

BORDER

YES | NO

If set to YES, a border is drawn around the chart. If set to NO, no border is displayed around the chart.

POINT-MARKERS

YES | NO

Specifies whether point markers appear on line charts. If set to YES, point markers appear on line charts. If set to NO, point
markers do not appear.

Places the legend in the specified location on the chart. The first portion of the placement parameter (CENTER, UPPER, or
LOWER) is the vertical position, and the second portion (RIGHT, LEFT, or CENTER) is the horizontal.

LEGEND-PRESENTATION

INSIDE | OUTSIDE

Specifies where the legend appears on the chart. If set to INSIDE, the legend is presented inside the area defined by the
two axes. If set to OUTSIDE, the legend is presented within the chart border, but outside of the region represented by the
two axes.

PIE-SEGMENT-QUANTITY- DISPLAY

YES | NO

Specifies whether quantity is presented for each pie segment. If set to YES, the quantity is presented.

PIE-SEGMENT-PERCENT-DISPLAY

YES | NO

Specifies whether the percent-of-total number is presented for each pie segment. If set to YES, the percent-of-total figures
is presented.

PIE-SEGMENT-EXPLODE

NONE | MAX |MIN | USE-3RD-DATA-COLUMN

Controls which pie segments are exploded (selected) within the pie chart. MAX selects the largest segment. MIN selects the
smallest segment. USE-3RD-DATA-COLUMN uses the third field in the DATA-ARRAY to determine which pie segments are exploded.
This third field should be a CHAR and values of 'YES' or 'Y' indicate that the segment should be exploded.

X-AXIS-LABEL or Y-AXIS-LABEL

NONE | text

Specifies a line of text to be presented below (or alongside) the tick-mark labels on the axis.

X-AXIS-MIN-VALUE

AUTOSCALE | number

Specifies the minimum value on the axis. If there are data values that are less than X-AXIS- MIN-VALUE, they are not presented.
AUTOSCALE directs SQR to calculate an appropriate minimum value.

Y-AXIS-MIN-VALUE

AUTOSCALE | number

Specifies the minimum value on the axis. If there are data values that are less than Y-AXIS- MIN-VALUE, then they are not
presented. AUTOSCALE directs SQR to calculate an appropriate minimum value.

X-AXIS-MAX-VALUE

AUTOSCALE | number

Specifies the maximum value on the axis. If there are data values that are greater than X- AXIS-MAX-VALUE, they are not presented.
AUTOSCALE directs SQR to calculate an appropriate maximum value.

Y-AXIS-MAX-VALUE

AUTOSCALE | number

Specifies the maximum value on the axis. If there are data values that are greater than Y- AXIS-MAX-VALUE, they are not presented.
AUTOSCALE directs SQR to calculate an appropriate maximum value.

X-AXIS-SCALE or Y-AXIS-SCALE

LOG | LINEAR

Specifies the scale for the axis. LOG specifies a logarithmic scale for the axis. Otherwise, the scale is linear.

X-AXIS-MAJOR-TICK- MARKS

YES | NO

Specifies whether to display tick-marks for major increments on the X-axis. If set to YES, tick-marks appear on the axis between
X-AXIS-MIN-VALUE and X-AXIS-MAX-VALUE, according to the X-AXIS-SCALE setting spaced by X-AXIS-MAJOR-INCREMENT.

Y-AXIS-MAJOR-TICK- MARKS

YES | NO

Specifies whether to display tick-marks for major increments on the Y-axis. If set to YES, tick-marks appear on the axis between
Y-AXIS-MIN-VALUE and Y-AXIS-MAX-VALUE, according to the Y-AXIS-SCALE setting spaced by Y-AXIS-MAJOR-INCREMENT.

X-AXIS-MINOR-TICK- MARKS

YES | NO

Specifies whether to display tick-marks for minor increments on the X-axis. If set to YES, tick-marks appear on the axis between
X-AXIS-MIN-VALUE and X-AXIS-MAX-VALUE, according to the X-AXIS-SCALE setting spaced by X-AXIS-MINOR-INCREMENT.

Y-AXIS-MINOR-TICK- MARKS

YES | NO

Specifies whether to display tick-marks for minor increments on the Y-axis. If set to YES, tick-marks appear on the axis between
Y-AXIS-MIN-VALUE and Y-AXIS-MAX-VALUE, according to the Y-AXIS-SCALE setting spaced by Y-AXIS-MINOR-INCREMENT.

X-AXIS-MAJOR-INCREMENT or Y-AXIS-MAJOR-INCREMENT

AUTOSCALE | number

Specifies, for SQR, the increment used for spacing the major tick-marks on the axis. AUTOSCALE directs SQR to determine an
appropriate increment.

X-AXIS-MINOR-INCREMENT or Y-AXIS-MINOR-INCREMENT

number

Specifies, for SQR, the increment used for spacing the minor tick-marks on the axis. These arguments must be set for the X-AXIS-
MINOR-TICK-MARKS and the Y-AXIS- MINOR-TICK-MARKS to appear.

X-AXIS-TICK-MARK- PLACEMENT or Y-AXIS-TICK-MARK- PLACEMENT

INSIDE | OUTSIDE | BOTH

Specifies where to place the tick-marks on the axis. INSIDE (or OUTSIDE) directs SQR to place the tick-marks on the inside
(or outside) of the axis only. BOTH directs SQR to draw the tick-marks such that they appear on both sides of the axis.

X-AXIS-GRID or Y-AXIS-GRID

YES | NO

Specifies whether a grid line is drawn for each major tick-mark on the axis. If set toYES, a dashed grid line is drawn for
each major tick-mark. If set to NO, no grid line is drawn on the axis.

Example

This code example declares a basic sales chart using DECLARE-CHART. For each region, the SUB-TITLE, DATA-ARRAY, and other
elements are overridden to provide the chart with the specific features desired.

DECLARE-COLOR-MAP

The DECLARE-COLOR-MAP command in the BEGIN-SETUP section defines or redefines colors in an SQR report. You can define an endless
number of entries.

Parameters

color_name

A color_name is composed of alphanumeric characters (A-Z, 0-9), the underscore (_) character, and the hyphen (-) character. It must start
with an alphabetical (A-Z) character and is not case-sensitive. The name none is reserved and cannot be assigned a value. A name in the format (RGBredgreenblue) cannot be assigned a value. The name default is reserved and cannot be assigned a value. Default is used during execution when a referenced color is not defined in the runtime environment.

{rgb}

red_lit | _var | _col, green_lit | _var | _col, blue_lit | _var | _col where each component is a value in the range of 000 to 255. In the BEGIN-SETUP section, only literal values are allowed.

Defines the datasource logon parameters prior to logon. Can be used to override the default connection logon parameters.

Parameters

connection_name

A user-defined name for describing a datasource connection.

USER, PASSWORD

Traditional logon semantics.

PARAMETERS = keyword_str=attr_str;

Defines a list of keyword-attribute pairs required by a datasource driver for logon. There is no syntax restriction on these
entries apart from the delimiting semicolons (;) and equal signs (=). The keywords must match the logon property names listed
for a datasource.

NO-DUPLICATE=TRUE|FALSE(default is FALSE)

This optional keyword prevents SQR from automatically creating additional logins to datasources that are busy handling a previous
query. Creating a new login in such cases is the default behavior for SQR, which allows a single CONNECTION declaration to
be used in a subquery. The behavior, while allowing dynamic logins as-needed, causes problems when doing both DDL (BEGIN-SQL)
and DML (BEGIN-SELECT) against temporary tables in certain vendors datasources. In such cases, you must fetch from the temporary
table using the same login in which it was created. Here, you should code the CONNECTION as NO-DUPLICATE=TRUE, and then use
that connection in both the table creation logic of BEGIN-SQL and the row fetching logic of BEGIN-SELECT.

DECLARE-IMAGE

Note. If TYPE, IMAGE-SIZE, and SOURCE are not defined in DECLARE-IMAGE, they must be defined in PRINT-IMAGE.

Description

Declares the type, size, and source of an image to be printed.

The DECLARE-IMAGE command defines and names an image. This image can then be placed in a report at the position specified
in the PRINT-IMAGE command.

Note. If the image file is unrecognizable, or has incomplete header information, a box (either shaded, for HP printers, or having
a diagonal line through it in the case of postscript) appears where the image is expected.

The DECLARE-LAYOUT command describes the characteristics of a layout to be used for an output file. A layout can be shared
by more than one report. If no DECLARE-LAYOUT is defined or if a DECLARE-REPORT does not reference a defined layout, a layout
named DEFAULT is created with the default attribute values shown in the DECLARE-LAYOUT Command Arguments table. For an example of how DECLARE-LAYOUT
relates to DECLARE-REPORT, see the DECLARE-REPORT examples in this document.

You can define as many layouts as are necessary for the requirements of the application. You can override the DEFAULT layout
attributes by defining a layout called DEFAULT in your program. Each layout name must be unique.

SQR maps its line and column positions on the page by using a grid determined by the LINE-HEIGHT and CHAR-WIDTH arguments. That is, SQR calculates the number of columns per row by dividing the LINE-WIDTH by the CHAR-WIDTH and calculates the number
of lines by dividing the PAGE-DEPTH by the LINE-HEIGHT. Each printed segment of text is placed on the page using this grid. Because the characters in proportional
fonts vary in width, it is possible that a word or string is wider than the horizontal space you have allotted, especially
in words containing uppercase letters or boldfaced characters. To account for this behavior, you can either move the column
position in the PRINT or POSITION statements or indicate a larger CHAR-WIDTH in the DECLARE-LAYOUT command.

The DECLARE-LAYOUT command selects the proper fonts. In addition, the parameter interacts with PAPER-SIZE as follows:

When you do not specify ORIENTATION=LANDSCAPE or the PAPER-SIZE dimensions, SQR creates a page with the dimensions set to 11 inch by 8.5 inch. This results in a page of 100 columns by 45
lines with 0.5 inch margins.

When you specify PAPER-SIZE=(paper_name) the page orientation is set according to the paper_name specified. If you also specify ORIENTATION and the value differs from the PAPER-SIZE value, the ORIENTATION value overrides
the PAPER-SIZE value.

When you specify PAPER-SIZE=(page_width, page_depth), SQR does not swap the page width and page depth if ORIENTATION=LANDSCAPE.

Parameters

layout_name

A unique layout name to be used for referencing the layout and its attributes.

uom (unit of measure)

An optional suffix which denotes the unit of measure to apply to the preceding value.

paper_name

An option of PAPER-SIZE. This name is associated with predefined dimensions.

This table lists valid unit of measure suffixes:

Suffix

Meaning

Definition

dp

decipoint

0.001388 inch

pt

point

0.01388 inch

mm

millimeter

0.03937 inch

cm

centimeter

0.3937 inch

in

inch

1.0000 inch

This table lists valid paper names for the paper_name parameter.

Name

Width

Depth

Orientation

Letter

8.5 in

11 in

Portrait

Legal

8.5 in

14 in

Portrait

A4

8.27 in

11.69 in

Portrait

Executive

7.25 in

10.5 in

Portrait

B5

7.17 in

10.12 in

Portrait

Com-10

4.125 in

9.5 in

Landscape

Monarch

3.875 in

7.5 in

Landscape

DL

4.33 in

8.66 in

Landscape

C5

6.378 in

9.016 in

Landscape

This table describes the arguments of the DECLARE-LAYOUT command:

Argument

Choice or Default UOM

Default Value

Description

PAPER-SIZE

inches

8.5 in, 11 in

Physical size of the page. The first parameter is the width of the page. The second parameter is the depth or length. It may
also be a predefined name. (See the table of valid paper names..) Note that when ORIENTATION= LANDSCAPE the default values
are 11 in, 8.5 in.

FORMFEED

YES, NO

YES

Specifies whether formfeeds are to be written at the end of each page.

Amount of blank space to leave at the right side of the page. If you specify LINE-WIDTH or MAX-COLUMNS, you cannot use this
parameter.

LINE-WIDTH

inches

7.5 in

Length of the line. If you specify RIGHT-MARGIN or MAX-COLUMNS, you cannot use this parameter.

MAX-COLUMNS

75

Maximum number of columns in a line. If you specify RIGHT-MARGIN or LINE-WIDTH, you cannot use this parameter.

BOTTOM-MARGIN

inches

0.5 in

Amount of blank space to leave at the bottom of the page. If you specify PAGE-DEPTH or MAX-LINES, you cannot use this parameter.

PAGE-DEPTH

inches

10 in

Depth of the page. If you specify BOTTOM-MARGIN or MAX-LINES, you cannot use this parameter.

MAX-LINES

60

Maximum number of lines printed on the page. If you specify PAGE-DEPTH or BOTTOM-MARGIN, you cannot use this parameter.

LINE-HEIGHT

points

12 pt

Size of each SQR line on the page. There are 72 points per inch. If LINE-HEIGHT is not specified, it follows the value for
POINT-SIZE, if specified. The default value of 12 points yields 6 lines per inch. For the printer type LINEPRINTER, this value
is used only to calculate the TOP-MARGIN and BOTTOM-MARGIN (for example, not in computing the position on the page).

CHAR-WIDTH

points

7.2 pt

Size of each SQR horizontal character column on the page (for example, the distance between the locations (1, 12) and (1, 13)).
For the printer type LINEPRINTER, this value is used only to calculate the TOP-MARGIN and BOTTOM-MARGIN (not in computing
the position on the page).

Example

This example illustrates the ability to specify these parameters using a different measurement system, such as metric:

Each printer has a set of defaults as listed in the DECLARE-PRINTER Command Arguments table. The DECLARE-PRINTER command overrides
these defaults.

Use the DECLARE-PRINTER command in the SETUP section to define the characteristics of the printer or printers to be used.
If you need to change some of the arguments depending on the runtime environment, you can use the ALTER-PRINTER command in any part of the program except the PROGRAM and SETUP sections.

A program can contain no more than one DECLARE-PRINTER command for each printer type for each report. If you do not provide
a printer declaration, the default specifications are used. The default printer attributes can be overridden by providing
a DECLARE-PRINTER specification for each printer. The names are:

DEFAULT-LP for line printer.

DEFAULT-HP for HP LaserJet.

DEFAULT-HT for HTML.

DEFAULT-PS for PostScript

This table lists the arguments, provides the possible choices or measure, lists the default values, and describes the arguments.

Argument

Choice or Measure

Default

Description

FOR-REPORTS

ALL

The name of the reports that use this printer definition. The default is ALL, for all reports. This argument is required only
for a program with multiple reports. If you are writing a program that produces only a single report, you can ignore this
argument.

TYPE

LINEPRINTER, POSTSCRIPT, HPLASERJET, HTML, LP, PS, HP, HT

LP

The output type specific to each printer. LINEPRINTER (LP) files can be viewed by a text editor. POSTSCRIPT (PS) files require
you to know PostScript to understand what will be shown on the printer. HPLASERJET (HP) files are binary files and cannot
be edited or viewed. HTML (HT) files can be viewed by a browser.

INIT-STRING

(none)

Sends control or other characters to the printer at the beginning of the report. This parameter is designed primarily for
the LINEPRINTER and has limited use with other printer types. Specify nondisplay characters by placing their decimal values
inside angle brackets. For example, <27> is the ESC or escape character.

RESET-STRING

(none)

Sends control or other characters to the printer at the end of the report. This parameter is designed primarily for the LINEPRINTER
and has limited use with other printer types. Specify nondisplay characters by placing their decimal values inside angle brackets.
For example, <27> is the ESC or escape character.

COLOR

Yes, No

No

Specifies whether this printer can print in color.

POINT-SIZE

points

12

This argument does not apply to LINEPRINTER printers. The beginning size of the selected font.

FONT-TYPE

PROPORTIONAL, FIXED

Depends on the font

This argument applies only to HPLASERJET printers and needs to be specified only for font types not defined in the Fonts Available
for HP LaserJet Printers in SQR table.

SYMBOL-SET

HP defined sets

0U

This argument applies only to HPLASERJET printers. The default value of 0U is for the USASCII symbol set. For a complete list
of the symbol sets, see the HP LaserJet Technical Reference Manual.

STARTUP-FILE

filename

POSTSCRI.STR

This argument applies only to POSTSCRIPT printers. This argument is used to specify an alternate startup file. Unless otherwise
specified, the default startup file is located in the directory pointed to by the environment variable SQRDIR.

PITCH

characters/inch

10

This argument is for HPLASERJET printers only. If you specify a fixed pitch font, you should also indicate the pitch.

FONT

font_number

3

This is the font number of the typeface to use. For HPLASERJET printers, this is the typeface value as defined by Hewlett-Packard.
For a complete list of the typeface numbers, see the HP LaserJet Technical Reference Manual.

For POSTSCRIPT printers, SQR supplies a list of fonts and arbitrary font number assignments in the file POSTSCRI.STR. The
font numbers are the same as those for HP LaserJet printers, wherever possible, so that you can use the same font number for
reports to be printed on both types of printers. You can modify the font list in POSTSCRI.STR to add or delete fonts. Read
the POSTSCRI.STR file for instructions. The Fonts Available for HP LaserJet Printers in SQR table lists the fonts available
in SQR internally. The Fonts Available for PostScript Printers table lists the fonts available in the SQR POSTSCRI.STR file.

BEFORE-BOLD

any string

(none)

The BEFORE-BOLD and AFTER-BOLD arguments are for LINEPRINTER printers only. They specify the character string to turn boldfacing
on and off. If the string contains blank characters, enclose it in single quote marks ('...'). To specify nonprintable characters,
such as ESC, enclose the decimal value inside angle brackets as shown: BEFORE-BOLD=<27>[r ! Turn on bold AFTER-BOLD=<27>[u ! Turn it off

These arguments work with the BOLD argument of the PRINT command.

AFTER-BOLD

any string

(none)

See BEFORE-BOLD.

This table lists the fonts available in SQR for use with the FONT argument for HPLASERJET printer types.

Value

Typeface

Style

0

Line printer

Fixed

1

Pica

Fixed

2

Elite

Fixed

3

Courier

Fixed

4

Helvetica

Proportional

5

Times Roman

Proportional

6

Letter Gothic

Fixed

8

Prestige

Fixed

11

Presentations

Fixed

17

Optima

Proportional

18

Garamondi

Proportional

19

Cooper Black

Proportional

20

Coronet Bold

Proportional

21

Broadway

Proportional

22

Bauer Bodini Black Condensed

Proportional

23

Century Schoolbook

Proportional

24

University Roman

Proportional

The font you choose—in orientation, typeface, and point size—must be an internal font, available in a font cartridge, or downloaded
to the printer.

For fonts not listed in the Fonts Available for HP LaserJet Printers in SQR table, you must indicate the font style using
the FONT-TYPE argument to ensure that the correct typeface is selected by the printer.

This table lists the fonts available in SQR for use with the FONT argument for PostScript printer types:

Value

Typeface

Boldface Type Available

3

Courier

Y

4

Helvetica

Y

5

Times Roman

Y

6

Avant Garde Book

N/A

8

Palatino Roman

Y

11

Symbol

N/A

12

Zapf Dingbats

N/A

17

Zapf Chancery Medium Italic

N/A

18

Bookman Light

N/A

23

New Century Schoolbook Roman

Y

30

Courier Oblique

Y

31

Helvetica Oblique

Y

32

Times Italic

Y

33

Avant Garde Demi

N/A

34

Avant Garde Book Oblique

N/A

35

Avant Garde Demi Oblique

N/A

36

Palatino Oblique

Y

37

New Century Schoolbook Italic

Y

38

Helvetica Narrow

Y

39

Helvetica Narrow Oblique

Y

40

Bookman Demi

N/A

41

Bookman Light Italic

N/A

42

Bookman Demi Italic

N/A

Other type faces can be added to the POSTSCRI.STR file.

There are different fonts available in SQR for Windows when printing with Microsoft Windows printer drivers (using the -PRINTER:WP
command-line flag). When you use the -PRINTER:WP flag, your report is sent directly to the default Microsoft Windows printer.
To specify a nondefault Microsoft Windows printer, enter -PRINTER:WP:{printer name}. The {printer name} is the name assigned
to your printer. For example, to send output to a Windows printer named NewPrinter, you would use -PRINTER:WP:NewPrinter. If your printer name has spaces, enclose the entire argument in quotes.

Fonts are specified by number in the FONT qualifier of the ALTER-PRINTER command.

This table lists the fonts available when printing with Microsoft Windows printer drivers:

Value

Windows Font/Name

Style

3

Courier New

Fixed

300

Courier New

Bold

4

Arial

Proportional

400

Arial

Bold

5

Times New Roman

Proportional

500

Times New Roman

Bold

6

AvantGarde

Proportional

8

Palatino

Proportional

800

Palatino

Bold

11

Symbol

Proportional

Note. Fonts 6, 8, and 800 are not supplied with Microsoft Windows. You can get these fonts by purchasing the ADOBE Type Manager
(ATM). The advantage of using ATM fonts is the compatibility for PostScript printer fonts. The Symbol font uses the SYMBOL_CHARSET
instead of the usual ANSI_CHARSET character set. You can add more fonts by editing the appropriate Fonts section in the sqr.ini
file.

The DECLARE-PROCEDURE command can be used to define SQR procedures that are to be invoked before or after a report is printed
or before the beginning or end of each page.

Issue the DECLARE-PROCEDURE in the SETUP section. For multiple reports, you can use the command as often as required to declare
procedures required by all the reports. If you issue multiple DECLARE-PROCEDURE commands, the last one takes precedence. In
this way, you can use one command to declare common procedures for ALL reports and others to declare unique procedures for
individual reports. The referenced procedures can accept arguments.

If there are no FOR-REPORTS specified, ALL is assumed. Initially, the default for each of the four procedure types is NONE.
If a procedure is defined in one DECLARE-PROCEDURE for a report, that procedure is used unless NONE is specified.

Use the USE-PROCEDURE command to change the procedures to be used at runtime. To turn a procedure off, specify NONE in the
USE-PROCEDURE statement.

Parameters

FOR-REPORTS

Specifies one or more reports that use the given procedures. This argument is required only for a program with multiple reports.
If you are writing a program that produces only a single report, you can ignore this argument.

BEFORE-REPORT

Specifies a procedure to be executed at the time of the execution of the first command which causes output to be generated
(PRINT). It can be used, for example, to create a report heading.

AFTER-REPORT

Specifies a procedure to be executed just before the report file is closed at the end of the report. It can be used to print
totals or other closing summary information. If no report was generated, the procedure does not execute.

BEFORE-PAGE

Specifies a procedure to be executed at the beginning of every page, just before the first output command for the page. It
can be used, for example, to set up page totals.

AFTER-PAGE

Specifies a procedure to be executed just before each page is written to the file. It can be used, for example, to display
page totals.

You can optionally specify arguments to be passed to any of the procedures. Arguments can be any variable, column, or literal.

Example

The following example illustrates the DECLARE-PROCEDURE command

declare-procedure ! These procedures will
before-report=report_heading ! be used by all reports
after-report=report_footing
end-declare
declare-procedure ! These procedures will
for-reports=(customer) ! be used by the customer
before-page=page_setup ! report
after-page=page_totals
end-declare

You can use the DECLARE-REPORT command to declare one or more reports to be produced in the application.

You must use this command when developing applications to produce more than one report.

Multiple reports can share the same layout and the same printer declarations or each report can use its own layout or printer
definitions if the report has unique characteristics.

When you are printing multiple reports, unless report names are specified using the -F command-line flag, the first report
declared is generated with the name of program.lis, where program is the application name.

Additional reports are generated with names conforming to the rules dictated by the OUTPUT-FILE-MODE setting in the sqr.ini
file.

When the -KEEP or -NOLIS flags are used, the first intermediate print file (.spf file) is generated with a name of program.spf
and additional reports are generated with names conforming to the rules dictated by the OUTPUT-FILE-MODE setting in the sqr.ini
file..

Parameters

report_name

Specifies the name of the report.

TOC

Specifies the name of the table of contents for this report.

LAYOUT

Specifies the name of the layout for this report. If no layout is specified, the default layout is used.

PRINTER-TYPE

Specifies the type of printer to be used for this report. If no printer type is specified, the default, LINEPRINTER, is used
for this report. If no DECLARE-PRINTER is specified, DEFAULT-LP is used. Valid values for PRINTER-TYPE are: HT, HP, PD, PS,
LP, HTML, HPLASERJET, POSTSCRIPT, and LINEPRINTER

Specifies the number of spaces by which each level is indented. The default setting is 4.

BEFORE-TOC

Specifies a procedure to be executed before generating the table of contents. If no table of contents is generated, the procedure
does not execute.

AFTER-TOC

Specifies a procedure to be executed after generating the table of contents. If no table of contents is generated, the procedure
does not execute.

BEFORE-PAGE

Specifies a procedure to be executed at the start of every page.

AFTER-PAGE

Specifies a procedure to be executed at the end of each page.

ENTRY

Specifies a procedure that is executed to process each table of contents entry (instead of SQR doing it for you). When this
procedure is invoked, the following SQR-reserved variables are populated with data about the TOC entry:

#SQR-TOC-LEVEL contains the level.

#SQR-TOC-TEXT contains the text.

#SQR-TOC-PAGE contains the page number.

These are global variables. If the procedure is local, you must precede it with an underscore (for example, #_sqr-toc-page).
These three SQR-reserved variables are only valid within the scope of the ENTRY procedure. They can be referenced outside
the scope, but their contents are undefined.

You can set the default numeric type externally, using the -DNT command-line flag or the DEFAULT-NUMERIC setting in the Default-Settings
section of the sqr.ini file. However, the setting in the DECLARE-VARIABLE command takes precedence over all other settings.
If the command has not been used, then the -DNT command-line flag takes precedence over the setting in the sqr.ini file.

In addition to FLOAT, INTEGER, or DECIMAL, you can set DEFAULT-NUMERIC in the sqr.ini file and -DNT command-line flag to V30.
With V30, the program acts in the same manner as in pre-version 4.0 releases; that is, all variables are FLOAT. V30 is not
a valid setting for the DEFAULT-NUMERIC setting in the DECLARE-VARIABLE command.

The DECLARE-VARIABLE command enables the user to determine the type of variables to use. This command can only appear in the
SETUP section or as the first statement of a local procedure. The placement of the command affects its scope. When used in
the SETUP section, it affects all variables in the entire program. Alternately, when it is placed in a local procedure, its
effect is limited to the scope of the procedure. If the command is in both places, the local declaration takes precedence
over the SETUP declaration.

In addition to declaring variables, this command enables the default numeric type to be specified using the DEFAULT-NUMERIC
setting as FLOAT, INTEGER, or DECIMAL. When dealing with money or where more precision is required, use the DECIMAL qualifier.

The DECLARE-VARIABLE command, the -DNT command-line flag, and the DEFAULT-NUMERIC setting in the sqr.ini file affect the way
numeric literals are typed. If V30 is specified, then all numeric literals are FLOAT (just as in pre-version 4.0 releases);
otherwise, the use or lack of a decimal point determines the type of the literal as either FLOAT or INTEGER, respectively.
Finally, not specifying DECLARE-VARIABLE command, the -DNT command- line flag, and the DEFAULT-NUMERIC setting in the sqr.ini
file is the same as specifying V30.

Parameters

DEFAULT-NUMERIC

Specifies the default type for numeric variables. Unless explicitly declared otherwise, a numeric variable assumes the variable
type. This qualifier overrides any setting from the command-line flag -DNT or the DEFAULT- NUMERIC entry in the [Default-Settings]
section of the sqr.ini file. If -DNT was not specified on the command line and the sqr.ini file entry has no DEFAULT-NUMERIC
entry, then the default numeric type is FLOAT.

DECIMAL

Specifies that the numeric variables that follow are decimal variables with a precision specified with prec_lit. The precision
can be assigned to the group of variables or to each individual variable. The precision is the total number of digits used
to represent the number. This precision can range from 1 to 38. The default value is 16. The range of decimal numbers is from
-9.9999999999999999999999999999999999999E±4096 to +9.9999999999999999999999999999999999999E±4096

FLOAT

Specifies that the numeric variables that follow are used as double precision floating point. The range and precision of these
numbers are machine-dependent.

DATE

Specifies that the date variables that follow can contain a date in the range of January1, 4713 BC to December 31, 9999 AD.

INTEGER

Specifies that the numeric variables that follow are used as integers with a range of -2147483648 to +2147483647.

#DEFINE

Syntax

#DEFINE substitution_variablevalue

Description

Declares a value for a substitution variable within the body of the report (rather than using the ASK command).

#DEFINE is useful for specifying constants such as column locations, printer fonts, or any number or string that is used in several locations in the program. When the
value of the number or string must be changed, you need only change the #DEFINE command. All references to that variable change
automatically, which makes modifying programs much simpler.

If the ASK command is used to obtain the value of a substitution variable that has already been defined, ASK uses the previous
value and the user is not prompted. This enables you to predefine some variables and not others. When the report runs, ASK
requests values for only those variables that have not had a value assigned.

You can use #DEFINE commands inside an include file. This is a method of gathering commonly used declarations into one place,
and reusing them for more than one report.

The value in the #DEFINE command can have embedded spaces and does not need to be enclosed within quotes. The entire string
is used as is.

The #DEFINE command cannot be broken across program lines.

Parameters

substitution_variable

The variable to be used as the substitution variable. The substitution variable is used to substitute any command, argument,
or part of a SQL statement at compile time.

DISPLAY

Syntax

DISPLAY {any_lit|_var|_col}
[[:$]edit_mask|NUMBER|MONEY|DATE][NOLINE]

Description

Displays the specified column, variable, or literal.

The DISPLAY command can display data to a terminal. The data is displayed to the current location on the screen. If you want
to display more than one field on the same line, use NOLINE on each display except the last.

Dates can be contained in a date variable or column, or a string literal, column, or variable. When a date variable or column
is displayed without an edit mask, the date appears in the following manner:

For DATETIME columns and SQR DATE variables, SQR uses the format specified by the SQR_DB_DATE_FORMAT setting.

If this has not been set, SQR uses the first database-dependent format as listed in the Default Database Formats table.

For DATE columns, SQR uses the format specified by the SQR_DB_DATE_ONLY_FORMAT setting.

If this has not been set, SQR uses the format listed in the DATE Column Formats table.

For TIME columns, SQR uses the format specified by the SQR_DB_TIME_ONLY_FORMAT setting.

If this has not been set, SQR uses the format listed in the TIME Column Formats table.

When displaying a date in a string literal, column, or variable using EDIT or DATE, the string uses the format specified by
the SQR_DB_DATE_FORMAT setting, one of the database-dependent formats as listed in the Default Database Formats table, or
the database-independent format SYYYYMMDD[HH24[MI[SS[NNNNNN]]]].

If you require more control over the display, use the SHOW command.

Parameters

any_lit|_var|_col

The text, number, or date to be displayed.

edit_mask

Causes the field to be edited before being displayed. For additional information regarding edit masks, see the PRINT command.

NUMBER

Indicates that any_lit|_var|_col is to be formatted using the NUMBER-EDIT-MASK of the current locale. This option is not valid
with date variables.

MONEY

Indicates that any_lit|_var|_col is to be formatted using the MONEY-EDIT-MASK of the current locale. This option is not valid
with date variables.

DATE

Indicates that any_lit|_var|_col is to be formatted using the DATE-EDIT-MASK of the current locale. This option is not valid
with numeric variables. If DATE-EDIT-MASK has not been specified, the date is displayed using the default format for that
database (see the Default Database Formats table).

NOLINE

Suppresses the carriage return after the field is displayed.

Example

The following segments illustrate the various features of the DISPLAY command:

DIVIDE

The source field is divided into the destination field and the result is placed in the destination. The source is always first,
the destination always second.

When dealing with money-related values (dollars and cents), use decimal variables rather than float variables. Float variables
are stored as double precision floating point numbers, and small inaccuracies can appear when dividing many numbers in succession.
These inaccuracies can appear due to the way different hardware and software implementations represent floating point numbers.

Parameters

src_num_lit|_var|_col

Divided into the contents of dst_num_var.

dst_num_var

Contains the result after execution.

ON-ERROR

Sets the result to the specified number when a division by zero is attempted. If ON-ERROR is omitted and a division by zero
is attempted, SQR halts with an error message.

ROUND

Rounds the result to the specified number of digits to the right of the decimal point. For float variables, this value can be from
0 to 15. For decimal variables, this value can be from 0 to the precision of the variable. For integer variables, this argument
is not appropriate.

Numeric variables (DECIMAL, INTEGER, FLOAT) can be passed to procedure numeric arguments without regard to the argument type
of the procedure.

SQR automatically converts the numeric values upon entering and leaving the procedure as required.

Date variables can be passed to procedure date or string arguments.

When a field in a DO command receives a value back from a procedure (a colon indicates it is a back value, that is, a value
that is being returned), it must be a string, numeric, or date variable, depending on the procedure argument; however, a date
can be returned to a string variable and vice versa.

When a date is passed to a string, the date is converted to a string according to the following rules:

For DATETIME columns and SQR DATE variables, SQR uses the format specified by the SQR_DB_DATE_FORMAT setting.

If this has not been set, SQR ues the first database-dependent format as listed in the Default Database Formats table.

For DATE columns, SQR uses the format specified by the SQR_DB_DATE_ONLY_FORMAT setting.

If this has not been set, SQR uses the format listed in the DATE Column Formats table.

For TIME columns, SQR uses the format specified by the SQR_DB_TIME_ONLY_FORMAT setting.

If this has not been set, SQR uses the format as listed in the TIME Column Formats table.

Parameters

procedure_name

Specifies the name of the procedure to be executed.

arg1 [, argi ]

Specifies the arguments to be passed to the procedure. Arguments can be any type of variable or constant value.

#ELSE

Syntax

#ELSE

Description

Compiles the code following the #ELSE command when a preceding #IF, #IFDEF, or #IFNDEF command is FALSE. (#ELSE is a compiler
directive that works with the #IF, #IFDEF, and #IFNDEF compiler directives.)

See Also

The #IF, #IFDEF, and #IFNDEF commands for a description of each compiler directive.

ELSE

Syntax

ELSE

Description

ELSE is an optional command in an IF command.

See Also

The IF command for a description and example.

ENCODE

Syntax

ENCODE src_code_string_lit INTO dst_txt_var

Description

Assigns a nondisplay or display character to a string variable.

The ENCODE command can define nondisplay characters or escape sequences sent to an output device. These characters or sequences can perform complex output device manipulations. The ENCODE command
also displays characters not in the keyboard. If your keyboard does not have the Euro symbol, use the ENCODE feature to create
a string variable for it.

The encode characters can be included in a report at the appropriate location using a PRINT or PRINT-DIRECT command.

Unicode (UCS-2) code points from <1> to <65535> can be defined in ENCODE command.

Parameters

src_code_string_lit

Specifies a string of characters to be encoded and placed in dst_txt_var.

Determines the value of a column, literal, or variable and takes action based on that value.

The EVALUATE command is useful for branching to different commands depending on the value of a specified variable or column.

EVALUATE commands can be nested.

Evaluating a date variable or column with a string results in a date comparison (chronological, not a byte by byte comparison
as is done for strings). The string must be in the proper format as follows:

For DATETIME columns and SQR DATE variables in the format specified by the SQR_DB_DATE_FORMAT setting, SQR uses one of the
database-dependent formats (see the Default Database Formats table), or the database-independent format 'SYYYYMMDD[HH24[MI[SS[NNNNNN]]]]'.

For DATE columns, SQR uses the format specified by the SQR_DB_DATE_ONLY_FORMAT setting, or the format listed in the DATE Column
Formats table.

For TIME columns, SQR uses the format specified by the SQR_DB_TIME_ONLY_FORMAT setting, or the format as listed in the TIME
Column Formats table.

Parameters

any_lit|_var|_col

Specifies a text or numeric column; a text, numeric, or date variable; or a text or numeric literal to be used in the evaluation.
In short, an evaluation argument.

comparison_operator

Any valid comparison operator. See the list of operators in the #IF command. .

Specifies the evaluation expression. The evaluation argument is compared with the argument, beginning from the first WHEN.
If the expression is TRUE, SQR processes the commands after the WHEN. If the expression is FALSE, SQR processes the next WHEN
expression. Each WHEN must be on its own line.

If more than one WHEN expression appears directly before a set of commands, any one of them, if TRUE, causes the commands
to execute.

BREAK

Causes an immediate exit of the EVALUATE command. Use BREAK at the end of a set of commands.

WHEN-OTHER

Signifies the start of default commands to be processed if all other WHEN expressions are FALSE. WHEN-OTHER must appear after
all other WHEN expressions.

If the stored procedure specified in stored_procedure_name contains a SELECT query, the EXECUTE command must specify an INTO argument to process the values from the query. If no INTO
argument is specified, then the values from the query are ignored.

EXECUTE retrieves just the first row when the following instances are true:

The DO procedure is not specified.

The stored procedure, stored_procedure_name selects one or more rows.

An INTO argument is specified.

This is useful for queries returning a single row.

Parameters

-XC

(Sybase only) Specifies that the EXECUTE command shares the same connection as the DO=procedure it can invoke. This argument
is required to share Sybase temporary tables.

ON-ERROR

Declares an SQR procedure to execute if an error occurs. If ON-ERROR is omitted and an error occurs, SQR halts with an error
message. For severe errors (for example, passing too few arguments) SQR halts, even if an error procedure is specified.

You can specify arguments to be passed to the ON-ERROR procedure. Arguments can be any variable, column, or literal.

DO

Specifies an SQR procedure to execute for each row selected in the query. Processing continues until all rows have been retrieved.
You can specify arguments to be passed to the procedure. Arguments can be any variable, column, or literal.

@#status_variable

Returns the procedure status in the specified numeric variable. The status is returned only after selected rows are retrieved.

stored_procedure_name

Names the stored procedure to execute.

@param

Names the parameter to pass to the stored procedure. Parameters can be passed with or without names. If used without names,
they must be listed in the same sequence as defined in the stored procedure.

any_lit|_var|_col

Specifies the value passed to the stored procedure. It can be a string, numeric, or date variable, a previously selected column,
a numeric literal, or a string literal.

OUT[PUT]

Indicates that the parameter receives a value from the stored procedure. The parameter must be a string, numeric, or date
SQR variable. Output parameters receive their values only after rows selected have been retrieved. If you specify multiple
output parameters, they must be in the same sequence as defined in the stored procedure.

INTO

Indicates where to store rows that are retrieved from the stored procedure's SELECT statement. The INTO argument contains
the names of the columns with data types and lengths (if needed). You must specify the columns in the same sequence and match
the data type used in the stored procedure's SELECT statement.

If the stored procedure contains more than one SELECT query, only the first query is described with the INTO argument. Rows
from subsequent queries are ignored.

WITH RECOMPILE

Causes the query to recompile each time it is executed rather than using the plan stored with the procedure. Normally, this
is not required or recommended.

Example

The following code example invokes the stored procedure get_total with two parameters: a string literal and a string variable. The result from the stored procedure is stored in the variable
#total.

execute get_total 'S. Q. Reporter' $State #Total Output

The following code example invokes the stored procedure get_products with two parameters. The stored procedure selects data into five column variables. The SQR procedure print_products is called for each row retrieved. The return status from the stored procedure is placed in the variable #proc_return_status.

EXTRACT

You must specify the starting location of the string as an offset from the beginning of the string and its length. An offset
of zero (0) begins at the leftmost character; an offset of 1 begins one character beyond that, and so on.

If the source is a date variable or column, it is converted to a string before the extraction according to the following rules:

FIND searches the specified string for a character sequence and, if the string is found, returns its location as an offset
from the beginning of the specified string. If the sequence is not found, FIND returns -1 in dst_location_int_var.

You must specify an offset from which to begin the search and supply a numeric variable for the return of the location.

If the source or search object is a date variable or column, it is converted to a string before the search according to the
following rules:

For DATETIME columns and SQR DATE variables, SQR uses the format specified by the SQR_DB_DATE_FORMAT setting.

If this has not been set, SQR uses the first database-dependent format as listed in the Default Database Formats table.

For DATE columns, SQR uses the format specified by the SQR_DB_DATE_ONLY_FORMAT setting is used.

If this has not been set, SQR uses the format listed in the DATE Column Formats table.

For TIME columns, SQR uses the format specified by the SQR_DB_TIME_ONLY_FORMAT setting.

If this has not been set, SQR uses the format as listed in the TIME Column Formats table.

Parameters

{obj_txt_lit|_var|_col}|{date_var|_col}

Specifies a text variable, column, or literal that is to be sought in src_txt_var|_col.

{src_txt_var|_col}|{date_var|_col}

Specifies a text variable or column to be searched.

start_int_lit|_var

Specifies the starting location of the search.

dst_location_int_var

Specifies the returned starting location of the leftmost character of the matching text in {src_txt_var|_col| date_var|_col }.

When a date field is copied to a string variable, SQR converts the date to a string in the format specified by the SQR_DB_DATE_FORMAT
setting. If this has not been set, SQR uses the first database-dependent format listed in the Default Database Formats table.

If the destination is a date variable, the string extracted from the source must be in the format specified by the SQR_DB_DATE_FORMAT
setting, or one of the database-dependent formats (see the Default Database Formats table), or the database- independent format
'SYYYYMMDD[HH24[MI[SS[NNNNNN]]]]'.

src_array_name(element)

If the array's field names are listed, SQR takes the values from the fields and occurrences specified. If the array's field
names are not listed, the values are taken from consecutively defined fields in the array.

field[(occurs)]

Array element and field occurrence numbers can be numeric literals (such as 123) or numeric variables (such as #j). If no
field occurrence is stated, occurrence zero is used.

Example

The following code example copies $name, $start_date, and #salary from the first three fields in the #j'th element of the emps array:

get $name $start_date #salary from emps(#j)

The following code example copies #city_tot and #county_tot from the fields cities and counties in the #j'th element of the states array:

get #city_tot #county_tot from states(#j) cities counties

The following code example copies $code from the #j'th occurrence of the code field in the #n'th element of the codes array:

get $code from codes(#n) code(#j)

See Also

The PUT command for information about moving data into an array.

GET-COLOR

The GET-COLOR command is allowed wherever the PRINT command is allowed. If the requested color settings do not map to a defined name, the name is returned as RGBredgreenblue, where each component is a three digit number—for example, RGB127133033. You can use this format wherever you use a color name. The color name 'none' is returned if no color is associated with
the specified area.

Parameters

PRINT-TEXT-FOREGROUND

Defines the color in which the text prints.

PRINT-TEXT-BACKGROUND

Defines the color to print as a background behind the text.

{color_name_var}

A color_name is composed of alphanumeric characters (A-Z, 0-9), the underscore (_) character, and the hyphen (-) character. The name must start with
an alphabetical (A-Z) character and is not case-sensitive. The name 'none' is reserved and cannot be assigned a value. A name
in the format (RGBredgreenblue) cannot be assigned a value. The name 'default' is reserved and can be assigned a value. 'Default'
is used during execution when a referenced color is not defined in the runtime environment.

{rgb}

red_lit | _var | _col, green_lit | _var | _col, blue_lit | _var | _col where each component is a value in the range of 000 to 255. In the BEGIN-SETUP section, only literal values are allowed.

After GRAPHIC commands execute, SQR changes the current print location to the starting location of the graphic. This is different
from the way the PRINT command works.

The GRAPHIC command has the following variations:

BOX

HORZ-LINE

VERT-LINE

The following sections describe the individual GRAPHIC commands:

Parameters

BOX

BOX draws a box of any size at any location on the page. Boxes can be drawn with any size rule and can be shaded or left empty.

width and depth

The width is the horizontal size in character columns; depth is the vertical size in lines. The top left corner of the box
is drawn at the line and column specified. The bottom right corner is calculated using the width and depth. You can specify
relative placement with (+), (-), or numeric variables, as with regular print positions.

rule_width

The default rule width is 2 decipoints (there are 720 decipoints per inch). The top horizontal line is drawn just below the
base of the line above the starting point. The bottom horizontal line is drawn just below the base of the ending line. Therefore,
a one-line deep box surrounds a single line.

shading

A number between 1 and 100, specifying the percentage of shading to apply. 1 is very light, and 100 is black. If no shading
is specified, the box is blank. Specify a rule-width of zero, if a border is not desired.

HORZ-LINE

HORZ-LINE draws a horizontal line from the location specified, for the length specified. Horizontal lines are drawn just below the base.

rule_width

The default rule width is 2 decipoints.

VERT-LINE

VERT-LINE draws a vertical line from the location specified for the length (in lines) specified. Vertical lines are drawn just below the base line of the
line position specified to just below the base line of the line reached by the length specified. To draw a vertical line next
to a word printed on line 27, position the vertical line to begin on line 26, for a length of 1 line.

The ALTER-PRINTER and DECLARE-PRINTER commands for information about setting and changing the FONT, FONT-TYPE, POINT-SIZE,
and PITCH.

#IF

Syntax

#IF {txt_lit|num_lit}comparison_operator
{txt_lit|num_lit}

Description

Indicates that the commands following are to be compiled when the expression is TRUE. (#IF is a compiler directive.)

SQR has five compiler directives that enable different pieces of SQR code to be compiled, depending on the existence or value of substitution variables (not program variables, such as string, numeric, or date).

Substitution variables defined automatically for each -DEBUGxxx letter can also be used with the #IF, #IFDEF, and #IFNDEF directives. They can turn entire sections of an SQR program on or off from the command line, depending on the -DEBUGxxx flag.

You can nest #IF, #IFDEF, or #IFNDEF directives to a maximum of 10 levels.

The #IF, #IFDEF, or #IFNDEF directives cannot be broken across program lines.

The following table lists the compiler directives.

Directive

Example

Description

#IF

#IF {option}='A'

Compiles the commands following the #IF directive if the substitution variable option is equal to 'A'. The test is not case-sensitive.
Only one simple expression is allowed per #IF command.

#ELSE

#ELSE

Compiles the commands following the #ELSE directive when the #IF expression is FALSE.

#ENDIF

#ENDIF

Ends the #IF directive. #ENDIF can also be typed #END-IF (with a hyphen).

#IFDEF

#IFDEF option

Compiles the commands following the #IFDEF directive if the substitution variable option is defined.

#IFNDEF

#IFNDEF option

Compiles the command following the #IFNDEF directive if the substitution variable option is not defined.

The #DEBUG command for information about the -DEBUG command-line flag.

IF

Syntax

IF logical_expression

IF commands have the following structure:

IF logical_expression
SQR Command...
[ELSE
SQR Command...]
END-IF

Description

Executes commands depending on the value of a condition.

The expression is evaluated as a logical TRUE or FALSE. A value or expression that evaluates to nonzero is TRUE.

Each IF command must have a matching END-IF command.

IF commands can be nested.

Comparing a date variable or column with a string, results in a date comparison (chronological, not a byte by byte comparison
as is done for strings). The string must be in the proper format as follows:

For DATETIME columns and SQR DATE variables, SQR uses the format specified by the SQR_DB_DATE_FORMAT setting, one of the database-dependent
formats (see the Default Database Formats table), or the database-independent format 'SYYYYMMDD[HH24[MI[SS[NNNNNN]]]]'.

For DATE columns, SQR uses the format specified by the SQR_DB_DATE_ONLY_FORMAT setting, or the format listed in the Date Column
Formats table.

For TIME columns, SQR uses the format specified by the SQR_DB_TIME_ONLY_FORMAT setting, or the format as listed in Time Column
Formats table.

Parameters

logical_expression

Any valid logical expression. See the LET command for a description of logical expressions.

#IFDEF

Syntax

#IFDEF substitution_variable

Description

Indicates that the following commands are to be compiled when the substitution variable has been declared by an ASK or #DEFINE command, or by the -DEBUG flag on the SQR command line. (#IFDEF is a compiler directive.)

Parameters

substitution_variable

Is the variable to be used as the substitution variable.

See Also

The #IF command for a description of each compiler directive.

#IFNDEF

Syntax

#IFNDEF substitution_variable

Description

Indicates that the following commands are to be compiled when the substitution variable has not been declared by an ASK or
#DEFINE command, or by the -DEBUG flag on the SQR command line. (#IFNDEF is a compiler directive.)

Parameters

substitution_variable

Is the variable to be used as the substitution variable.

See Also

The #IF command for a description of each compiler directive.

#INCLUDE

Syntax

#INCLUDE filename_lit

Description

Includes an external source file into the SQR report specification.

You may want to keep commonly used routines in a single file and reference or include that file in programs that use the routine. For example, you might have a set of #DEFINE commands for different printers
to control initialization, font changes, and page size declarations. You can reference the appropriate include file depending on which printer you want to use.

Include files can be nested up to four levels. Variable substitution scanning takes place before the #INCLUDE command is processed. This enables you to substitute all or
part of the include file name at runtime, adding flexibility to controlling which file is included for the run.

Parameters

filename_lit

A file name that is valid for the platform on which the application is to be compiled.

Use MAXLEN to prevent the user from entering data that is too long. If an INSERT or UPDATE command references a variable whose length is greater than the length defined in the database, the SQL is rejected and SQR halts.
If the maximum length is exceeded, the terminal beeps (on some systems, this may cause the screen to flash instead).

If prompt is omitted, SQR uses the default prompt, Enter [$|#]var:. In either case, a colon (:) and two spaces are added to the prompt.

Specifying TYPE causes data type checking to occur. If the string entered is not the type specified, the terminal beeps and an error message
is displayed. The INPUT command is then re-executed. If TYPE=DATE is specified, then input_var can be a date or text variable; however, TYPE=DATE is optional if input_var is a date variable. If a numeric variable is used, it is validated as a numeric variable. The types CHAR, TEXT, and DATE
are invalid types. The data types supported are described in the following table:

Data Type

Description

CHAR, TEXT

Any character. This is the default datatype.

NUMBER

A floating point number in the format [+|-]9999.999[E[+|- ]99]

INTEGER

An integer in the format [+|-]99999

DATE

A date in one of the following formats:

MM/DD/YYYY [BC|AD] [HH:MI[:SS[.NNNNNN]] [AM|PM]]

MM-DD-YYYY [BC|AD] [HH:MI[:SS[.NNNNNN]] [AM|PM]]

MM.DD.YYYY [BC|AD] [HH:MI[:SS[.NNNNNN]] [AM|PM]]

SYYYYMMDD[HH24[MI[SS[NNNNNN]]]]

Specifying STATUS causes the INPUT command to complete regardless of what the user enters. No error message is displayed. A nonzero error code
is stored in the indicated numeric variable if the length or datatype entered is incorrect.

The following table lists the values of the INPUT command's STATUS argument:

Status Value

Indicates

0

Successful.

1

Bad type (did not match the datatype of TYPE).

2

Too long (longer than MAXLEN or the input for an INTEGER variable is < -2147483648 or > +2147483647).

3

No arguments remain on the command line. The command was ignored.

By using NOPROMPT and STATUS with the SHOW command, you can write a sophisticated data entry routine.

FORMAT can only be used with dates. It can be a date edit mask or the keyword DATE. Use the keyword DATE if the date must be in
the format as specified with INPUT-DATE-EDIT-MASK setting for the current locale. If FORMAT has not been set, use a database-independent
format for the data as listed in the datatypes table.

Parameters

input_var

Specifies a text, numeric, or date variable for the input data.

MAXLEN

Specifies the maximum length for the data.

prompt

Specifies the prompt displayed to the user.

TYPE

Specifies the datatype required for the input.

STATUS

Specifies a numeric variable for a return status code.

NOPROMPT

Prevents the prompt from being displayed before the INPUT command is processed.

BATCH-MODE

If BATCH-MODE is specified and no more arguments are in the command line, a value of 3 is returned in the STATUS variable and the user
is not prompted for input.

LET

Syntax

LET dst_var=expression

Description

Assigns the value of an expression to a string, numeric, or date variable.

Valid expressions are formed as a combination of operands, operators, and functions. String, numeric, date, and array field
operands can be used in an expression and embedded functions. SQR supports a standardized set of mathematical operators and logical comparison operators working within a carefully defined set of precedence rules. SQR also provides a rich set of mathematical, string, date, and
file manipulation functions along with a number of special purpose utility functions. All combined, the SQR expression provides
a powerful tool that can be tailored to suit any information processing need. The following detail outlines the specific behavior
of each expression component: (1) the operand, (2) the operator, and (3) the function.

Parameters

dst_var

A string, numeric, or date variable or array field to which the result of the expression is assigned.

expression

The expression to evaluate.

Operands

Operands form the backbone of an SQR expression. Operands do not have to be the same type. You can combine string, numeric, and array field operands to form a valid expression. SQR performs a sequence of automatic operand conversions as it evaluates expressions that contain
dissimilar operand types. As the expression is evaluated, operands of lower precision are converted to match the operand of
higher precision. Consider the following code example:

let #answer = #float * #decimal / #integer

Because the multiply and divide operators are equal in precedence, the expression is evaluated as (#float * #decimal) / #integer. Working from the inside out, the #float variable is converted to a decimal type where a multiply is performed yielding the simplified expression, (#decimal)/#integer. SQR now converts the #integer operand to a decimal type before performing the final divide. When finished with the expression evaluation, SQR converts the
result to match the type of the #answer variable.

Converting operands of lower precision to operands of higher precision preserves the number of significant digits. The number of significant
digits is not lost when an integer is converted to float or decimal. In a similar manner, the number of significant digits
is preserved when floating point operands are converted to the decimal type. The number of significant digits is only sacrificed
when the final result is converted to match the type of the #answer variable and this variable is less precise than the highest of the operands being evaluated. In the example, precision is
not lost if the #answer is declared as a decimal type. SQR considers integer variables as the lowest in the precision hierarchy, followed by float
and then decimal.

The following sections list operators and functions supported in expressions.

Operators

Operators of the same precedence are processed in the sequence in which they appear in the expression, from left to right.
Use parentheses to override the normal precedence rules. All numeric types (decimal, float, integer) are supported for all
operators.

This table lists operators in descending order of precedence (operators listed in the same row within the table have the same
precedence):

Operator

Explanation

||

Concatenate two strings or dates

+, -

Sign prefix (positive or negative)

^

Exponent

*, /, %

Multiply, divide, remainder: a % b = mod(a,b) for integers

+, -

Plus, minus

Note. SQR distinguishes between a sign prefix and arithmetic operation by the context of the expression.

>, <, >=, <=, <>, !=, =

Comparison operators: greater than, less than, greater or equal to, less than or equal to, not equal (!= or <>), equal

not

Logical NOT

and

Logical AND

or, xor

Logical OR, XOR (exclusive OR)

Functions

This section lists numeric, file-related, and miscellaneous functions. The functions are listed in alphabetical order.

Function arguments are enclosed in parentheses and can be nested. Arguments referenced as x, y, or z indicate the first, second,
or third argument of a function. Otherwise, functions take a single argument or no arguments. All arguments are evaluated
before a function is evaluated.

Not all functions support all numeric types (decimal, float, integer). Certain functions do not support the decimal type directly,
but convert input decimal operands to the float type before the function is evaluated. The following table annotates the functions
that directly support the decimal type and the ones that do not.

Use parentheses to override the normal precedence rules.

This table describes numeric functions:

Function

Description

abs

Returns the absolute value of num_value. This function returns a value of the same type as num_value.

Returns the fractional remainder, f, of x_value/ y_value such that x_value = i * y_value + f, where i is an integer, f has the same sign as x_value, and the absolute value of f is less than the absolute value of y_value. The arguments are promoted to the type of the greatest precision and the function returns a value of that type.

The transcendental functions sin, cos, tan, sinh, cosh, and tanh take their arguments in radians. The functions asin, acos, and atan return radian values.
To convert from radians to degrees or degrees to radians, use the rad or deg functions as follows:

If arguments or intermediate results passed to a numeric function are invalid for that function, SQR halts with an error message.

For example, passing a negative number to the sqrt function causes an error. Use the cond function described in the Miscellaneous
Functions table to prevent division by zero or other invalid function or operator argument values.

The following table lists file-related functions. These functions return zero (0) when successful; otherwise, they return
the system error code.

Function

Description

delete

Deletes the file filename. The function returns either a zero (0) to indicate success or the value returned from the operating system to indicate an
error.

Syntax:

stat_var = delete(filename)

filename = text literal, column, variable, or expression.

stat_var = decimal, float, or integer variable.

Example:

let #fstatus = delete($filename)

exists

Determines if the file filename exists. The function returns either a zero (0) to indicate success or the value returned from the operating system to indicate
an error.

Syntax:

stat_var = exists(filename)

filename = text literal, column, variable, or expression.

stat_var = decimal, float, or integer variable.

Example:

let #fstatus = exists($filename)

rename

Renames old_filename to new_filename. The function returns either a zero (0) to indicate success or the value returned from the operating system to indicate an
error.

In these functions where a string argument is expected and a date variable, column, or expression is entered, SQR converts
the date to a string according to the following rules:

For DATETIME columns and SQR DATE variables, SQR uses the format specified by the SQR_DB_DATE_FORMAT setting.

If this has not been set, SQR uses the first database-dependent format as listed in the Default Database Formats table.

For DATE columns, SQR uses the format specified by the SQR_DB_DATE_ONLY_FORMAT setting.

If this has not been set, SQR uses the format listed in the DATE Column Formats table.

For TIME columns, SQR uses the format specified by the SQR_DB_TIME_ONLY_FORMAT setting.

If this has not been set, SQR uses the format as listed in the TIME Column Formats table.

Except where noted in an individual function, if a string variable, column, or expression is entered where a date argument
is expected, the string must be in the format specified by the SQR_DB_DATE_FORMAT setting, one of the database-dependent formats
listed in the Default Database Formats table, or the database-independent format 'SYYYYMMDD[HH24[MI[SS[NNNNNN]]]]'.

Function

Explanation

array

Returns a pointer to the starting address of the specified array field. The value returned from this function can only be
used by a user-defined function. See the routine printarray in the file UFUNC.C for complete instructions on how to use this
function.

Syntax:

array_var = array(array_name, field_name)

array_name = text literal, column, variable, or expression

field_name = text literal, column, variable, or expression

array_var = text variable

Example:

let #fstatus = printarray(array('products', 'name'), 10, 2, 'c')

ascii

Returns the numeric value for the first character in str_value. This function returns a float value.

Syntax:

ascii_var = ascii(str_value)

str_value = date or text literal, column, variable, or expression

ascii_var = decimal, float, or integer variable

Example:

let #fascii = ascii($filename)

asciic

Returns the numeric value for the first character (rather than byte) of the specified string.

Syntax:

ascii_var = asciic(str_value)

str_value = date or text literal, column, variable, or expression

ascii_var = decimal, float, or integer variable

Example:

let #fascii = asciic($filename)

chr

Returns a string that is composed of a character with the numeric value of num_value.

Returns y_value if the x_value is nonzero (0); otherwise returns z_value. If y_value is numeric, the z_value must also be numeric; otherwise, date and textual arguments are compatible. If either the y_value or z_value is a date variable, column, or expression, a date is returned. The return value of the function depends on which value is
returned.

format_mask = text literal, column, variable, or expression. The keyword DATE can be used to specify the DATE-EDIT-MASK setting from
the current locale. If this argument is not specified, the format specified by the SQR_DB_DATE_FORMAT setting is used. If
this has not been set, the first database-dependent format listed in the Default Database Formats table is used.

Trims characters in source_value from the left until a character is not in set_value and returns the result.

Syntax:

dst_var = ltrim(source_value, set_value)

source_value = date or text literal, column, variable, or expression

set_value = text literal, column, variable, or expression

dst_var = text variable

Example:

let $ltrim = ltrim(&description, '.')

nvl

Returns y_value if the x_value is null; otherwise, returns x_value. If x_value is numeric, y_value must also be numeric; otherwise, date and textual arguments are compatible. In any case, the x_value determines the type of expression returned. The return value of the function depends on which value is returned.

Syntax:

dst_var = nvl(x_value, y_value)

x_value = Any literal, column, variable, or expression

y_value = Any literal, column, variable, or expression

dst_var = Any variable

Example:

let $city = nvl(&city, '-- not city --')

If x_value is a date and y_value is textual, y_value is validated according to the following rules:

For DATETIME columns and SQR DATE variables, SQR uses the format specified by the SQR_DB_DATE_FORMAT setting, one of the database-dependent
formats (see the Default Database Formats table), or the database-independent format 'SYYYYMDD[HH24[MI[SS[NNNNNN]]]]'.

For DATE columns, SQR uses the format specified by the SQR_DB_DATE_ONLY_FORMAT setting, or the format listed in the DATE Column
Formats table.

For TIME columns, SQR uses the format specified by the SQR_DB_TIME_ONLY_FORMAT setting, or the format as listed in the TIME
Column Formats table.

range

Returns a value of one (1) if x_value is between y_value and z_value; otherwise, returns a value of zero (0). If the first argument is text or numeric, the other arguments must be of the same
type. If the first argument is a date, the remaining arguments can be dates and/or text. It is also possible to perform a
date comparison on a mix of date and text arguments, for example, where x_value is a date and y_value and z_value are text arguments. In a comparison of this sort, y_value must represent a date that is earlier than that of z_value.

If x_value is a date and y_value and/or z_value is textual, then y_value and/or z_value is validated according to the following rules:

For DATETIME columns and SQR DATE variables, SQR uses the format specified by the SQR_DB_DATE_FORMAT setting, one of the database-dependent
formats (see the Default Database Formats table), or the database-independent format 'SYYYYM­MDD[HH24[MI[SS[NNNNNN]]]]'.

For DATE columns, SQR uses the format specified by the SQR_DB_DATE_ONLY_FORMAT setting, or the format listed in the table
DATE Column Formats.

For TIME columns, SQR uses the format specified by the SQR_DB_TIME_ONLY_FORMAT setting, or the format as listed in table TIME
Column Formats.

replace

Inspects the contents of source_value and replaces all occurrences of from_string with to_string and returns the modified string.

Syntax:

dst_var = replace(source_value, from_string, to_string)

source_value = date or text literal, column, variable, or expression

from_string = text literal, column, variable, or expression

to_string = text literal, column, variable, or expression

dst_var = text variable

Example:
let $replaced = replace($paragraph, 'good', 'excellent')

roman

Returns a string that is the character representation of source_value expressed in lowercase roman numerals.

Syntax:

dst_var = roman(source_value)

source_value = text literal, column, variable, or expression.

dst_var = text variable

Example:

let $roman = roman(#page-count)

rpad

Pads the source_value on the right to a length of length_value using pad_value and returns the result.

Trims characters in source_value from the right until a character is not in set_value and returns the result.

Syntax:

dst_var = rtrim(source_value, set_value)

source_value = date, or text literal, column, variable, or expression

set_value = text literal, column, variable, or expression

dst_var = text variable

Example:

let $rtrim = rtrim(&description, '.')

strtodate

Converts the string source_value in the format format_mask to a date type.

Syntax:

dst_var = strtodate(source_value [, format_mask])

source_value = text literal, column, variable, or expression

format_mask = text literal, column, variable, or expression that describes the exact format of the source_value. The keyword DATE can be used to specify the DATE-EDIT-MASK setting from the current locale. If this argument is not specified,
then source_value must be in the format specified by the SQR_DB_DATE_FORMAT setting, one of the database-dependent formats (see the Default
Database Formats table), or the database-independent format 'SYYYYMDD[HH24[MI[SS[NNNNNN]]]]'. Valid format codes are specified
in the Date Edit Format Codes table.

Converts the specified string as follows: Any occurrence of a double-byte character that also has a single-byte representation
(numerals, punctuation, roman characters, and katakana) is converted.

Syntax:

dst_var = to_multi_byte (source_value)

source_value = date or text literal, column, variable, or expression

Example:

let $multi = to_multi_byte (&text)

to_number

Converts source_value to a number. This function returns a float value.

Syntax:

dst_var = to_number(source_value)

source_value = date or text literal, column, variable, or expression.

dst_var = decimal, float, or integer variable

Example:

let #value = to_number($number)

to_single_byte

Converts the specified string as follows: For SJIS, EBCDIK290, and EBCDIK1027, any occurrence of a single-byte character that
also has a multi-byte representation (numerals, punctuation, roman characters, and katakana) is converted. This function also
converts a sequence of kana characters followed by certain grammatical marks into a single-byte character that combines the
two elements. For all other encodings, the string is not modified.

Syntax:

dst_var = to_single_byte(source_value)

source_value = date or text literal, column, variable, or expression

Example:

let $single = to_single_byte (&text)

translate

Inspects the contents of source_value and converts characters that match those in from_set to the corresponding character in to_set and returns the translated string.

Syntax:

dst_var = translate(source_value, from_set, to_set)

source_value = date or text literal, column, variable, or expression

from_set = text literal, column, variable, or expression

to_set = text literal, column, variable, or expression

dst_var = text variable

Example:

let $translated = translate(edit(&price, '999,999.99'),',',',')

transform

Returns a Unicode string which is a specified transform of a given string.

Syntax:

dst_var = transform(source_value, transform_value)

source_value = date or text literal, column, variable or expression

transform_value = text literal, column, variable, or expression

dst_var = text variable

Example:

let $hiragana = transform($string, 'ToHiragana')

unicode

Returns a Unicode string from the string of hexadecimal values provided.

Syntax:

dst_var = unicode(source_value)

source_value = text literal, column, variable or expression

dst_var = text variable

Example:

let $uniStr = unicode('u+5e73 u+2294')

upper

Converts the contents of source_value to uppercase and returns the result.

Syntax:

dst_var = upper(source_value)

source_value = date or text literal, column, variable, or expression

dst_var = text variable

Example:

let $upper = upper(&description)

wrapdepth

Returns the number of print lines required by source_value. See the PRINTWRAP command for detailed descriptions of the parameters to this function. This function returns a float value.

In addition to using the preceding built-in functions, you can write your own functions in C, using the supplied source file UFUNC.C.

You can pass any number of arguments to your function and values can be returned by the function or passed back in variables.

After editing and recompiling UFUNC.C, you must relink SQR.

The following is a step-by-step example of how to add a user-defined function to SQR so that it can be invoked using the LET,
IF, or WHILE command.

The example adds the C function random, which returns a random number. The function accepts a parameter that is used as the
seed to start a new sequence of numbers. If the seed is zero, then the same sequence is used.

When adding functions to UFUNC, keep in mind the following considerations:

String functions require the following arguments:

(int) Number of arguments.

(char *) or (double *) Array of argument pointers, to either char[ ] or double.

(char *) Address for result string. If unchanged, function returns a NULL string.

(int) Maximum length of result string, in bytes.

Numeric functions require the following arguments:

(int) Number of arguments.

(char *) or (double *) Array of argument pointers, to either char[ ] or double.

Add the function name to the declaration list. The name of the function called from SQR is random. The return type is n for numeric. The number of arguments passed is 1, and the argument type is n for numeric. The function name in UFUNC.C is random. The characters PVR must be entered before the function name.

Name

Return_type

Number of Arguments

Arg_Types

Function

"max",

'n',

0,

"n",

PVR max,

"max",

'n',

0,

"n",

PVR max,

"split",

'n',

0,

"C",

PVR split,

"printarray",

'n',

4,

"cnnc",

PVR printarray,

"random",

'n',

1,

"n",

PVR random,

/* Last entry must be NULL -- do not change */
"", '\0', 0, "", 0
};

At the end the of UFUNC.C file, add the following random routine. The routine name must be lowercase; however, in your SQR
program it can be referenced in either uppercase or lowercase.

Loads an internal table with columns from the database. Enables a quick search using the LOOKUP command.

Use the LOAD-LOOKUP command in conjunction with one or more LOOKUP commands.

LOAD-LOOKUP retrieves two columns from the database, the KEY field and the RETURN_VALUE field. Rows are ordered by KEY and
stored in an array.

LOAD-LOOKUP commands specified in the SETUP section are always loaded and cannot reference variables for the ROWS, EXTENT,
and WHERE arguments.

When you use the LOOKUP command, SQR searches the array (with a binary search) to find the RETURN_VALUE corresponding to the
KEY referenced in the lookup.

Usually this type of lookup can be done with a database join, but joins take substantially longer. However, if your report is small and the number of rows to be joined is small, a lookup
table can be slower because the entire table has to be loaded and sorted for each report run.

By default, SQR lets the database sort the data. This works fine if the database and SQR both use the same character set and
collating sequence. The SORT argument enables you to specify the sorting method if this is not true. Additionally, if the
machine that SQR is running on is faster than the machine the database is running on, letting SQR perform the sort could decrease
the execution time of the report.

The only limit to the size of a lookup table is the amount of memory your computer has available. You could conceivably load
an array with many thousands of rows. The binary search is performed quickly regardless of how many rows are loaded.

Except for the amount of available memory, there is no limit to the number of lookup tables that can be defined.

Parameters

NAME

The name of the lookup table. The array name is referenced in the LOOKUP command.

TABLE

The name of the table in the database, where the KEY and RETURN_VALUE columns or expressions are stored.

KEY

The name of the column that is used as the key in the array that is used for looking up the information. Keys can be character,
date, or numeric data types. If numeric, SQR permits only integers with 12 digits or fewer for the KEY column. Keys can be
any database-supported expression. See the RETURN_VALUE argument.

RETURN_VALUE

The name of the column (expression) that is returned for each corresponding key.

The following example is for ORACLE. See your database manual for the correct syntax.

RETURN_VALUE='name||''-''||country||''-''||population'

ROWS

The initial size of the lookup table. This argument is optional, and if not specified, a value of 100 is used.

EXTENT

The amount to increase the array when it becomes full. This argument is optional, and if not specified, a value of 25% of
the ROWS value is used.

WHERE

A WHERE clause used to select a subset of all the rows in the table. If specified, the selection begins after the word WHERE.
The WHERE clause is limited to 255 characters.

SORT

The sorting method to be used. The following values are permitted:

DC: Database sorts data, case-sensitive sort

DI: Database sorts data, case-insensitive sort

SC: SQR sorts data, case-sensitive sort

SI: SQR sorts data, case-insensitive sort

The default is SC or the method specified by the -LL command-line flag. The DI method is applicable only to databases that
provide this feature and have been installed in that manner.

QUIET

Suppresses the message Loading lookup array... when the command executes. The warning message stating the number of duplicate keys found is also suppressed.

Example

The following command loads the array, states, with the columns abbr and name from the database table stateabbrs, where country
is USA.

MBTOSBS

Syntax

MBTOSBS {txt_var}

Description

Converts a double-byte string to its single-byte equivalent.

This command converts the specified string as follows: any occurrence of a double-byte character that also has a single-byte
representation (numerals, punctuation, roman characters, and katakana) is converted.

Parameters

txt_var

Specifies the string to be converted.

See Also

The TO_SINGLE_BYTE function of the LET command.

MOVE

Moves the source field to the destination field. Optionally, you can reformat the field using the format_mask argument. Source and destination fields can be different types,
numeric, text, or date. MOVE is also useful for converting from one type to another; however, date and numeric variables are
incompatible.

When a date variable or column is moved to a string variable, the date is converted according to the following rules:

For DATETIME columns and SQR DATE variables, SQR uses the format specified by the SQR_DB_DATE_FORMAT setting.

If this has not been set, SQR uses the first database-dependent format as listed the Default Database Formats table.

For DATE columns, SQR uses the format specified by the SQR_DB_DATE_ONLY_FORMAT setting.

If this has not been set, SQR uses the format listed in the DATE Column Formats table.

For TIME columns, SQR uses the format specified by the SQR_DB_TIME_ONLY_FORMAT setting.

If this has not been set, SQR uses the format as listed in the TIME Column Formats table.

Finally, as this example shows, the edit mask can be contained in a string variable.

Parameters

src_any_lit | _var | _col

Specifies any source column, variable, or literal. Note that a date can be stored in a date variable or column, or a string
literal, column, or variable. When using a date format_mask or the keyword DATE with the MOVE command, the source, if a string
literal, column, or variable, must be in the format specified by the SQR_DB_DATE_FORMAT setting, one of the database-dependent
formats as listed in the Default Database Formats table, or the database-independent format 'SYYYYMMDD[HH24[MI[SS[NNNNNN]]]]'.

$Counter = 000123
!
! Convert a number to a string using the default edit mask
!
! SQR, by default, outputs six digits of precision.
! If you require more or less precision, specify an edit mask.
!
move 123.78 to #defvar
move #defvar to $defvar
show '$DefVar = ' $defvar

The LET command for information about copying, editing, or converting fields.

The EDIT parameter of the PRINT command for a description of the edit masks.

The ALTER-LOCALE command for a description of the arguments NUMBER-EDIT-MASK, MONEY-EDIT-MASK, and DATE-EDIT-MASK.

The PRINT command regarding the default date-time components as a result of moving an incomplete date to a date variable.

MULTIPLY

Syntax

MULTIPLY {src_num_lit|_var|_col} TIMES dst_num_var
[ROUND=nn]

Description

Multiplies the first field by the second and places the result into the second field.

When dealing with money-related values (dollars and cents), use decimal variables rather than float variables. Float variables
are stored as double precision floating point numbers, and small inaccuracies can appear when multiplying many numbers in
succession. These inaccuracies can appear due to the way different hardware and software implementations represent floating
point numbers.

Parameters

src_num_lit | _var | _col

Specifies a numeric source column, variable, or literal.

dst_num_var

Specifies a destination numeric variable.

ROUND

Rounds the result to the specified number of digits to the right of the decimal point. For float variables, this value can be from
0 to 15. For decimal variables, this value can be from 0 to the precision of the variable. For integer variables, this argument
is not appropriate.

Example

The following example illustrates the MULTIPLY command

multiply &quantity times #cost
multiply 1.5 times #result

See Also

The ADD command for more information.

The LET command for a discussion of complex arithmetic expressions.

NEW-PAGE

Syntax

NEW-PAGE [erase_from_line_num_lit|_var|_col]

Description

Writes the current page and begins a new one.

For line printers, this command can optionally erase the old page starting at a specified line. After this action is performed,
the location on the page is unchanged—that is, the value of #current-line is the same. The default action is to erase the entire page and reset #current-line to its initial value for the page.

In reports where an overflow page is needed, sometimes it is useful to retain information from the first page on succeeding
pages.

Each NEW-PAGE occurrence adds a form feed character to the output file unless you specify FORMFEED=NO in the DECLARE-LAYOUT for this program in the SETUP section.

NEW-REPORT

Closes the current report output file and opens a new one with the specified file name.

This command is normally used with single reports only. When used with multiple report declarations, this command affects the current report only.

The internal page counter is reset to 1 when NEW-REPORT is executed.

Note. SQR does not create a report output file until the first page is completed. It is possible that NEW-REPORT will not create
a new file, for example, if no data is selected and nothing is printed on the page.

Parameters

{report_filename_txt_lit | _var | _col}

Specifies a new file name.

Example

The following example shows the NEW-REPORT command:

new-report 'rep2a.lis'
new-report $next-file

Assign the report file name within an SQR report by issuing the NEW-REPORT command before printing. You might even prompt
for the file name to use, as shown in the following example:

NEXT-LISTING

NEXT-LISTING is used in tabular reports. This command causes a new vertical offset in the page to begin.

After NEXT-LISTING is executed, line 1 is reset one line below the deepest line previously printed in the page body. That
is, if you then write PRINT (1, 5), the string is printed on the next available line starting in column 5. Note that the SQR
reserved variable #current-line still reflects the actual line number within the page body.

The value of SKIPLINES must be a nonnegative integer. If it is less than 0, then 0 is assumed.

The value of NEED must be an integer greater than 0. If it is less than or equal to 0, then 1 is assumed.

Parameters

NO-ADVANCE

Suppresses any line movement when no printing has occurred since the previous NEXT-LISTING or NEW-PAGE. The default increments
the line position even when nothing was printed.

SKIPLINES

Causes the specified number of lines to be skipped before setting up the new offset.

NEED

Specifies the minimum number of lines needed to begin a new listing or set of detail lines. If this number of lines does not
exist, a new page is started. You can use NEED to prevent a group of detail lines from being broken across two pages.

OPEN

Opens an operating system file for reading or writing. After a file is opened, it remains open until explicitly closed by the CLOSE command. A maximum of 256 files can be opened at one time.

Parameters

{filename_lit | _var | _col}

Specifies the file name. The file name can be literal, variable, or column. This makes it easy to prompt for a file name at
runtime.

{filenum_num_lit | _var | _col}

Specifies a number that identifies the file in the application. All file commands use the file number to reference the file. File numbers can be numeric variables and literals. The number can be any positive integer less than
64,000.

FOR-READING

When a file is opened for reading, SQR procures all data sequentially. SQR does not allow for random access of information.

FOR-WRITING

When a file is opened for writing, a new file is created. If a file of the same name already exists, it can be overwritten
(this depends on the operating system).

FOR-APPEND

When a file is opened in append mode, the current file contents are preserved. All data written is placed at the end of the
file. SQR creates the file if one does not already exist. For existing files, make sure the attributes used are the same as
those used when the file was created. Failure to do this can produce unpredictable results.

RECORD

For the VARY file type, this is the maximum size for a record. For the FIXED file type, this is the size of each record without the line terminator. For the FIXED_NOLF file type, this is the size of each record.

FIXED

This file type assumes that all records contained within the file are the same length. Terminate each record by a line terminator
(system dependent). You can use this file type when writing or reading binary data.

FIXED_NOLF

This file type specifies that all records contained within the file are the same length with no line terminators. When writing
records, SQR pads short records with blank characters to ensure each record is the same length. This file type can be used
when writing or reading binary data.

VARY

This file type specifies that the records can be of varying length. Each record is terminated by a line terminator (system-dependent).
Only records containing display characters (no binary data) can be used safely. When reading records, any data beyond the
maximum length specified is ignored. This is the default file type.

STATUS

Sets the numeric variable to zero if the OPEN succeeds and to -1 if it fails. Without the STATUS argument, a failure on OPEN
causes SQR to halt. By using a STATUS variable, you can control what processing should occur when a file cannot be opened.

Example

This section contains two examples: a regular open command and an expanded command:

An encoding directive added to the OPEN command allows differently encoded files to be managed in a single run of SQR. When
no ENCODING is specified on the OPEN command, SQR uses the file input or output encoding specified in the INI file unless
the file is UCS-2 encoded and auto-detection of UCS-2 files is enabled. The complete syntax of the OPEN command is:

POSITION

Syntax

POSITION position
[@document_marker[COLUMNS{num_lit|_var|_col}
[num_lit|_var|_col]...]]

Description

Sets the current position on a page.

Parameters

position

A position qualifier consisting of (line, column, width), where column and width are numbers that denote characters and spaces. Line, column, and width are all optional. If line or column are omitted, the print position is set by default to the current position, which is the
position following the last printed item. Width is set by default to the width of the text that is being printed. A plus sign
or minus sign indicates relative positioning in SQR. A plus sign moves the print position forward from the current position,
and a minus sign moves it back.

@document_markerg

References a location defined in a document paragraph. In this case, the position used is the location of that marker in the text of the document.

COLUMNS

Defines columns beginning at the location of the document marker. The columns defined are relative to the position of the
document marker.

When COLUMNS is used, the entire command cannot be broken across more than one program line.

Example

The following example shows the POSITION command:

position (12,5) ! Set current position to line 12, column 5.
position (+2,25) ! Set position 2 lines down, at 25th column.
position () @total_location ! Set position to document
print #total () edit 999,999,999 ! marker @total_location.
position () @name_loc columns 1 30
print name () ! Columns are defined at @name_loc and
next-column ! 29 characters to the right of @name_loc
print title ()

Dates can be contained in a date column or variable or, in a string literal, column, or variable. When using EDIT or DATE
with the PRINT command, a date in a string literal, column, or variable must be in an acceptable format. See the description
of EDIT for further details.

position

A position qualifier consisting of (line, column, width), where column and width are numbers that denote characters and spaces. Line, column, and width are all optional. If line or column are omitted, the print position is set by default to the current position, which is the
position following the last printed item. Width is set by default to the width of the text that is being printed. Position
can be relative. See the POSITION command for a full description and examples of relative positioning.

format_command [format_cmd_params]

Specifies optional formatting commands and parameters.

Format Commands

The PRINT command has the following format commands:

BACKGROUND

BOLD

BOX

CENTER

CODE-PRINTER

DATE

EDIT

FILL

FOREGROUND

MONEY

NOP

NUMBER

ON-BREAK

SHADE

UNDERLINE

WRAP

Some of these format commands can be used in combination with others and some are mutually exclusive. The following tables
shows which can be used together. An X indicates that they can be used together.

BACKGROUND/ FOREGROUND

BOLD

BOX

CENTER

CODE-PRINTER

DATE/ EDIT/ MONEY/ NUMBER

BACKGROUND/ FOREGROUND

X

X

X

BOLD

X

X

X

X

BOX

X

X

X

X

CENTER

X

X

X

X

CODE-PRINTER

DATE/ EDIT/ MONEY/ NUMBER

X

X

X

X

FILL

X

X

X

X

MATCH

X

X

X

X

NOP

X

X

X

X

X

X

ON-BREAK

X

X

X

X

X

SHADE

X

X

X

X

X

UNDERLINE

X

X

X

X

WRAP

X

X

X

FILL

MATCH

NOP

ON-BREAK

SHADE

UNDERLINE

WRAP

BACKGROUND/ FOREGROUND

X

X

X

X

X

X

BOLD

X

X

X

X

X

X

X

BOX

X

X

X

X

X

X

CENTER

X

X

X

X

X

X

CODE- PRINTER

X

DATE/ EDIT/ MONEY/ NUMBER

X

X

X

X

FILL

X

X

X

X

X

MATCH

X

X

X

X

NOP

X

X

X

X

X

X

ON- BREAK

X

X

X

X

X

X

SHADE

X

X

X

X

X

X

UNDERLINE

X

X

X

X

X

X

WRAP

X

X

X

X

X

The following sections describe the PRINT format commands.

BOLD

BOLD causes the string or number to print in bold type.

For HP LaserJet printers, the appropriate boldface font must be loaded in the printer.

For PostScript printers, the appropriate boldface must be defined in the PostScript startup file, postscri.str.

See the DECLARE-PRINTER Command Arguments table for information about which font can be boldfaced.

For line printers, when the BEFORE-BOLD and AFTER-BOLD arguments on the DECLARE-PRINTER command are used, the specified strings are added before and after the data to be boldfaced. If BEFORE-BOLD and AFTER-BOLD are not
specified, BOLD has no effect.

BOX draws a one-line deep graphical box around the printed data. This option has no effect for line printers.

For example:

print &grand_total (+5, 20) box
print 'Happy Birthday !!' (1,1) box

Note. For HP LaserJet printers using proportional fonts, BOX and SHADE are not able to determine the correct length of the box because it varies with the width of the characters printed. BOX and
SHADE work well with fixed-pitch fonts and with all PostScript fonts.

CENTER

CENTER centers the field on a line. The position qualifier for column is ignored. For example:

Adds nondisplay characters to the program for the purpose of sending a sequence to the printer. CODE-PRINTER causes the string
to be placed behind the page buffer, rather than within it, so alignment of printed data is not affected by the white space consumed by the nondisplay
characters. Only strings can be printed using CODE-PRINTER.

Because the report might be printed on different types of printers, you should specify for which type this data is to be used.
The report is ignored if printed to a different type. If necessary, you can send a different sequence to another type with
a second PRINT statement.

In the previous example, the two CODE-PRINTER arguments put the $big_font and $normal_font sequences into the output, without overwriting any data in the page buffer. Sequences printed with the CODE- PRINTER argument
are positioned using the regular line and column positioning. However, unlike the PRINT command, the current print location
after execution is the beginning location where the CODE-PRINTER string was placed. Multiple coded strings printed using the
same line and column location appear in the output in the same sequence in which they were printed.

DATE

You cannot use DATE with numeric columns or variables. DATE indicates that the field is to be formatted using the DATE-EDIT-MASK
from the current locale. (See the ALTER_LOCALE command.) If this entry is not set, then the date is printed according to the
following rules shown in the Date table.

Column Type

Default Mask

If not set

DATETIME

SQR_DB_DATE_FORMAT

See the Default Database Formats table for the format that is used.

DATE

SQR_DB_DATE_ONLY_FORMAT

See the DATE Column Formats table for the format that is used.

TIME

SQR_DB_TIME_ONLY_FORMAT

See the TIME Column Formats table for the format that is used.

EDIT

EDIT has the following syntax:

EDIT edit_format

EDIT causes each field to be edited before it is printed. The three types of edits are:

Text edit

Numeric edit

Date edit

The following table lists the text edit format characters.

Character

Description

X

Use character in field.

B

Insert blank.

~ (tilde)

Skip character in field.

R[n]

Reverse sequence of string, for languages such as Hebrew. The optional number indicates right justification within length indicated.

Any other character, such as punctuation, in a text edit mask is treated as a constant and is included in the edited field.

The characters 8, 9, 0, V, and $ are illegal in a text edit mask because they are used to indicate that the mask is for a
numeric edit.

The following table lists the numeric edit format characters.

Character

Description

8

Digit, zero fill to the right of the decimal point, trim leading blanks (left justify the number).

9

Digit, zero fill to the right of the decimal point, space fill to the left.

0

Digit, zero fill to the left.

$

Dollar sign, optionally floats to the right.

B

Treated as a 9, but if a value is zero, the field is converted to blanks.

C

Entered at the end of the mask, causes the comma and period characters to be transposed when the edit occurs. This is to support
monetary values where periods delimit thousands and commas delimit decimals. (Example: 1.234,56).

E

Scientific format. The number of 9s after the decimal point determines the number of significant digits displayed. The E can
be uppercase or lowercase; the display follows the case of the mask.

V

Implied decimal point.

MI

Entered at the end of the mask, causes a minus to display at the right of the number.

PR

Entered at the end of the mask, causes angle brackets (< >) to be displayed around the number if the number is negative.

PS

Entered at the end of the mask, causes parentheses to be displayed around the number if the number is negative.

PF

Entered at the end of the mask, causes floating parentheses to be displayed around the number if the number is negative.

NA

Entered at the end of the mask, causes N/A to be displayed if the numeric column variable is null. The case of N/A follows
that of the mask.

NU

Entered at the end of the mask, causes blanks to be displayed if the numeric column variable is null.

.

Decimal point.

,

Comma.

Characters other than those listed in the Numeric Edit Format Characters table are illegal for numeric edit masks and cause
errors during processing.

Last 3, 2, or 1 digits of the year. On input, for calculating the 4-digit year, the current century and/or decade is used.
For example, a 9 using the Y mask would result in the year 1999 if the current year is in the 1990s.

YYYY SYYYY

4–digit year, S prefixes BC dates with "-".

RR

Last 2 digits of year; for years in other centuries. See the Date Edit Format Code-RR table.

CC or SCC

Century; S prefixes BC dates with "-".

BC AD

BC/AD indicator.

Q

Quarter of year (1,2,3,4; JAN-MAR=1).

RM

Roman numeral month (I-XII; JAN=I).

WW

Week of year (1–53) where week 1 starts on the first day of the year and continues to the seventh day of the year.

W

Week of the month (1–5) where week 1 starts on the first day of the month and ends on the seventh.

DDD

Day of year (1–366).

DD

Day of month (1–31).

D

Day of week (1–7). Sunday is first day of week.

DAY

Name of day.

DY

Abbreviated name of day.

ER

Japanese Imperial Era. Returns the name of the of the Japanese Imperial Era in the appropriate kanji (Heisei is the current
era).

EY

Year of the Japanese Imperial Era. Returns the current year within the Japanese Imperial Era.

Note. The common Japanese date format is: 'YYYY<nen>MM<gatsu>DD<nichi>' where <nen>, <gatsu>, and <nichi> are the kanji strings
for year, month, and day respectively.

J

Julian day; the number of days since Jan 1, 4713 BC. Numbers specified with 'J' must be integers.

AM PM

Meridian indicator.

HH

Assumes 24-hour clock unless meridian indicator specified.

HH12

Hour of day (1–12).

HH24

Hour of day (0–23).

SSSSS

Seconds past midnight (0–86399).

N NN NNN NNNN NNNNN NNNNNN

Fractions of a second. Precise to microseconds; however, for most hardware and databases, this much accuracy is not attainable.

MONTH

Name of month.

MON

Abbreviated name of month.

MM

Month (01–12; JAN=01).

MI

Minute (0–59).

SS

Second (0–59).

|

Used to concatenate different masks.

Note. If the last two digits of the year are between 00 and 49, the return date is in the current century. If the last two digits
of the year are between 50 and 99, the return date is in the century after the current one.

Last 2 Digits of Current Year

2-Digit Year is 00–49

2-Digit Year is 50–99

00–49

The return date is in the current century.

The return date is in the century before the current one.

50–99

The return date is in the century after the current one.

The return date is in the current century.

All masks can be used by the strtodate function except for CC, SCC, Q, W, and WW.

A backslash forces the next character into the output from the mask. For example, a mask of The cu\rre\nt \mo\nth is Month results in the output string of The current month is January. Without the backslashes the output string would be The cu04e7t january is January.

A vertical bar can be used as a delimiter between format codes; however, in most cases the bar is not necessary. For example,
the mask 'YYYY|MM|DD' is the same as 'YYYYMMDD'.

Any other character, such as punctuation, in a date edit mask is treated as a constant and is included in the edited field.
If the edit mask contains spaces, it must be enclosed in single quotes (').

The masks MON, MONTH, DAY, DY, AM, PM, BC, AD, and RM are case-sensitive and follow the case of the mask entered. For example, if the month is January, the mask Mon yields "Jan" and MON yields "JAN".

All other masks are case-insensitive and can be entered in either uppercase or lowercase. In addition, National Language Support
is provided for the following masks: MON, MONTH, DAY, DY, AM, PM, BC, and AD.

See the ALTER-LOCALE command in the SQR Samples section for additional information.

If the value of the date field being edited is "Mar 14 2004 9:35", the edit masks produce the results in the following table.

Edit Mask

Result

dd/mm/yy

14/03/04

DD-MON- YYYY

14-MAR-2004

'Month dd, YYYY'

March 14, 2004

MONTH-YYYY

MARCH-2004

HH:MI

09:35

'HH:MI PM'

09:35 AM

YYYYMMDD

20040314

MM.DD.YYYY

03.14.2004

Mon

Mar

DD|D|DDD

143073

In addition to being used with the EDIT argument, edit masks can be used with the MOVE, CONCAT, DISPLAY, and SHOW commands, and with the edit function of the LET command. You edit the field using the supplied mask before storing or displaying it.

When a date with missing date and/or time components is displayed or printed, the defaults are as follows:

The default year is the current year.

The default month is the current month.

The default day is one.

The default time is zero (00:00:00.000000).

For example, assuming today is September 7, 2004, the following assignment would produce an equivalent date-time of September
1, 2004 13:21:00.000000:

let $date1 = strtodate('13:21','HH:MI')

Edit masks can be changed dynamically by storing them in a string variable and referencing the variable name preceded by a colon (:). For example:

When a date that is stored in a string literal, column, or variable is printed with an edit mask, it must be in one of the
following formats:

The format specified by the environment variable SQR_DB_DATE_FORMAT, or the corresponding setting in the sqr.ini file.

One of the database-dependent formats, as listed in the Default Database Formats table.

The database-independent format, 'SYYYYMMDD[HH24[MI[SS[NNNNNN]]]]'.

When a date column or variable is printed without an edit mask, the date is printed in the format specified by the environment
variable SQR_DB_DATE_FORMAT or the corresponding setting in the sqr.ini file. If this has not been set, then the date is printed
in the primary database format (the first entry) listed in the Default Database Formats table.

When you specify a color on the PRINT command its scope is that of the PRINT command. If you do not define the specified color
name, then the setting for default is used. Use the color name none to turn off color for the specified area.

MATCH compares a field to a list of key values and if a match is found, prints the corresponding string at the specified line
and column. If the match_text contains white space, it must be enclosed in single quotes ('). Any number of match text(s)
can be tested, but each must have its own line, column, and print_text. If a match is not found, the unmatched field is printed
at the position specified in the parentheses. Line and column positions for each matched string are treated as fixed or relative
positions depending on the type of positioning used in the position qualifier for the PRINT command. For example:

The column positions are treated as fixed locations due to the fixed 25 position declared in parentheses.

MONEY

MONEY indicates that the column or variable is to be formatted using the MONEY-EDIT-MASK from the current locale. (See the
ALTER_LOCALE command.) This can only be used with a numeric column or variable.

NOP

NOP suppresses the print command, causing no operation to be executed. This argument is useful for temporarily preventing a field from printing. For example:

print &ssn (1,1) nop
Hide the social security number.

NUMBER

NUMBER indicates that the column or variable is to be formatted using the NUMBER-EDIT-MASK from the current locale. (See the
ALTER-LOCALE command.) This argument can only be used with a numeric column or variable.

ON-BREAK causes the specified action in a tabular report when the value of a field changes (a break occurs). The default action
prints the field only when its value changes (PRINT=CHANGE). ON-BREAK has the following qualifiers:

PRINT specifies when the break field is printed.

ALWAYS duplicates the break field for each detail group.

CHANGE prints the value only when it changes.

This is the default.

CHANGE/TOP-PAGE prints the value both when it changes and at the top of each new page.

NEVER suppresses printing.

SKIPLINES specifies how many lines to skip when the value changes.

PROCEDURE specifies the procedure to be invoked when the value changes.

This qualifier cannot be used with either the AFTER or BEFORE qualifier.

AFTER and BEFORE procedures specify procedures to invoke either after or before the value changes.

If no rows are fetched, neither procedure is executed. AFTER and BEFORE can be used only within a SELECT paragraph.

The sequence of events is shown here:

SAVE indicates a string variable where the previous value of a break field is stored.

LEVEL specifies the level of the break for reports containing multiple breaks.

For example, a report sorted by state, county, and city might have three break levels: state is level 1 (the most major),
and city is level 3 (the most minor). When a break occurs, other breaks with equal or higher level numbers are cleared. The
level number also affects the sequence in which AFTER and BEFORE procedures are processed.

SET assigns a number to the set of leveled breaks in reports with more than one set of independent breaks.

Following is the sequence of events for a query containing ON-BREAK fields:

Any BEFORE procedures are processed in ascending LEVEL sequence before the first row of the query is retrieved.

When a break occurs in the query, the following happens:

AFTER procedures are processed in descending sequence from the highest level to the level of the current break field.

SAVE variables are set with the new value.

BEFORE procedures are processed in ascending sequence from the current level to the highest level break.

Any breaks with the same or higher level numbers are cleared so they do not break on the next value.

If a PROCEDURE has been declared, the procedure is invoked.

If SKIPLINES was specified, the current line position is advanced.

The value is printed (unless PRINT=NEVER was specified).

After the query finishes (at END-SELECT) any AFTER procedures are processed in descending level sequence, for example:

Upon entering the query at BEGIN-SELECT, the three BEFORE procedures are executed in sequence:

Bef-state

Bef-cnty

Bef-city

After the last row is retrieved, at END-SELECT, the three AFTER procedures are executed in sequence:

City-tot

Cnty-tot

State-tot

The SAVE qualifier saves the previous break value in the specified string variable for use in an AFTER procedure. You may
want to print the previous break field with a summary line:

print &state (+1,1) on-break after=state-tot save=$old-state

The SET qualifier enables you to have sub-reports with leveled breaks. By separating the ON-BREAKs into sets, the associated
leveled breaks in each set do not interfere with each other.

begin-select
state (+1,1,2) on-break set=1 after=state-tot level=1

SET=1 associates this leveled break with other breaks having the same set number.

SHADE

Draws a one-line deep, shaded graphical box around the printed data. For line printers this argument has no effect.

print 'Company Confidential' (1,1) shade
print &state (+2, 40) shade

Note. For HP LaserJet printers using proportional fonts, BOX and SHADE are not able to determine the correct length of the box because
it varies with the width of the characters printed. BOX and SHADE work well with fixed pitch fonts and with all PostScript
fonts.

UNDERLINE

UNDERLINE prints the specified data with underlined characters. For line printers, UNDERLINE causes backspace and underscore
characters to be output, which emulates underlining, for example:

Note. After a string wraps, the current position is one character to the right of the last character in the column. When a string
ends on the last position of a line, an implicit line feed causes the new current position to be the first character of the
following line. In the SETUP section, use the DECLARE-LAYOUT command to make the page width one character wider than the right
edge of the wrapped text to avoid generating an implicit line feed.

In this example, the line position is 1 for each of the three wrapped fields:

In this example, the line position is 1 for each of the three wrapped fields: note1, note2, and note3. The current print position
after a wrap occurs at the bottom right edge of the wrapped paragraph. To continue printing on the same line, you must use
a fixed line number for the next field.

max_lines_lit|_var|_col

Specifies the maximum paragraph depth in lines. Usually, the line length and maximum lines are indicated with numeric literals.
However, WRAP can also reference numeric variables or columns. This is useful when you want to change the width or depth of
a wrapped paragraph during report processing. The numeric variable can optionally be preceded by a colon (:), for example:

KEEP-TOP retains the current line position except if a page break occurs, in which case, line 1 is used as the current line
position. The default action is to set the next print position at the bottom of the wrapped data.

In the following example, the column &resolution prints on the same line as the first line of the column &instructions:

The STRIP and ON arguments affect which characters are to be converted before wrapping, and which characters force a wrap
to occur.

Characters in the STRIP string argument are converted to spaces before the wrap occurs.

Characters in the ON string argument cause a wrap at each ON character found. The ON character is not printed.

Both arguments accept regular characters and nondisplay characters whose decimal values are surrounded by angled brackets,
<nn>, where nn is a decimal number between 1 and 255, representing the character in the current character set of the operating system. For
example, to print a long data type that contains embedded carriage returns, the setup would be:

print &long_field (5,20) wrap 42 30 on=<13>

The paragraph wraps at each carriage return, rather than at the usual word boundaries. If the ON character is not found within
the width specified for the paragraph, the wrap occurs at a word space. The following example converts the STRIP characters
to spaces before wrapping on either a line feed <10> or a space (the default):

print &description (20,10) wrap 50 22 strip=/\^@<13> on=<10>

WRAP can also be used to print reversed characters, for support of languages such as Hebrew. An R after the length and max_lines
arguments causes the field to be reversed before the wrap takes place. In addition, the entire paragraph is right-justified
within the length indicated.

LINE-HEIGHT specifies the number of lines to skip between each line of the wrapped data. By default a value of 1 (single space)
is assumed. The following example prints the comment column with one blank line between each printed line for a maximum of
four printed lines:

print &comment (1,1) wrap 40 4 line-height = 2 ! Double space text

See Also

The LET command for information about copying, editing, or converting fields.

The ALTER-LOCALE command for a description of the arguments NUMBER-EDIT-MASK, MONEY-EDIT-MASK, and DATE-EDIT-MASK.

Specifies the position of the upper left corner. Position parameters can be relative. See the POSITION command for examples
of relative positioning. Document markers are not allowed. After execution, the current position is returned to this location;
however, the next listing line is the next line below the bottom of the bar code. (This is different than the way the PRINT
command works.)

TYPE

Specifies the type of bar code to be printed. Types are shown in the Bar Code Types table.

HEIGHT

Specifies the height of the bar code in inches. The height must be between 0.1 and 2 inches. The code prints to the nearest
one-tenth of an inch. For Zip+4 Postnet, the height of the bar code is fixed. The height should be between 0.2 and 2.0 for
Zip+4 Postnet. If it is less than 0.2, the bar code extends above the position specified.

TEXT

Specifies the text to be encoded and printed. The number and type of text characters permitted or required depends on the
bar code type. See the Bar Code Types table for specifications.

CAPTION

Specifies optional text to be printed under the bar code in the current font. SQR attempts to center the caption under the
bar code; however, for proportional fonts this may vary slightly.

CAPTION is not valid for Zip+4 Postnet. If specified, it is ignored.

CHECKSUM

Specifies an optional check sum to be computed and printed within the bar code. Valid values are YES and NO, where NO is the
default.

Note. Some barcode types ignore the CHECKSUM qualifier. See the Bar Code Types table for those barcode types for which CHECKSUM
is relevant.

Example

This example shows how to use the PRINT-BAR-CODE command to create a UPC-A bar code:

Note. If you do not define CHART-SIZE with this command, you must define it with DECLARE-CHART.

Description

Prints a chart. Only PostScript printers or HP printers that support HPGL (generally, this is HPLaserJet 3 and higher) render chart output.

The PRINT-CHART command directs SQR to output a chart according to the named chart, if any, and the overridden attributes,
if any.

Note. PRINT-CHART can be used without referencing a named chart if all required attributes for the DECLARE-CHART are supplied in
addition to all its required parameters. The PRINT-CHART command directs SQR to display the chart on the current page using
the attribute values at the moment the command is executed. Manipulation of chart attribute values has no effect on the appearance
of the chart after the PRINT-CHART command has been executed. For example, if you execute a PRINT-CHART with TITLE=$ttl and
$ttl='Encouraging Results', and then change the value of $ttl to 'Discouraging Results' immediately afterward, then the chart
is printed with first value, 'Encouraging Results'. PRINT-CHART expects the DATA-ARRAY to be organized in a particular way.
See the Chart Array Field Types (fewer than four fields) table for details. PRINT-CHART fills the area defined by CHART-SIZE
as much as possible while maintaining an aesthetically pleasing ratio of height to width. In cases where the display area
is not well suited to the chart display, the chart is centered within the specified region, and the dimensions are scaled
to accommodate the region. Do not be alarmed if the chart does not fit exactly inside the box you have specified. It means
that SQR has accommodated the shape of the region to provide the best looking chart possible. Chart commands used to send
output to a line printer are ignored. Only PostScript printers or HP printers that support Hewlett Packard's HPGL (generally,
this is HP LaserJet model 3 and higher) render chart output. If you attempt to print a chart to a LaserJet printer that does
not support HPGL, the HPGL command output might become part of your output, leaving one or more lines of meaningless data
across your report.

All the attributes defined for DECLARE-CHART are valid for the PRINT-CHART command. PRINT-CHART has five additional parameters.
The position of the chart is described using the first parameter. The data that supports the chart is defined in the additional
attributes: DATA-ARRAY, DATA-ARRAY-ROW-COUNT, DATA-ARRAY-COLUMN-COUNT, and DATA-ARRAY-COLUMN-LABELS.

As mentioned, each chart type meets a specific organizational requirement. The Chart Array Field Types (fewer than four fields)
table describes these requirements.

Note. If the first field in the array designated by DATA-ARRAY is of type CHAR, then the value on the x-axis is the contents of
that column. If the first field is not of type CHAR, then the value of the x-axis is the row number of the array designated
by DATA-ARRAY, beginning with 1. Pie charts show the character value in the legend area. Histograms show the character value
on the y-axis. XY-Scatter charts do not use the character value and none is needed in the array.

Note. If a PIE chart contains many small slices, the user must set the PIE-SEGMENT-QUANTITY-DISPLAY and/or PIE-SEGMENT-PERCENT-DISPLAY
arguments to NO to prevent the values from one slice overwriting the values of another slice.

Specifies the name of the chart from the DECLARE-CHART command. This name is not necessary if you specify the CHART-SIZE and
all other pertinent attributes in the PRINT-CHART command.

Position

(row, column) Specifies the position of the upper left corner. Position parameters can be relative. See the POSITION command
for examples of relative positioning. Document markers are not allowed. After execution, the current position is returned
to this location; however, the next listing line is the next line below the bottom of the chart area. (This is different than
the way the PRINT command works.)

DATA-ARRAY

Specifies the name of the array containing the data to be plotted. This must be the name of an array defined with CREATE-ARRAY.

DATA-ARRAY- ROW-COUNT

Specifies the number of rows or sets of data to be used from the DATA-ARRAY. If the DATA-ARRAY has a greater number of rows,
only DATA-ARRAY-ROW- COUNT is included in the chart.

DATA-ARRAY- COLUMN-COUNT

Specifies the number of columns to be used from the DATA-ARRAY. If the DATA-ARRAY has a greater number of columns, only DATA-ARRAY-
COLUMN-COUNT is included in the chart.

DATA-ARRAY- COLUMN-LABELS

Specifies labels for each Y-Axis value of the data set (fields) in DATA-ARRAY. These labels are displayed in the legend box.
Column labels are ignored for pie charts. See the Chart Array Field Types (fewer than four fields) table for applicable fields
for each type of chart.

For definitions of the other arguments, see the DECLARE-CHART Command Arguments table.

Example

In this example, a pie chart is printed without explicit reference to a chart declared with DECLARE-CHART. All necessary arguments must be supplied in
PRINT-CHART.

PRINT-DIRECT

Writes directly to the print output file without using the SQR page buffer.

PRINT-DIRECT can be used for special applications that cannot be accomplished directly with PRINT commands, such as initializing
a page with graphics or other special sequences. Because this text is often printer-dependent and because the report can be
printed on different types of printers that require different control characters, you can use the PRINTER qualifier to specify
the printer type. If no PRINTER qualifier is specified, the command applies to all printer types.

When using PRINT-DIRECT in conjunction with PRINT commands, be aware that the SQR page buffer is copied to the output file
only when each page is full or when a NEW-PAGE command is issued. One approach is to use PRINT-DIRECT commands inside a BEFORE-PAGE
or AFTER-PAGE procedure (declared with the DECLARE-PROCEDURE command), so they are coordinated with the information coming out of the page buffer.

Parameters

NOLF

Specifies that no carriage return and line feed is to be printed. By default, printed text is followed by a carriage return
and line feed character.

PRINT-IMAGE

Note. If TYPE, IMAGE-SIZE, and SOURCE are not defined in PRINT-IMAGE, they must be defined in DECLARE-IMAGE.

Description

Prints an image.

The PRINT-IMAGE command can be placed in any section of a report with the exception of the SETUP section. The image file pointed
to can be any file of the proper format.

PRINT-IMAGE may be used without referencing a named image if all required attributes for the DECLARE-IMAGE are supplied in
addition to all its required parameters.

Parameters

image_name

Specifies the name of an image specified by a DECLARE-IMAGE.

position

(row, column) Specifies the position of the upper left corner. Position parameters can be relative. See the POSITION command
for examples of relative positioning. Document markers are not allowed. After execution, the current position is returned
to this location; however, the next listing line below the bottom of the image area. (This is different from the way the PRINT
command works.)

PUT

Columns retrieved from the database and SQR variables or literals can be moved into an array. The array must have been created
previously using the CREATE-ARRAY command.

Considerations using PUT

When a date variable or column is moved into a text or char array field, the date is converted to a string according to the
following rules:

For DATETIME columns and SQR DATE variables, SQR uses the format specified by the SQR_DB_DATE_FORMAT setting.

If this has not been set, SQR uses the first database-dependent format as listed the Default Database Formats table.

For DATE columns, SQR uses the format specified by the SQR_DB_DATE_ONLY_FORMAT setting.

If this has not been set, SQR uses the format listed in the DATE Column Formats table.

For TIME columns, SQR uses the format specified by the SQR_DB_TIME_ONLY_FORMAT setting.

If this has not been set, SQR uses the format as listed in the TIME Column Formats table.

When a string variable, column, or literal is moved to a date array field, the string must be in the format specified by the
SQR_DB_DATE_FORMAT setting, one of the database-dependent formats as listed in the DATE Column Formats table is used, or the
database-independent format 'SYYYYMMDD[HH24[MI[SS[NNNNNN]]]]'.

dst_array_name(element)

If array fields are listed, data is placed into each field in the sequence it is listed, in the occurrence specified of that
field.

If array fields are not listed, data is placed into consecutive fields in the order in which they were defined in the CREATE-ARRAY
command; data is copied into occurrence zero of each field of the element specified in the array.

field [ ( occurs ) ]

Array element and field occurrence numbers can be numeric literals (123) or numeric variables (#j).

If no occurrence is specified, occurrence zero is used.

Parameters

src_any_var

The source variable or literal to be moved into the array. Numeric variables, literals, and database columns can be put into
number (decimal, float, integer) fields. String variables, literals, and database columns can be put into char, text, or
date fields. Date variables can be put into date, char, or text fields.

Example

In the following example, the four variables &name, #count, $date1, and $code are placed into the first four fields defined in the names array. The data is put into the #j'th element of the array.

put &name #count $date1 $code into names(#j)

The following command places #j2, #j3, and #j4 into the zero through 2nd occurrences of the tot field in the #j'th element of the totals array.

put #j2 #j3 #j4 into totals(#j) tot(0) tot(1) tot(2)

The following command copies #count into the #j2'th occurrence of the count field in the #j'th element of the states array.

Text data is any string of characters. The length of the variable name indicates how many characters to place into the variable.

After being transferred, trailing blanks in the variable are omitted.

If the field was written as a date variable, then it may be read into a date variable or text variable.

When reading a date into a date variable, it must be in the format specified by the SQR_DB_DATE_FORMAT setting, one of the
database-dependent formats as listed in the DATE Column Formats table is used, or the database-independent format 'SYYYYMMDD[HH24[MI[SS[NNNNNN]'.

Binary numbers, may be 1, 2, or 4 bytes in length.

They must be read into numeric variables. Note that the bytes making up the binary number must be in the standard sequence
expected by your operating system.

When reading binary data the file must be opened with the FIXED or FIXED-NOLF qualifier.

Only the integer portion of the number is represented with binary numbers.

To maintain the decimal portion of the number convert the number to a string variable.

If you use binary numbers, the file is not portable across platforms.

Different hardware represents binary numbers differently.

The total length indicated for the variables must be less than or equal to the length of the record being read.

If there are no more records to read, the #end-file reserved variable is set to 1; otherwise, it is set to 0 (zero). Your program should check this variable after each READ
command.

If STATUS is specified, SQR returns 0 if the read is successful; otherwise, it returns the value of errno, which is system-dependent.

Parameters

filenum_lit|_var | _col

Specifies the number assigned in the OPEN command to the file to be read.

any_var :length_int_lit

Specifies one or more variables into which data from the record read are to be put. length_int_lit specifies the length of each field of data.

The following example shows a READ command that reads two dates. One is loaded into a date variable; the other is loaded into
a string variable, which is then converted to a date using the strtodate function.

ROLLBACK

An automatic rollback is performed whenever SQR ends due to program errors. ROLLBACK is useful in testing or in certain error
conditions.

ROLLBACK is an SQR command and should not be used inside an SQL paragraph.

Note. The ROLLBACK command can be used with Oracle, DB2, Informix, and ODBC(Microsoft SQL Server is accessible only with SQR Server for ODBC). For Sybase and Microsoft SQL Server, use BEGIN TRANSACTION and ROLLBACK TRANSACTION within SQL paragraphs as in the following example. See the COMMIT command for an example of ROLLBACK.

Example

The following example shows the ROLLBACK command:

if #error-status = 1
rollback
stop
end-if

See Also

The COMMIT command.

SBTOMBS

Syntax

SBTOMBS { txt_var }

Description

Converts a single-byte character into a multibyte equivalent.

This command converts the specified string as follows: Any occurrence of a single-byte character that also has a multibyte
representation (numerals, punctuation, roman characters, and katakana) is converted. This command also converts a sequence
of a kana character followed by certain grammatical marks into a single multibyte character, which combines the two elements.

Parameters

txt_var

Specifies the string to be converted.

See Also

The TO_MULTI_BYTE function of the LET command.

SECURITY

The SECURITY command can be repeated as many times as desired for the current report. After the SECURITY command is executed,
all subsequent commands for the current report are constrained by the designated sids until the report ends or another SECURITY command executes.

You can use the SECURITY command wherever you use the PRINT command.

Parameters

SET

Sets the list of security IDs for subsequent commands. The previous list of security IDs is replaced by the specified security IDs. This argument is optional
and can only be used once.

sid

Can be any string literal, column, or variable. The value is case-sensitive.

APPEND

Appends the specified security IDS to the current list. This argument is optional and can be used multiple times.

REMOVE

Removes the specified security IDS from the current list. This argument is optional and can be used multiple times.

MODE

Used to turn on (reactivate) or turn off (suspend) the security feature for the current report. This argument is optional
and can only be used once.

mode

Can be any string literal, column, or variable. The value is not case-sensitive and can be either ON or OFF.

Example

The following example shows the SECURITY command:

Begin-Report
Security Set=('Directors', 'Vice-Presidents')
.
. ! Only Directors and VPS can see this
.
Security Remove=('Directors')
.
. ! Only VPS can see this
.
Security Mode='Off'
.
. ! Anybody can see this
.
Security Mode='On' Append=('Managers')
.
. ! Only VPs and Managers can see this
.
Security Append=('Engineers')
.
. ! Only VPs, Managers, and Engineers can see this
.
End-report

SET-COLOR

The SET-COLOR command is allowed wherever the PRINT command is allowed. If the specified color name is not defined, SQR uses
the settings for the color name 'default.' Use the color name 'none' to turn off color for the specified area.

Parameters

PRINT-TEXT- FOREGROUND

Defines the color in which the text is printed.

PRINT-TEXT- BACKGROUND

Defines the color to print as a background behind the text.

{color_name_lit | _var | _col}

A color_name is composed of alphanumeric characters (A-Z, 0-9), the underscore (_) character, and the hyphen (-) character. It must start
with an alphabetical (A-Z) character and is case-insensitive. The name 'none' is reserved and cannot be assigned a value.
A name in the format (RGBredgreenblue) cannot be assigned a value. The name 'default' is reserved and may be assigned a value.
'Default' is used during execution when a referenced color is not defined in the runtime environment.

{rgb}

red_lit | _var | _col, green_lit | _var | _col, blue_lit | _var | _col where each component is a value in the range of 000 to 255. In the BEGIN-SETUP section, only literal values are allowed.

SET-GENERATIONS

Returns the set of members in the dimension 'product' that are at the 5th generation in the dimension's hierarchy. (Returns all 'Brand Name' members (Generation Level 5) under the product hierarchy
of 'all products.drink.alcoholic beverages.beer and wine.' This would increase the result set to a list of beers and wines.)
Returns the set of members in the dimension 'time' that are at the 1st generation deep into the dimension. (Returns all 'Year' members (Generation Level 1) under the time hierarchy of '2004.Q1.2'.
This reduces result set to '2004'.)

Example

The following example shows the SET-GENERATIONS command:

set-generations=('product',5,'time',1 )

SET-LEVELS

Syntax

Set-levels=(dimension, level, dimension, level,...,...)

Description

Extends the dimension hierarchy for the previously declared dimension.

Set-levels used with only the previous 'set-members', returns all members under the product hierarchy and the next two generations
(Product SubCategory and Brand Name) for the product hierarchy of all products.drink.alcoholic beverages.beer and wine'. Set-levels
used with the previous 'set-members' and 'set-generations', returns all members for generation levels 5 through 7 under the
product hierarchy of all products.drink.alcoholic beverages.beer and wine.'

Example

The following example shows the SET-LEVELS command:

set-levels=('product',2 )

SET-MEMBERS

Syntax

set-members=(dimension, hierarchy, dimension, hierarchy,..., ...)

Description

Returns the set of members in a dimension, level, or hierarchy whose name is specified by a string.

Example

Returns the set of members in the dimension 'product' at the specific hierarchy of 'all products', at a specific level of
'drink', at a specific level of 'alcoholic beverages', at a specific level of 'beer and wine'. Returns the set of members
in the dimension 'time' at the specific hierarchy of '2004', at the specific level of 'Q1', at the specific level of '2'.

SHOW

Displays one or more variables or literals on the screen. In addition, cursor control is supported for ANSI terminals.

Any number of variables and screen positions can be used in a single command. Each one is processed in sequence.

Screen locations can be indicated by either fixed or relative positions in the format (A,B), where A is the line and B is
the column on the screen. A and/or B can also be numeric variables. Relative positions depend on where the previous SHOW command
ended. If the line was advanced, the screen cursor is usually immediately to the right of the previously displayed value and
one line down.

Fixed or relative cursor positioning can be used only within the boundaries of the terminal screen. Scrolling off the screen
using relative positioning, for example (+1,1), is not supported. Instead, use a SHOW command without any cursor position
when you want to scroll. Also, you cannot mix SHOW and DISPLAY commands while referencing relative cursor positions.

The SHOW command does not advance to the next line if a cursor location (...), CLEAR-SCREEN, CLEAR-LINE, or BEEP is used.
(A SHOW command without any of these arguments automatically advances the line.) To add a line advance, add (+1,1) to the
end of the line or use an extra empty SHOW command.

Only ANSI terminals are supported for cursor control, screen blanking, line blanking, and display characteristics.

Dates can be contained in a date variable or column, or a string literal, column, or variable. When displaying a date variable
or column, without an edit mask, the date is displayed according to the following rules:

For DATETIME columns and SQR DATE variables, SQR uses the format specified by the SQR_DB_DATE_FORMAT setting.

If this has not been set, SQR uses the first database-dependent format as listed in the Default Database Formats table.

For DATE columns, SQR uses the format specified by the SQR_DB_DATE_ONLY_FORMAT setting.

If this has not been set, SQR uses the format listed in the Default Database Formats table.

For TIME columns, SQR uses the format specified by the SQR_DB_TIME_ONLY_FORMAT setting.

If this has not been set, SQR uses the format as listed in the TIME Column Formats table.

When displaying a date in a string literal, column, or variable using EDIT or DATE, the string must be in the format specified
by the SQR_DB_DATE_FORMAT setting, one of the database-dependent formats as listed in the Default Database Formats table,
or the database-independent format 'SYYYYMMDD[HH24[MI[SS[NNNNNN]]]].

Parameters

cursor_position

Specifies the position on the screen to begin the display.

{CLEAR-SCREEN | CS}

Clears the screen and sets the cursor position to (1,1).

{CLEAR-LINE | CL}

Clears a line from the current cursor position to the end of the line.

{any_lit | _var | _col}

Specifies the information to be displayed.

EDIT

Shows variables under an edit mask. If the mask contains spaces, enclose it in single quotes. For additional information regarding
edit masks, see the PRINT command.

NUMBER

Indicates that any_lit|_var|_col is to be formatted using the NUMBER-EDIT- MASK from the current locale. (See the ALTER-LOCALE
command.) This option is not valid for date variables.

MONEY

Indicates that any_lit|_var|_col is to be formatted using the MONEY-EDIT- MASK from the current locale. (See the ALTER-LOCALE
command.) This option is not valid for date variables.

DATE

Indicates that any_lit|_var|_col is to be formatted using the DATE-EDIT-MASK from the current locale. (See the ALTER-LOCALE
command.) This option is not valid for numeric variables. If DATE-EDIT-MASK has not been specified, the date is displayed
using the default format for that database (see the Default Database Formats table).

BOLD, BLINK, UNDERLINE, and REVERSE

Changes the display of characters on terminals that support those characteristics. Some terminals support two or more characteristics
at the same time for the same text. To turn all special display characteristics off, use NORMAL.

NORMAL

Turns off all special display characteristics set with BOLD, BLINK, UNDERLINE, and REVERSE.

BEEP

Causes the terminal to beep.

NOLINE

Inhibits a line advance.

Example

The following program segments illustrate the various features of the SHOW command:

01-Jan-2004
!
! Show two values on the same line
!
show 'Hello' ' World'

Produces the following output:

Hello World
!
! Show two values on the same line with editing of the values
!
let #taxes = 123456.78
show 'You owe ' #taxes money ' in back taxes.'

Produces the following output:

You owe $123,456.78 in back taxes.

The following program illustrates the usage of additional options of the SHOW command. Only terminals that support the ANSI
escape characters can use the cursor control, screen blanking, line blanking and display attributes.

The LET command for information about copying, editing, or converting fields.

The EDIT parameter of the PRINT command for a description of the edit masks.

The ALTER-LOCALE command for a description of the arguments NUMBER-EDIT-MASK, MONEY-EDIT-MASK, and DATE-EDIT-MASK.

DISPLAY

STOP

Syntax

STOP [QUIET]

Description

The STOP command halts SQR and executes a ROLLBACK command (not in Sybase, Microsoft SQL Server, or Informix). All report page buffers are flushed, if they contain data; however, no headers or footers are printed and the AFTER-PAGE
and AFTER-REPORT procedures are not executed.

STOP is useful in testing.

Parameters

QUIET

Causes the report to complete with the "SQR: End Of Run" message, instead of ending with an error message.

The "||" concatenation operator in the Operators table under the LET command.

SUBTRACT

Syntax

SUBTRACT {src_num_lit|_var|_col} FROM dst_num_var[ROUND=nn]

Description

SUBTRACT subtracts the first value from the second and moves the result into the second field.

When dealing with money-related values (dollars and cents), use decimal variables rather than float variables. Float variables
are stored as double precision floating point numbers, and small inaccuracies can appear when subtracting many numbers in
succession. These inaccuracies can appear due to the way floating point numbers are represented by different hardware and
software implementations.

Parameters

{src_num_lit | _var | _col}

Is subtracted from the contents of dst_num_var.

dst_num_var

Contains the result after execution.

ROUND

Rounds the result to the specified number of digits to the right of the decimal point. For float variables this value can be from
0 to 15. For decimal variables, this value can be from 0 to the precision of the variable. For integer variables, this argument
is not appropriate.

Specifies the level at which to place the text. If this argument is not specified, the value of the previous level is used.

Example

The following example shows the TOC-ENTRY command:

toc-entry text = &heading
toc-entry text = &caption level=2

See Also

The DECLARE-TOC command.

UNSTRING

Syntax

UNSTRING {{src_txt_lit|_var|_col}|{src_date_var|_col}}
BY {delim_txt_lit|_var|_col}
INTO dst_txt_var...

Description

Copies portions of a string into one or more text variables.

Each substring is located using the specified delimiter. The source string must not be included in the list of destination strings.

If more destination strings than substrings are found in the source strings, the extra destination strings are each set to
an empty string.

If more substrings are found in the source string than in the destination strings, the extra substrings are not processed.
It is up to the programmer to ensure that enough destination strings are specified.

If the source is a date variable or column, it is converted to a string according to the following rules:

For DATETIME columns and SQR DATE variables, SQR uses the format specified by the SQR_DB_DATE_FORMAT setting.

If this has not been set, SQR uses the first database-dependent format as listed in the Default Database Formats table.

For DATE columns, SQR uses the format specified by the SQR_DB_DATE_ONLY_FORMAT setting.

If this has not been set, SQR uses the format listed in the Default Database Formats table.

For TIME columns, SQR uses the format specified by the SQR_DB_TIME_ONLY_FORMAT setting.

If this has not been set, SQR uses the format as listed in the TIME Column Formats table.

Parameters

{src_txt_lit|_var|_col}|{ src_date_var|_col}

Specifies the source field to be parsed.

delim_txt_lit|_var|_col

Specifies one or more characters to be used to delimit the fields within {src_txt_lit|_var|_col}|{src_date_var|_col}

USE-PRINTER-TYPE

Syntax

USE-PRINTER-TYPE printer-type

Description

Sets the printer type to be used for the current report.

The USE-PRINTER-TYPE command sets or alters the printer type to be used for the current report. The USE-PRINTER-TYPE command
must appear before the first output is written to that report. If output has already been written to the report file, the
USE-PRINTER-TYPE command is ignored.

Parameters

printer-type

Specifies the printer type to be used for the current report. See DECLARE-PRINTER for valid types.

The USE-PROCEDURE must be issued in the PROGRAM or PROCEDURE sections of an SQR program. USE-PROCEDURE is a runtime command;
its compile-time equivalent is DECLARE-PROCEDURE. You can use the command as often as required to change to the necessary procedures required by the reports. If you issue
multiple USE-PROCEDURE commands, each remains in effect for that report until altered by another USE-PROCEDURE command for
that report. In this way, you can use one to change common procedures for ALL reports and others to change unique procedures
for individual reports. The referenced procedures can accept arguments.

If no FOR-REPORTS is specified, ALL is assumed. Initially, the default for each of the four procedure types is NONE. If a
procedure is defined in one DECLARE-PROCEDURE for a report, that procedure is used unless NONE is specified.

You can change the BEFORE-REPORT only before the first output is written to that report, because that causes the BEFORE-REPORT
procedure to be executed.

Parameters

FOR-REPORTS

Specifies the reports that are to use these procedures. This argument is required only for a program with multiple reports.
If you are writing a program that produces a single report, you can ignore this argument.

BEFORE-REPORT

Specifies a procedure to execute at the time of execution of the first command, which causes output to be generated. You can
use the command, for example, to create a report heading.

AFTER-REPORT

Specifies a procedure to execute just before the report file is closed at the end of the report. This argument can be used
to print totals or other closing summary information. If no report was generated, the procedure does not execute.

BEFORE-PAGE

Specifies a procedure to execute at the beginning of every page, just before the first output command for the page. It can
be used, for example, to set up page totals.

AFTER-PAGE

Specifies a procedure to execute just before each page is written to the file. This argument can be used, for example, to
display page totals.

You can also specify arguments to be passed to the procedure. Arguments can be any variable, column, or literal.

Example

The following example shows the USE-PROCEDURE command:

use-procedure ! These procedures will
for-reports=(all) ! be used by all reports
before-report=report_heading
after-report=report_footing
use-procedure ! These procedures will
for-reports=(customer) ! be used by the customer
before-page=page_setup ! report
after-page=page_totals
use-procedure ! The after-report
for-reports=(summary) ! procedure will be
after-report=none ! disabled for the
! summary report

See Also

DECLARE-PROCEDURE

USE-REPORT

Syntax

USE-REPORT {report_name_lit|_var|_col}

Description

For programs with multiple reports, enables the user to switch between reports.

The USE-REPORT command specifies to which report files the subsequent report output is to be written. An application can contain
several USE-REPORT statements to control several reports.

You must specify the report name and report characteristics in a DECLARE-REPORT paragraph and in the associated DECLARE-LAYOUT
and DECLARE- PRINTER paragraphs.

Parameters

{report_name_lit|_var|_col}

Specifies the report to become the current report. All subsequent PRINT and PRINT-DIRECT statements are written to this report
until the next USE- REPORT is encountered.

WRITE

Writes a record to a file from data stored in variables, columns, or literals.

The file must already be opened for writing.

If length is specified, the variable is either truncated at that length or padded with spaces to that length. If length is
not specified (for string variables or database columns), the current length of the variable is used.

When writing numeric variables, the length argument is required. Only 1, 2, or 4 byte binary integers are written. Floating
point values are not supported directly in the WRITE command. However, you can first convert floating point numbers to strings
and then write the string.

When writing binary data the file must be open using the FIXED or FIXED-NOLF qualifiers. The file is not portable across platforms
because binary numbers are represented differently.

When writing a date variable or column, the date is converted to a string according to the following rules:

For DATETIME columns and SQR DATE variables, SQR uses the format specified by the SQR_DB_DATE_FORMAT setting.

If this has not been set, SQR uses the first database-dependent format as listed in the Default Database Formats table.

For DATE columns, SQR uses the format specified by the SQR_DB_DATE_ONLY_FORMAT setting.

If this has not been set, SQR uses the format listed in the DATE Column Formats table.

For TIME columns, SQR uses the format specified by the SQR_DB_TIME_ONLY_FORMAT setting.

If this has not been set, SQR uses the format as listed in the TIME Column Formats table.

Text literals take the length of the literal.

Files opened for writing are treated as having variable-length records. If you need a fixed-length record, specify a length
for each variable written to the file.

The total length of the variables and literals being written must not be greater (but can be less) than the record length
specified when the file was opened. Records are not padded, but are written with the total length of all variables in the
WRITE command.

If STATUS is specified, SQR returns 0 if the write is successful; otherwise, it returns the value of errno, which is system-dependent.

Parameters

filenum_lit|_var |_col

Specifies the number assigned in the OPEN command to the file to be written.