String Primary

<string primary>

──┬─ <string constant> ───────────────┬────────────────────────────────┤
  ├─ <string constant identifier> ────┤
  ├─ <string identifier> ─────────────┤
  ├─ <string file attribute primary> ─┤
  ├─ <string task attribute primary> ─┤
  ├─ <accept function> ───────────────┤
  ├─ <head-tail functions> ───────────┤
  ├─ <string function> ───────────────┤
  ├─ <system function> ───────────────┤
  ├─ <take-drop functions> ───────────┤
  ├─ <timedate functions> ────────────┤
  ├─ <translate functions> ───────────┤
  └─ ( ── <string expression> ── ) ───┘

Explanation

Syntax for string constants, string constant identifiers, and string identifiers is provided in Basic Constructs. The other kinds of string primaries are defined in the following topics.

String File Attribute Primary

<string file attribute primary>

── <file identifier> ── ( ─┬─ <file name file attribute> ─┬─ ) ────────┤
                           ├─ <mnemonic file attribute> ──┤
                           ├─ <name file attribute> ──────┤
                           ├─ <string file attribute> ────┤
                           ├─ <title file attribute> ─────┤
                           └─ KIND ───────────────────────┘

Explanation

A string file attribute primary returns the value of an attribute of the file with the specified file identifier. The file attribute must be of type mnemonic, name, file name, string, or title.

The KIND attribute returns the kind of device the file resides on.

The file attribute SERIALNO cannot be used as a string primary.

Refer to Interrogating File Attributes for related information.

Example

The following example returns the current value of the SECURITYTYPE attribute of the file variable FILEA:

FILEA (SECURITYTYPE)

Possible values for SECURITYTYPE are CONTROLLED, GUARDED, PRIVATE, or PUBLIC. See the File Attributes Programming Reference Manual for more information.

String Task Attribute Primary

<string task attribute primary>

── <task identifier> ── ( ─┬─ <file name task attribute> ─┬─ ) ────────┤
                           ├─ <mnemonic task attribute> ──┤
                           ├─ <name task attribute> ──────┤
                           ├─ <string task attribute> ────┤
                           ├─ <title task attribute> ─────┤
                           ├─ ACCESSCODE ─────────────────┤
                           ├─ FAMILY ─────────────────────┤
                           ├─ OPTION ─────────────────────┤
                           └─ USERCODE ───────────────────┘

Explanation

A string task attribute primary returns the value of a task attribute associated with the specified task variable. The task attribute can be of type mnemonic, name, file name, string, or title.

Additionally, a string task attribute primary can be used to return the value of the complex task attributes FAMILY, USERCODE, ACCESSCODE, and OPTION. Refer to Interrogating Complex Task Attributes for further information.

Example

The following example returns the current value of the STATUS attribute of task variable TASKA:

TASKA (STATUS)

Possible values include NEVERUSED, SCHEDULED, and ACTIVE.

ACCEPT Function

<accept function>

── ACCEPT ── ( ── <string expression> ── ) ────────────────────────────┤

Explanation

The ACCEPT function displays a string on the ODT and waits for an operator to respond by way of an AX (Accept) system command. For a description of this command, refer to the System Commands Reference.

The AX command can also be entered from the MARC Action line, as explained in the MARC Operations Guide. If the job was initiated through CANDE, the string is also displayed at the originating terminal, and can be replied to by using CANDE ?AX command. For details, refer to the control commands in the CANDE Operations Reference Manual.

The first 430 characters of the AX operator response are returned as the value of the ACCEPT function.

The response to the ACCEPT function can be entered before the actual execution of that function.

The string expression specified in the ACCEPT function displays a maximum of 430 characters, although the string expression can contain up to 1799 characters.

Example

The following example runs a program and then examines the task state to see whether the program terminated normally. If it did not, then the value of the HISTORYTYPE attribute is displayed, and an ACCEPT function asks the user whether they want the job to continue:

RUN OBJECT/PROG ON ORDSPK [T];
IF T ISNT COMPLETEDOK THEN
BEGIN
DISPLAY"JULY RUN TERMINATED ABNORMALLY DUE TO"
& T(HISTORYTYPE);
IF ACCEPT("DO YOU WISH TO CONTINUE? YES OR NO") NEQ"YES" THEN
ABORT"JOB ABORTED AT YOUR REQUEST";
END;

HEAD and TAIL Functions

<head-tail functions>

──┬─ HEAD ─┬─ ( ── <string expression> ── , ── <character set> ── ) ───┤
  └─ TAIL ─┘

<character set>

──┬───────┬─┬─ <string constant expression> ─┬─────────────────────────┤
  └─ NOT ─┘ └─ ALPHA ────────────────────────┘

Explanation

The character set specifies a collection of characters used to control the action of the HEAD and TAIL functions. The predefined character set ALPHA consists of the letters A through Z and the digits 0 through 9. The string constant expression can have characters in any order. If the character set is of the form NOT string constant expression, then the character set consists of all EBCDIC characters except those specified in the string constant expression.

The HEAD function returns a string consisting of a copy of all leading characters in the string expression that belong to the set of characters in the character set. If the first character in the string expression is not a member of the character set, a null string ("") is returned.

The TAIL function returns a new string consisting of a copy of all the characters in the string expression that remains after the removal of all the leading characters belonging to the character set. If all characters in the string expression are members of the character set, a null string is returned.

For any string expression S and any character set C, the following relation is always true:

S = HEAD(S,C) & TAIL(S,C)

The HEAD and TAIL functions allow string expressions of up to 1800 characters for the parameter.

Examples

The following examples illustrate use of the HEAD and TAIL functions:

STR1:=" A B C";
STR2:= HEAD(STR1," "); % RESULT =" "
STR2:= TAIL(STR1," "); % RESULT ="A B C"
STR1:="FILE/NAME";
STR2:= HEAD(STR1,NOT"/"); % RESULT ="FILE"
STR2:= TAIL(STR1,NOT"/"); % RESULT ="/NAME"

STRING Function

<string function>

── STRING ── ( ── <integer expression> ── , ───────────────────────────►
►─┬─ <integer expression> ─┬─ ) ───────────────────────────────────────┤
  └─ * ────────────────────┘

Explanation

The STRING function returns a string that is formed by taking the absolute value of the first integer expression and converting it to its EBCDIC character representation. The length of the returned string is specified by the second parameter; if this second parameter is an integer expression with a value less than or equal to zero, the returned string is of length zero.

If the value of the second integer expression is greater than the minimum number of characters needed to represent the first argument, a sufficient number of leading zeros are provided.

If the value of the second integer expression is less than the number of characters needed to represent the first integer expression, the right-most characters are returned.

If the second parameter of the STRING function is an asterisk (*), the returned string will be long enough to contain all the digits of the character representation of the first argument with no leading zeros.

A run-time error occurs if the value of the second parameter is less than 0 or greater than 1800.

If you use a real expression in place of the first integer expression, the value is rounded to the nearest integer. However, if you use a real expression in place of the second integer expression, the fractional part of the value is simply truncated. For example, the function STRING(433.5, 2.5) returns the value "34". This result occurs because the value 433.5 is rounded up to 434, but the length value of 2.5 is truncated to 2.

Examples

The following examples illustrate the STRING function:

STR1:= STRING(123,*); % RESULT ="123"
STR2:= STRING(123,6); % RESULT ="000123"
STR1:= STRING(123.456, 7); % RESULT ="0000123"
STR2:= STRING(1234,3); % RESULT

SYSTEM Function

<system function>

── SYSTEM ── ( ─┬─ SERIALNUMBER ─┬─ ) ─────────────────────────────────┤
                ├─ TYPE ─────────┤
                └─ MCPLEVEL ─────┘

Explanation

The SYSTEM function is a string function that returns system identification information.

Examples

The following information can be requested:

SYSTEM (SERIALNUMBER)

Returns the serial number of the system as a string; the length of the string will vary. For example:

"1000"

SYSTEM (TYPE)

Returns the machine type as a string; the length of the string will vary. For example:

"CS7101"

SYSTEM (MCPLEVEL)

Returns the version and cycle of the current MCP as a string of six characters. The first two characters represent the version of the MCP and the last three characters represent the cycle of the MCP. A period (.) separates the version and the cycle. For example:

"37.100"

TAKE and DROP Functions

<take-drop functions>

──┬─ TAKE ─┬─ ( ── <string expression> ── , ── <integer expression> ) ───┤
  └─ DROP ─┘

Explanation

The TAKE function returns a string formed by taking the first integer expression number of characters from the string expression.

The DROP function returns a string with the characters remaining in the string expression after the first integer expression number of characters have been discarded.

A run-time error occurs if the value of the second parameter is less than 0 or greater than 1024, or is greater than the number of characters in the string expression.

For any string expression S and any integer expression I in the range 0 LEQ I LEQ LENGTH(S), the following relation is always true:

S = TAKE(S,I) & DROP(S,I)

If you use a real expression instead of an integer expression, the WFL compiler automatically truncates the fractional part, rather than rounding off the value. For example, the function TAKE("ABCDEF", 2.9) returns the value "AB", not "ABC".

The TAKE and DROP functions allow string expressions of up to 1032 characters for the parameter and the result.

Example

The following example illustrates the TAKE and DROP functions:

STR1:="ABCDEF";
STR2:= TAKE(STR1,2);      % RESULT ="AB"
STR2:= DROP(STR1,2);      % RESULT ="CDEF"

TIMEDATE Functions

<timedate function>

── TIMEDATE ── ( ─┬─ HHMMSS ─────────────┬─ ) ─────────────────────────┤
                  ├─ HHMMSSPPPP ─────────┤
                  ├─ YYYYMMDDHHMMSS ─────┤
                  ├─ YYYYMMDDHHMMSSPPPP ─┤
                  ├─ DISPLAY ────────────┤
                  ├─ MONTH ──────────────┤
                  ├─ DAY ────────────────┤
                  ├─ DAYNUMBER ──────────┤
                  ├─ YYDDD ──────────────┤
                  ├─ YYMMDD ─────────────┤
                  ├─ MMDDYY ─────────────┤
                  ├─ DDMMYY ─────────────┤
                  ├─ YYYYDDD ────────────┤
                  ├─ YYYYMMDD ───────────┤
                  ├─ MMDDYYYY ───────────┤
                  └─ DDMMYYYY ───────────┘

Explanation

The TIMEDATE function is a string function that can be used to obtain the time or date, or both, in various forms. All strings returned by the TIMEDATE function appear in uppercase.

Examples

The forms of the TIMEDATE function are described in the following paragraphs. Each description includes an example that indicates the result that would be returned at 5:09:00.7124 p.m., Wednesday, July 4, 2001.

TIMEDATE (HHMMSS)

Returns the time as a string of six characters. The first two characters represent the hours on a 24-hour clock, the next two characters represent the minutes, and the last two characters represent the seconds. For example:

"170900"

TIMEDATE (HHMMSSPPPP)

Returns the time as a string of 10 characters. The first two characters represent the hours on a 24-hour clock, the next two characters represent the minutes, the next two characters represent the seconds, and the last four characters represent the ten thousandths of a second. For example:

"1709007124"

TIMEDATE (YYYYMMDDHHMMSS)

Returns the time and date as a string of 14 characters. The first eight characters represent the date: four characters for the year, two characters for the month, and two characters for the day of the month. The last six characters represent the time: two characters for the hours on a 24-hour clock, two characters for the minutes, and two characters for the seconds. For example:

"20010704170900"

TIMEDATE (YYYYMMDDHHMMSSPPPP)

Returns the time and date as a string of 18 characters. The first eight characters represent the date: four characters for the year, two characters for the month, and two characters for the day of the month. The last 10 characters represent the time: two characters for the hours on a 24-hour clock, two characters for the minutes, two characters for the seconds, and four characters for the ten thousandths of a second. For example:

"200107041709007124"

TIMEDATE (DISPLAY)

Returns the time, day of the week, and date in a display-type format. The length of the string varies from 27 to 38 characters. For example:

"5:09 PM WEDNESDAY, JULY 4, 2001"

TIMEDATE (MONTH)

Returns the name of the month as a string. The length of the string varies from three to nine characters. For example:

"JULY"

TIMEDATE (DAY)

Returns the name of the day of the week as a string. The length of the string varies from six to nine characters. For example:

"WEDNESDAY"

TIMEDATE (DAYNUMBER)

Returns the number of the day of the week as a string of one character. The days of the week are numbered as follows: Sunday=0, Monday=1, Tuesday=2, Wednesday=3, Thursday=4, Friday=5, Saturday=6. For example:

"3"

TIMEDATE (YYDDD)

Returns the date as a string of five characters. The first two characters represent the year (modulo 100). The last three characters represent the day of the year. For example:

"01185"

TIMEDATE (YYMMDD)

Returns the date as a string of six characters. The first two characters represent the year (modulo 100). The following two characters represent the month, and the last two characters represent the day of the month. For example:

"010704"

TIMEDATE (MMDDYY)

Returns the date as a string of six characters. The first two characters represent the month. The following two characters represent the day of the month, and the last two characters represent the year (modulo 100). For example:

"070401"

TIMEDATE (DDMMYY)

Returns the date as a string of six characters. The first two characters represent the day of the month. The following two characters represent the month, and the last two characters represent the year (modulo 100). For example:

"040701"

TIMEDATE (YYYYDDD)

Returns the date as a string of seven characters. The first four characters represent the year. The last three characters represent the day of the year. For example:

"2001185"

TIMEDATE (YYYYMMDD)

Returns the date as a string of eight characters. The first four characters represent the year. The following two characters represent the month, and the last two characters represent the day of the month. For example:

"20010704"

TIMEDATE (MMDDYYYY)

Returns the date as a string of eight characters. The first two characters represent the month. The following two characters represent the day of the month, and the last four characters represent the year. For example:

"07042001"

TIMEDATE (DDMMYYYY)

Returns the date as a string of eight characters. The first two characters represent the day of the month. The following two characters represent the month, and the last four characters represent the year. For example:

"04072001"

TRANSLATE Functions

<translate functions>

──┬─ LOWERCASE ─┬─(── <string expression> ──)──────────┤
  └─ UPPERCASE ─┘

Explanation

The LOWERCASE and UPPERCASE functions return a string of the same length as the string expression. Each character of the string expression is translated to upper or lower case characters according to the designated function.

Examples

The following examples illustrate the LOWERCASE and UPPERCASE functions:

STR1:="a1b2c3d4e5f6g7";
STR2:= UPPERCASE(STR1);          % RESULT = "A1B2C3D4E5F6G7"
STR2:= LOWERCASE("TRANSLATEME"); % RESULT = "translateme"