macros for fixed length string from integer, or short string
Posted: Fri Jan 29, 2021 10:29 pm
Three simple macros (again just to save typing/typos) to create a string of a fixed length whatever the size or length of the integer/string fed in.
This helps to create a neat and tidy lay out when writing data to a file or in simple printing. The source code does not look as messy, either!
NB There is no check to make sure the fixed length is actually long enough, it is assumed the user knows the range of the input.
This helps to create a neat and tidy lay out when writing data to a file or in simple printing. The source code does not look as messy, either!
NB There is no check to make sure the fixed length is actually long enough, it is assumed the user knows the range of the input.
Code: Select all
;2021-01-24 new
;macro to deliver integer right-justified in fixed length string
;i is the integer and n the fixed length
Macro UStrX(i, n)
Right(Space(n) + Str(i), n)
EndMacro
;2021-01-27 new
;macro to deliver string left justified in fixed length string
;st is the string and n the fixed length
Macro UStrLS(st,n)
Left(st + Space(n), n)
EndMacro
;2021-01-27 new
;macro to deliver string right-justified in fixed length string
;st is the string and n the fixed length
Macro UStrS(st, n)
Right(Space(n) + st, n)
EndMacro