Search code examples
string-formattinginformix4gl

What does String formatter "<<<&" in Informix 4GL code mean?


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.


Solution

  • 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.