Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
#definefunction toBase(num,base,width) terminate(vartype(num)<>1,"toBase","num must be integer") terminate(vartype(base)<>1,"toBase","base must be integer") terminate(vartype(width)<>1,"toBase","width must be integer") terminate(base<2 || base>36,"toBase","base must be 2-36") b = "" while num>0 b = strcat(strsub("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ",num mod base+1,1), b) num = int(num / base) endwhile if b == "" then b = "0" if width > 0 then b = strfixleft(b, "0", width) return b #endfunction #definefunction fromBase(str,base) terminate(vartype(str)<>2,"fromBase","str must be string") terminate(vartype(base)<>1,"fromBase","base must be integer") terminate(base<2 || base>36,"fromBase","base must be 2-36") b = 0 while str>"" x = strindex("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ",strsub(str,1,1),1,0) if x == 0 || x > base then return -1 b = b * base + (x - 1) str = strsub(str, 2, -1) endwhile return b #endfunction
Article ID: W15331
File Created: 2002:09:05:13:51:22
Last Updated: 2002:09:05:13:51:22