Integer to String
- Posted by Eduardo Uemura Okada <cool at MII.NUTECNET.COM.BR> Jan 03, 1998
- 824 views
Hi to everyone, happy new year! I'm actually working on a demo of a battle of my RPG, so I neede a routine to convert an integer to a string, the way I found was this, but if anyone knows a faster way, please, send me. Thank you -- Code starts here global function int_to_str(atom data) sequence to_return integer temp,length atom filenumber if data>=0 then if data<=9 then length=1 end if end if if data>=10 then if data<=99 then length=2 end if end if if data>=100 then if data<=999 then length=3 end if end if if data>=1000 then length=4 end if to_return={} filenumber=open("temp.tmp","w") print(filenumber,data) close(filenumber) filenumber=open("temp.tmp","r") for times=1 to length do temp=getc(filenumber) to_return=append(to_return,temp) temp=0 end for close(filenumber) system("del temp.tmp",2) return to_return end function