Long Expressions. Robelle Suprtool 5.7
বিজ্ঞাপন
বিজ্ঞাপন
204 • Suprtool 5.7 for MPE
----+----1----+----2----+----3----+----4
000101 New Years Day
000414 Good Friday
000524 Victoria Day
001009 Thanksgiving (Canada)
001111 Remembrance Day
001225 Christmas
001226 Boxing Day
010101 New Years Day
010405 Good Friday
010520 Victoria Day
011014 Thanksgiving (Canada)
011111 Remembrance Day
011225 Christmas
011226 Boxing Day
Long Expressions
Long If commands can use an ampersand to continue the command over several lines:
>if status = "20" and &
>> state = "AZ", &
>> "CA", &
>> "OR" {no ampersand on the last line}
This is awkward to use and, for internal reasons, the maximum length is restricted to
256 characters. The $read function makes it easier to enter long If commands. Its maximum length is based on the complexity of the expression, not on the number of characters.
$Read Function
The $read function reads the If expression from $stdinx, or from the usefile if the If command is in a usefile. $Read continues to prompt for input lines until you press
Return or enter "//." You must remember to enter all the necessary parts of the If expression, including connectors like AND and OR and commas. You do not use an ampersand (&) to continue from one line to the next when using $read.
>if $read {prompt for the expression}
-status = "20" and {$read prompts with "-"}
-state = "AZ", {the comma is still needed}
- "CA",
- "OR" {no comma on the last line}
- {blank line to terminate $read}
Redoing $Read
When prompting for an expression, $read saves each line in the redo stack and accepts the Before, Do, Listredo, and Redo commands. This provides an easy way to specify all or part of a previous $read expression.
Error: Data Overflow
While the $read function permits long expressions, there are other internal limits within the If command. The first is a limit on the amount of space for constants.
Suprtool must blank-fill all string constants to their full length. The following example overflows the data space:
Suprtool Commands
Suprtool Commands
>define char-256,1,256
>if char-256 = "a","b","c"
Error: Data Overflow
In this example, Suprtool attempted to create three 256-byte constants. There wasn't enough room for the last constant. Solutions to this problem include:
1. If possible, define short fields. If you have long field names, you may want to use the Define command to define shorter subfields.
2. Use tables and $lookup for many values.
3. Split the extract task into multiple passes. On the first pass, use an If expression that results in the fewest possible number of output records.
Use the output file from the first pass as input to the second. Apply the remainder of your If expression during the second pass.
Error: Code Overflow
Suprtool translates If commands to an internal machine representation. There is a limit on the size of this code. When an error occurs, there is little you can do except use tables and $lookup wherever possible, and when this fails use multiple passes.
$Read in Usefiles
When you specify $read in a usefile, Suprtool expects the If expression to appear in the usefile. This provides a method for storing and executing complicated If commands.
You can also manipulate Suprtool into prompting for portions of an If command.
When the If command with $read is the last command in a usefile, Suprtool satisfies the $read from $stdinx. The $read function can appear anywhere in which a space can appear, so you can use this to prompt the user for values.
>use prompt.use
>in sdfile {first line of usefile}
>if status=$read and & {continue the If command}
state = $read {last line of the usefile}
-"10" {prompt for status}
-// {end of prompt for status}
-"AZ", {prompt for state}
-"CA", {user must remember comma}
-"OR" {user also enters quotes}
-// {end of the second read}
Notes
Suprtool is not designed to be used by end users. We prefer that you write intelligent front-ends that understand user applications and hide the details of Suprtool from end users. We recommend that you use $read from usefiles only for one-time tasks, or for tasks used by experienced Suprtool users who do not require a friendly user interface.
$-functions
Some $-functions were originally designed for if command and some are more suited for the extract command. Because of this some $-functions don’t work in the if command, such as $edit, and others such as $number have interesting side effects.
Specifically with $number, when you work on byte type fields, they will be updated internally to be treated as display:
Suprtool 5.7 for MPE• 205
Get dataset
Def display-field,byte-field,display
If $number(display-field) > 10000
Out somefile,link xeq
The field byte-field will have leading zeroes and treated as a display.
206 • Suprtool 5.7 for MPE
Suprtool Commands
ডাউনলোড
বিজ্ঞাপন