How do I enter a long IF command?

A Suprtool command line cannot exceed 256 characters. You can reach this limit if you try to stack all your task commands into a single entity.

     input  ...; define ...; &
     extract ...; duplicate ...; if ...; &
     sort ...; output ...;xeq

The only solution in this situation is to put individual commands on separate lines. Then you can control the length of each command. If you are not stacking commands, you may also run into this problem if you use a long and complex If command. In that case, there are different ways to get around the problem.

If your command is complex and you are using long item names, you can assign shorter names by using Define statements. Then you can refer to the same item by using the short or long form.

     define low,ReOrderQuantity
     define curqty,OnHandQuantity

At the expense of readability, you can also remove unnecessary spaces. For example, you can use

     if curqty>low

instead of

     if on-hand-qty > re-order-quantity.

If your If command is too long because your list contains numerous values, you can load these values into a table.

     table custtbl,custno,item,"111111"
     table custtbl,custno,item,"222222"
     table custtbl,custno,item,"333333"
     if $lookup(custtbl,custno)

This table can replace the following If command,

     if custno="111111","222222","333333"

If you cannot apply these suggestions to your situation, you can also use the $READ function. The maximum length of the If command is then based on the complexity of the expression and not its length.

The $READ function reads the If expression from $STDINX, or from the use-file when it contains the If command. $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", "or" and commas. With $READ, you do not need an ampersand (&) to continue from one line to the next.

     >in supplier               {self-describing file}
     >if $read                  {prompt for the expression}
     -CustStatus = "20" and     {$READ prompts with "-"}
     -State = "AZ",             {the comma is still needed}
     -        "OR"              {no comma on the last line}
     -                          {blank line to terminate $READ}

....Back to the Suprtool Q&A P.3.2/a>