Re: value()

new topic     » goto parent     » topic index » view thread      » older message » newer message

On Tue, 18 Feb 2003 01:18:12 +0000, Pete Lomax <petelomax at blueyonder.co.uk> 
wrote:

>
> Hey gang blink,
>
> trying to parse STR, value(STR) is returning {GET_SUCCESS, SOMEVAL}.
>
> 1) is there any way to tell how much of STR value() "ate"?

Not with value() there isn't. I've written a convert-to-number routine tha 
does tell you this info. I can mail it if you like.

> 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!

  sequence x
  if integer(SOMEVAL) then
	x = sprintf("%d", SOMEVAL)
  else
      x = sprintf("%15.15f",SOMEVAL)
      -- Remove trailing zeros.
      for i = length(x) to 1 by -1 do
       if x[i] != '0' then
         exit
       end if
       x = x[1..i-1]
      end for
  end if




-- 

cheers,
Derek Parnell

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu