Re: int2str.e
- Posted by Pete Eberlein <xseal at HARBORSIDE.COM> Oct 25, 1997
- 904 views
Arthur Adamson wrote: > I needed to convert an integer to a string for using it in a file > name for instance. I overlooked it someplace imagine but I couldn't find any > built in function to do so. I wrote the following which handles the > problem...but tell me, is there a built in way? Thanks, Art Adamson > > --convert an int to a string > global function intToStr(integer tempInt) > sequence seqOut > seqOut = {} > while floor(tempInt) do > seqOut = prepend(seqOut, 48 + remainder(tempInt,10)) > tempInt = floor(tempInt / 10) > end while > return seqOut > end function --intToStr > > --puts(1,"The sequence returned is: ") > --? intToStr(1234) > --puts(1,intToStr(1234)) > Arthur P. Adamson, The Cincinnati Engine Man, euclid at isoc.net Did you try sprintf? --puts(1,"The sequence returned is: ") --? sprintf("%d",{1234}) --puts(1,sprintf("%d",{1234})) It does hex and floating point too. -- _____ _____ _____ ________ /\ \ /\ \ /\ \ / \ \ / \____\ / \____\ / \____\ / _ \____\ / / ___/_ / /____/ / / ___/_ / / \ [___] / / /\____\ / \ \ / / /\____\ \ \_/ / / \ \/ / ___/_\ \ \ \ \/ / ___/_ \ /____/ \ / /\ \\/\ \ \ \ / /\ \ \ \ \ \ \/ \____\ \ \ \ \ \/ \____\ \ \ \ \ / / \ \____\ \ / / \ \____\ \ / / \ / / \ / / \ / / \ / / \/____/ \ / / \/____/ \/____/xseal at harborside.com\/____/