Dim orig As String = "1234567890"
Dim i As Integer = val(orig) // could make I a double as well since val wont overflow it anyway
Dim s As String = Format(i, "\(###\)###\-####")
format handles a lot of stuff easily
Dim orig As String = "1234567890"
Dim i As Integer = val(orig) // could make I a double as well since val wont overflow it anyway
Dim s As String = Format(i, "\(###\)###\-####")
format handles a lot of stuff easily
That’s pretty slick.
Format, the ancient API 1 function, is pretty versatile
Oh fer f sake
This won’t work for strings that start with zero
So use one of the other numeric place markers like 0 and be done with it
Dim orig As String = "1234567890"
Dim i As Integer = val(orig) // could make I a double as well since val wont overflow it anyway
Dim s As String = Format(i, "\(000\)000\ 0000")
Note I removed the - since the format I originally gave was a bit off
It seems wasteful to first convert string into number and then back to string using Format(). Can’t Xojo split strings into groups and use simple format string for formatting?
with 8th I would simply do something like:
[3,3,4] s:/ "(%s) %s %s" s:strfmt
Unpack functionality could also be used to do the string split:
"2:3b1:4b" unpack drop "(%s) %s %s" s:strfmt
Naturally input string should be validated first.
Split is accomplished with things like mid, left, right etc
Or a regex
And there is no “sprintf” like function