1

I am reading through a legacy 4GL script. In the report section I came across the following:

int_type_variable USING “<<<&”

I understand this is supposed to convert the integer into a String using the String formatter. According to IBM Informix page,

< : This character left-justifies the numbers in the display field. It changes leading zeros to a null string.

& : This character fills with zeros any positions in the display field that would otherwise be blank.

The int_type_variable is generally 4 digit. I'm confused what it is supposed to do.

I would be grateful, if someone could explain with an example.

Ron
  • 149
  • 2
  • 16

2 Answers2

1

It's not very clearly defined, but the idea is that the number should be left-justified, and if it is zero, the zero digit should be displayed. You mention that you saw this in a report, presumably as part of a PRINT statement. You could easily explore what it does with the DISPLAY statement (outside a report):

MAIN

    DEFINE i INTEGER

    FOR i = -10 TO 1000 STEP 5
        DISPLAY "==", i USING "<<<&", "=="  # Optionally drop the "==" strings
    END FOR

END MAIN

You could experiment with alternative formats to see what the differences are, such as:

  • "<<<<"
  • "-<<<"
  • "-<<&"
  • "####"
  • "###&"
  • "---&"
  • "-##&"
  • "-&&&"
  • "-###"
  • etc.

You could try them all at once with a single DISPLAY statement, or compile the program repeatedly, or pass the format string to a function which does the display work, or …

If you must do it with a report, then you can write a simple report and test it:

MAIN

    DEFINE i INTEGER

    START REPORT test_formats

    FOR i = -10 TO 1000 STEP 5
        OUTPUT TO REPORT test_formats(i)
    END FOR

    FINISH REPORT test_formats

END MAIN

REPORT test_formats(i)

    DEFINE i INTEGER

    OUTPUT
        TOP MARGIN 0
        BOTTOM MARGIN 0
        LEFT MARGIN 0
        PAGE LENGTH 1

    ON EVERY ROW
        PRINT COLUMN  1, "==", i USING "<<<&", "==",
              COLUMN 11, "==", i USING "-<<<", "==",
              COLUMN 21, "==", i USING "-<<&", "==",
              COLUMN 31, "==", i USING "####", "==",
              COLUMN 41, "==", i USING "###&", "==",
              COLUMN 51, "==", i USING "---&", "==",
              COLUMN 61, "==", i USING "-##&", "==",
              COLUMN 71, "==", i USING "-###", "=="

END REPORT

Warning: No I4GL compiler was consulted about the validity of any of the code shown!

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
1

For the What or Why, a USING utilising "<" generally indicates that the developer did not want any excess space between the number and whatever was to its left, normally a title or label for the number you are looking at. So in your case, your report might be saying ...

Number of Records Found: 1

as opposed to say ...

Number of Records Found:    1

You might say that is not so bad with an expected maximum value of 9999 but say expected maximum value was 99999999999 then if you did not use "<" then you might end up with ...

Number of Records Found:           1

that is a big space between the number and its label and the possibility that the report reader would not interpret the label as belonging to the number.

You would not use "<" if you wanted the digits to align vertically. Then you would most likely be using "#" instead.

The "&" is used to indicate what to do if value is zero. In this case it is saying that if the value is 0 to display a single 0 ...

Number of Records Found: 0

If you had "<<<<" then no value would be displayed ...

Number of Records Found:

or if you had "&&&&" then leading zeros would be displayed...

Number of Records Found: 0001

Also your link wasn't to an Informix-4gl reference. You can use the Genero link in this instance http://4js.com/online_documentation/fjs-fgl-manual-html/#fgl-topics/c_fgl_DataConversions_format_numbers.html for some more examples. I don't think we have added any characters to the 4gl syntax in this area.

fourjs.reuben
  • 286
  • 3
  • 3