You could simply have done this to convert from decimal to binary:
DelVar ADelVar DDelVar Z
D is the number in decimal, A is the answer in binary. 1+iPart(log(D)/log(2 is used to calcule how many time you need to divide by 2 for the loop while 10^(Z-1)*2fPart(D/2)+A→A store 1 or 0 for this step in A . iPart(D/2→D divides the number in Decimal to calculate the next step..
I know its not fully optimized cause i'm not an expert in optimization but your program was way too big for a binary converter.
With this routine, you can also substitute the number 2 for the number you want or even a variable to have a converter in the base you want like in octodecimal.