I would like to see these handle an additional PAD parameter. The new syntax being:
StringLeft, OutputVar, InputVar, Count, Pad
StringRight, OutputVar, InputVar, Count, Pad
NewStr := SubStr(String, StartPos [, Length[,Pad]])
StringRight, OutputVar, InputVar, Count, Pad
NewStr := SubStr(String, StartPos [, Length[,Pad]])
For the commands, when Count is greater than the length of InputVar, OutputVar would be padded to length of Count with n Pad characters. For StringRight, the padding would prefix the output variable.
For Substr(), when StartPos is negative and Length exceeds the number of characters available, the pad would PREFIX the output.
In all these cases, the implemention should probably allow Pad to be a string instead of single character.
Rationale:
a. This would be entirely backward compatible.
b. MSGBOX or a simple GUI of text is rather clumsy when it comes to displaying columnar data because of the inability (as far as I know) of defining tab stop positions. One could easily use a FIXED font and pad data fields to align nicely. (Yes, defining tab stops in GUIs would be awesome, but I suspect well beyond the scope of something so simple as my proposal!)
c. Yes, I can do something like this:
Code: Select all
var := "my string"
pad := "---------------------------------------------------------"
padded_var := substr(var . pad, length)