1. Convert a string to an integer

Hello, how does one convert a string to an int? Like typecasting?:

something like to_integer("34")

thx

new topic     » topic index » view message » categorize

2. Re: Convert a string to an integer

One way:

include std/convert.e 
atom x = to_number("1234") 
-- or 
integer x = to_integer("123") 

Another, slightly more work:

include std/get.e 
object x = value("1234") 
-- x will be a sequence of two numbers: {GET_SUCCESS,1234} 
if x[1] = GET_SUCCESS then x = x[2] end if 
new topic     » goto parent     » topic index » view message » categorize

3. Re: Convert a string to an integer

ok perfect thanks! convert.e is what I was looking for

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

Search



Quick Links

User menu

Not signed in.

Misc Menu