1. command_line() - convert a sequence to an atom value?
- Posted by heyjoel at mindspring.com Aug 14, 2001
- 407 views
I want to convert my program from prompting for user input to including this input on the command line. I have used the command_line() function to do so, but have come across a small problem. If my program prompts the user for the data from within the program: Enter the data : 30 then then value 30 can be stored as an atom as declared. But command_line() returns a sequence with the value {51,48} which cannot be stored in my nice little atom. So, I am looking at reworking my code to treat everything as a sequence, but it would be a whole lot nicer if there happens to be a way of storing the numerical value of the command_line() sequence {51,48} as 30 in my atom. Any ideas? Joel Garcia
2. Re: command_line() - convert a sequence to an atom value?
- Posted by euman at bellsouth.net Aug 14, 2001
- 370 views
CK presents one method or you can use something like this which is ultra fast, address = allocate(256) -- 'warning' only 256 bytes can be used mem_set(address, 0, 256) poke your value staring at 'address' location and then you can peek the value from 'address' later when its needed again. if you have some code, I could help you modify it some to work like this. Euman euman at bellsouth.net > I want to convert my program from prompting for user input to including this > input on the command line. I have used the command_line() function to do > so, but have come across a small problem. > > If my program prompts the user for the data from within the program: > Enter the data : > 30 > then then value 30 can be stored as an atom as declared. > > But command_line() returns a sequence with the value {51,48} which cannot be > stored in my nice little atom. > > So, I am looking at reworking my code to treat everything as a sequence, but > it would be a whole lot nicer if there happens to be a way of storing the > numerical value of the command_line() sequence {51,48} as 30 in my atom. > > Any ideas? > > Joel Garcia
3. Re: command_line() - convert a sequence to an atom value?
- Posted by euman at bellsouth.net Aug 14, 2001
- 384 views
CK presents one method or you can use something like this which is ultra fast, address = allocate(256) -- 'warning' only 256 bytes can be used mem_set(address, 0, 256) poke your value staring at 'address' location and then you can peek the value from 'address' later when its needed again. be sure to free the allocated space when your finished with the data contained in 'address' useing free(address) if you have some code, I could help you modify it some to work like this. Euman euman at bellsouth.net > I want to convert my program from prompting for user input to including this > input on the command line. I have used the command_line() function to do > so, but have come across a small problem. > > If my program prompts the user for the data from within the program: > Enter the data : > 30 > then then value 30 can be stored as an atom as declared. > > But command_line() returns a sequence with the value {51,48} which cannot be > stored in my nice little atom. > > So, I am looking at reworking my code to treat everything as a sequence, but > it would be a whole lot nicer if there happens to be a way of storing the > numerical value of the command_line() sequence {51,48} as 30 in my atom. > > Any ideas? > > Joel Garcia
4. Re: command_line() - convert a sequence to an atom value?
- Posted by Chris Bensler <bensler at telus.net> Aug 14, 2001
- 401 views
I usually use thing code when I need to convert a sequence to a number value. It's faster than value(), and you don't have to include get.e This only takes care of whole numbers, but it could easily be modified for decimal values. If you want to use scientific notation, or hex values it's easier to just use value(). Chris --CODE sequence cmd_line cmd_line=command_line() if length(cmd_line)<3 then abort(1) end if -- no param atom val val=0 for i=1 to length(cmd_line[3]) do if cmd_line[3][i]<'0' or cmd_line[3][i]>'9' then abort(1) end if -- not a number val=val*10+cmd_line[3][i] end for --END CODE ----- Original Message ----- From: <heyjoel at mindspring.com> To: "EUforum" <EUforum at topica.com> Sent: Tuesday, August 14, 2001 8:26 PM Subject: command_line() - convert a sequence to an atom value? > > I want to convert my program from prompting for user input to including this > input on the command line. I have used the command_line() function to do > so, but have come across a small problem. > > If my program prompts the user for the data from within the program: > Enter the data : > 30 > then then value 30 can be stored as an atom as declared. > > But command_line() returns a sequence with the value {51,48} which cannot be > stored in my nice little atom. > > So, I am looking at reworking my code to treat everything as a sequence, but > it would be a whole lot nicer if there happens to be a way of storing the > numerical value of the command_line() sequence {51,48} as 30 in my atom. > > Any ideas? > > Joel Garcia > > > > > >