Integer concatenation with macro

64 Views Asked by At

How to concatenate integer correctly with macro ? I must call it twice here because i can't add something after ","(error)

#define concat(a,b,c) a##b##c
dim as integer a=10,b=20,c=30,d
d = a concat(*100+,,)b
d = d concat(*100+,,)c
?d  'output = 102030
sleep
2

There are 2 best solutions below

1
nimday On BEST ANSWER

I found a solution from freebasic forum

#define concat(a,b,c)  (((a)*100+(b))*100+(c))
dim as integer a=10,b=20,c=30,d
d = concat(a,b,c)
?d  'output = 102030
sleep
0
Joe On
#define concat(a,b,c) val(str(a)+str(b)+str(c))