1. likely value() error!

I have the following program:

include get.e
sequence s
object x
s =3D "1,234"
x =3D value(s)
? x[1] =3D GET_SUCCESS
? x

I get the following output:

1
{0,1}

Now, I wrote this program to see what would happen if I tried to convert =
a
number like 1,234 i.e, with a comma.  Not only did it not convert propert=
y,
but the error code was GET_SUCCESS.  Hmmm.

Alan
  =

new topic     » topic index » view message » categorize

2. Re: likely value() error!

Looking at get.e, it seems that commas are legal delimiters for Euphoria =
objects represented in a string (to simplify the code, I imagine). The =
'value' function is interpreting everything up to the ',' which means =
all it sees is "1". Replacing the string with "123,456" yields a value =
of 123.

This is an interesting fluke, I'm surprised it hasn't been noticed yet =
(perhaps it's just not considered a fluke...) Does anyone know if this =
has been addressed in 2.1? (I'm only using the 2.1 interpreter, I =
haven't copied the 2.1 include files into my working directory yet.)


Rod Jackson=20

----------
From:   Alan Tu[SMTP:ATU5713 at compuserve.com]
Sent:   Friday, March 12, 1999 11:31 AM
To:     EUPHORIA at LISTSERV.MUOHIO.EDU
Subject:        likely value() error!

I have the following program:

include get.e
sequence s
object x
s =3D "1,234"
x =3D value(s)
? x[1] =3D GET_SUCCESS
? x

I get the following output:

1
{0,1}

Now, I wrote this program to see what would happen if I tried to convert =
a
number like 1,234 i.e, with a comma.  Not only did it not convert =
property,
but the error code was GET_SUCCESS.  Hmmm.

Alan
 =20

new topic     » goto parent     » topic index » view message » categorize

3. Re: likely value() error!

>Now, I wrote this program to see what would happen if I tried to convert a
>number like 1,234 i.e, with a comma.  Not only did it not convert property,
>but the error code was GET_SUCCESS.  Hmmm.

Yes, it is a succes: it was able to succesfully 'get' a value from the string
you gave.
Example:

s = "4 Pizzaman"
? value (s)

-- Displays:  { 4, GET_SUCCES }
-- (well actuall, instead of GET_SUCCES it displays the value which is
represented by that constant)

Now, Im guessing, you wanted it to do something else with the given string. I
came up with two alternative interpretations of
the string:

    - you wanted to 'get' two values seperated by a comma in sequence-form:
      Insert this before your 'value (s)' statement.....
                                                            s = '{' & s '}'

    - you wanted to 'get' the value 1.234 as one floating point value:
(a comma is the european alternative to seperate the floating point part
     from the integer value)
     Insert this before your 'value (s)' statement.......
s = (s != ',' * s)  + (s = ','
                                                 * ',')

Im quite sure, this helps you out, if not, try to explain what you *wanted* it
to return in more detail...

Ralf Nieuwenhuijsen
nieuwen at xs4all.nl
ralf_n at email.com
UIN: 9389920

new topic     » goto parent     » topic index » view message » categorize

4. Re: likely value() error!

At 01:55 PM 12-03-1999 , you wrote:
>Looking at get.e, it seems that commas are legal delimiters for Euphoria
objects represented in a string (to simplify the code, I imagine). The
'value' function is interpreting everything up to the ',' which means all
it sees is "1". Replacing the string with "123,456" yields a value of 123.
>
>This is an interesting fluke, I'm surprised it hasn't been noticed yet
(perhaps it's just not considered a fluke...) Does anyone know if this has
been addressed in 2.1? (I'm only using the 2.1 interpreter, I haven't
copied the 2.1 include files into my working directory yet.)

Quite nasty bug!

I wonder why it ain't catched as GET_FAIL?

If s="{1,234}" it does correctly identify the 2 elemet sequence.


Regards,
         Daniel  Berstein
         [daber at pair.com]

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu