consoleintegerbasicfreebasic

Integer concatenation with macro


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

Solution

  • 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