Posts: 1,000
Threads: 253
Joined: Feb 2008
Once again I've got my little hack way of doing this...but I want to see if there is a nice easy QM way that I missed in the help file
Program saves files with this number suffixed on the file name:
00-99 (just formatted with leading zero)
but then:
100 is outputted as "a0"
101 = a1
102 = a2
...
110 = b0
120 = c0
up to 159 =f9
Posts: 58
Threads: 19
Joined: Mar 2005
nothing fancy, probably similar to your method
Macro
str s = "9"
if s.len > 2
,str s2.get(s 1 1)
,s2[0] = ('a' + val(s2))
,s.replace(s2 0 2)
else
,if s.len < 2
,,s - "0"
out s
Posts: 11,929
Threads: 138
Joined: Dec 2002
If need only < 160
Macro
Macro1267
out
int i
for i 0 160
,str s.format("%x%i" i/10 i%10)
,out s
,
%x formats hexadecimal number, 0 to f.
Posts: 1,000
Threads: 253
Joined: Feb 2008
Exactly what I need.
Function
Function54
out
int i=122
str s.format("%x%i" i/10 i%10)
out s
I didn't think of dividing by 10 like that and then didn't know you could grab 10%...nice work.
Thanks,
Jimmy Vig
Posts: 1,000
Threads: 253
Joined: Feb 2008
int Cart=75321
int Cut=100
str sCart.format("N:\%07i%x%i.wav" Cart Cut/10 Cut%10)
out sCart
I don't know if this can be done, but can the length of the format be a variable?
Like in the example above...if I want the length to be 7 places with leading zeros, can I use a variable to format?
Posts: 11,929
Threads: 138
Joined: Dec 2002
Call format() 2 times. At first format "N:\%07i%x%i.wav", then use it in the next format() as first argument. Or use from().
int Cart=75321
int Cut=100
str sCart.format(_s.from("N:\%0" 7 "i%x%i.wav") Cart Cut/10 Cut%10)
out sCart
Posts: 1,000
Threads: 253
Joined: Feb 2008
Thanks. Exactly what I need!