I'm wrestling with the Format function (and losing).
I have a number which I want to right justify in a 2 character field (called Result).
[font=courier]
1 <indicates 10 characters
1234567890 <indicates single character positions
9
[/font]
If the number is in a variable CurrentSource, the code I believe that will be necessary is:
Result := Format ('%-2S',[CurrentSource]);
However, when I run the code I get an exception:
Project SDLCOMP raised exception class 'EConvertError' with message
Invalid argument index in format "%-2S"
I have single quotes around the format string, even though Lazarus reports out the same string with double quotes!!
CurrentSource is an integer with a value of 1 (at the moment).
If I hover the cursor above a later part of the line, I get a note saying:
format('%-2S',[CurrentSource]) + '-'; =<Error: identifier not found "format" at start of expression>
This seems to indicate that the format function is not being found, which is strange since I used it a few lines back!
All the documentation in the rtl seems to indicate that I can only use the '%-2S' construct if I am formatting a string. Which raises the question:
Does Lazarus have any means (at all) of formatting a numeric value right justified with leading spaces?
I'm going to stop now while I still have some head left to beat against the brick wall tomorrow. Any suggestions, comments, pointers appreciated!
Thanks
Tony