Re: value()
- Posted by Robert Elia <bobelia200 at netzero.net> Feb 18, 2003
- 423 views
--=======1E037A3F======= At 01:18 AM 2/18/03 +0000, you wrote: > >Hey gang , > >trying to parse STR, value(STR) is returning {GET_SUCCESS, SOMEVAL}. > >1) is there any way to tell how much of STR value() "ate"? > >2) what is the simplest way to get SOMEVAL as returned back from >value() into a character string again? I'll do it if I have to, no >worry, but there just *must* be a better way than puts(fn,SOMEVAL) and >reading it back in again! > >Pete Regarding point 2): Use x = sprintf( "%d", {SOMEVAL} ). Right from the manual: SYNTAX: s = sprintf(st, x) DESCRIPTION: This is exactly the same as printf(), except that the output is returned as a sequence of characters, rather than being sent to a file or device. st is a format string, x is the value or sequence of values to be formatted. printf(fn, st, x) is equivalent to puts(fn, sprintf(st, x)). COMMENTS: Some typical uses of sprintf() are: 1. Converting numbers to strings. 2. Creating strings to pass to system(). 3. Creating formatted error messages that can be passed to a common error message handler. EXAMPLE: s = sprintf("%08d", 12345) -- s is "00012345" SEE ALSO: printf, value, sprint, get, system Bob --=======1E037A3F======= Content-Type: text/plain; charset=us-ascii; x-avg=cert; x-avg-checked=avg-ok-C6F1758 Content-Disposition: inline --- --=======1E037A3F=======--