Examples of $JUSTIFY()

Example:

    GTM> WRITE $JUSTIFY("HELLO",10),!,$JUSTIFY("GOODBYE",5)
    HELLO
    GOODBYE
    GTM>        
    

This uses $JUSTIFY() to display "HELLO" in a field of 10 spaces and "GOODBYE" in a field of 5 spaces. Because the length of "GOODBYE" exceeds five spaces, the result overflows the specification.

Example:

    GTM> WRITE "1234567890",!,$JUSTIFY(10.545,10,2)
    1234567890
    10.55
    GTM>        
    

This uses $JUSTIFY() to WRITE a rounded value right justified in a field of 10 spaces. Notice that the result has been rounded up.

Example:

    GTM> WRITE "1234567890",!,$JUSTIFY(10.544,10,2)
    1234567890
    10.54
    GTM>
    

Again, this uses $JUSTIFY() to WRITE a rounded value right justified in a field of 10 spaces. Notice that the result has been rounded down.

Example:

    GTM> WRITE "1234567890",!,$JUSTIFY(10.5,10,2)
    1234567890
    10.50
    GTM>
    

Once again, this uses $JUSTIFY() to WRITE a rounded value right justified in a field of 10 spaces. Notice that the result has been zero-filled to 2 places.

Example:

    GTM> WRITE $JUSTIFY(.34,0,2)
    0.34
    GTM>
    

This example uses $JUSTIFY to ensure that the fraction has a leading zero. Note the use of a second argument of zero in the case that rounding is the only function that $JUSTIFY is to perform.