1

I'm trying to align the column values, but they are of different lengths. I can't just use Print '123' (+1, 9) and then Print '123456' (+1, 9) because it'll look something like this:

123456790123456790123456790123456790123456790123456790 <- Ignore this line
       123
       123456

Notice how the right most numbers aren't aligned with each other. I want the output to be like this:

123456790123456790123456790123456790123456790123456790 <- Ignore this line
     123
  123456

So I would want to stop printing at a certain index. How would I achieve this using SQR?

I tried Print '123' (+1, 9) and Print '1234' (+1, 9) but it gives the wrong results.

Jimenemex
  • 3,104
  • 3
  • 24
  • 56

2 Answers2

1

I'm not familiar with SQR, but here's a suggestion: as SQR supports the LPAD function (see String functions):

Pads the source_value on the left to a length of length_value using pad_value and returns the result.

Syntax: dst_var = lpad(source_value, length_value, pad_value)

you could apply it to strings you print. For example (once again: note that I don't know SQR, you might need to adjust it):

Print lpad('123', 6, ' ') (+1, 9)

which would make ...123 (each dot represents a space).

Why LPAD to 6 characters in length? Well, because your other string ('123456') is 6 characters long. Change it, if necessary.

Littlefoot
  • 131,892
  • 15
  • 35
  • 57
1

First of all, it looks like you want to end the value in column 9. The lPad function will not work for this because (+1,9) says START in column 9. Also, you can't put the lPad function into the print statement.

Instead use the Edit parameter of print starting in column 1:

Print 123    (+1,1) edit 999999999
Print 123456 (+1,1) edit 999999999

Now that works great for numbers but it also works well for strings as long as they contain numbers. So this works too:

Print '123'    (+1,1) edit 999999999
Print '123456' (+1,1) edit 999999999

I have tested these statements in SQR and they work, however, this will produce ugly results:

Print 'ABC'    (+1,1) edit 999999999
Print 'ABCDEF' (+1,1) edit 999999999

If you have to print strings not numbers, then use the lPad command to format the variable:

Let $String = lPad($String, 9, ' ')
Print $String (+1,1) ! <--- start at column 1
cardmagik
  • 1,698
  • 19
  • 17