08-25-2022, 04:27 AM
(08-25-2022, 01:56 AM)mnrvovrfc Wrote: I had to write this function because it's near impossible to come up with a near-equivalent to "printf()" from C, because it could take at least two parameters. It became necessary to pad with zeroes at the front of an integer, such as giving serial numbers as filenames and making sure every single filename was the same number of characters.
Should have been able to do that "PRINT USING" trick saving to a temporary file only to enter its contents into a string, to pad an integer with zeroes, but not just with asterisks or spaces. :/
Sounds like what you wanted to do was something similar to this?
Code: (Select All)
Dim ss(8) As String
ss(1) = "One"
ss(2) = "Two"
ss(3) = "Three"
ss(4) = "Four"
ss(5) = "Five"
ss(6) = "Six"
ss(7) = "Seven"
ss(8) = "Eight"
Color 4, 1 'so we can see our spaces
For i = 1 To 8
Print PadBefore(ss(i), 8, "*"), PadAfter(ss(i), 8, "0")
Next
Function PadBefore$ (num$, digits, padding$)
p$ = num$
temp$ = String$(digits, padding$)
Mid$(temp$, digits - Len(p$) + 1) = p$
PadBefore$ = temp$
End Function
Function PadAfter$ (num$, digits, padding$)
p$ = num$
temp$ = String$(digits, padding$)
Mid$(temp$, 1) = p$
PadAfter$ = temp$
End Function