1. Inputting Something without ''
- Posted by Alan Tu <ATU5713 at COMPUSERVE.COM>
May 23, 1998
-
Last edited May 24, 1998
I'm improving a program that launches another program with a parameter. =
I
use a function to prompt for a parameter. The external program's
parameters are strictly integers (the parameter of the track of the CD yo=
u
want to play).
I discovered that if I enter 7, Euphoria passes on ASCII 7 to the program=
,
which doesn't make sense of course. If I type '7' at my prompt the
program, as I expected, plays track 7. Well, I don't want to type the
quotes. I just want to type say 7 and have Euphoria pass on '7', how do =
I
remedy this?
--Alan
=
2. Re: Inputting Something without ''
- Posted by Robert Gould <robgo1 at ENID.COM>
May 23, 1998
-
Last edited May 24, 1998
Alan Tu wrote:
>
> I'm improving a program that launches another program with a parameter. I
> use a function to prompt for a parameter. The external program's
> parameters are strictly integers (the parameter of the track of the CD you
> want to play).
>
> I discovered that if I enter 7, Euphoria passes on ASCII 7 to the program,
> which doesn't make sense of course. If I type '7' at my prompt the
> program, as I expected, plays track 7. Well, I don't want to type the
> quotes. I just want to type say 7 and have Euphoria pass on '7', how do I
> remedy this?
>
> --Alan
>
Have you tried creating a string file with the '#' s as values and then
doing a gets() ?
This should give you what you need.
Respectfully,
Robert
P.S. If I'm wrong please let me know. :)
3. Re: Inputting Something without ''
- Posted by Irv <irv at ELLIJAY.COM>
May 23, 1998
-
Last edited May 24, 1998
At 08:43 PM 5/23/98 -0400, Alan Tu wrote:
>I discovered that if I enter 7, Euphoria passes on ASCII 7 to the >program
>which doesn't make sense of course.
>
>--Alan
> =
>
include get.e
sequence s
atom i
puts(1,"Track:")
s = gets(0)
s = value(s) -- convert string into a 2-element sequence
i = s[2] -- s[1] is GET_SUCCESS/FAILURE
-- s[2] is the numeric value you typed.
Irv
4. Re: Inputting Something without ''
- Posted by mountains at MINDSPRING.COM
May 23, 1998
-
Last edited May 24, 1998
At 10:47 PM 5/23/98 -0400, you wrote:
Oops! I mis-read the question. Sorry.
The method below will write a single byte to a disk file, 0 to 255,
which should be enough to select any CD track!
include get.e
sequence s
atom fn
atom i
puts(1,"Track:")
s = gets(0)
s = value(s) -- convert to an integer value
i = s[2] -- discard the GET_SUCCESS...
fn = open("TEST.NNN","w")
puts(fn,i) -- write the byte to disk
close(fn)
fn = open("TEST.NNN","r")
i = getc(fn) -- read one character from the disk as an integer
printf(1,"I is %d",i)
close(fn)
Hope this helps,
Irv
5. Re: Inputting Something without ''
Irv,
I just read your latest post. Do I really have to create another file? =
Here's the algorithm I'd like to use.
1. input integer.
2. Convert to ASCII sequence.
3. system command line & space & ascii sequence.
Can Euphoria do that? (G)
--Alan
=
6. Re: Inputting Something without ''
maybe I'm misreading, but this sounds like a job for sprintf(), not
value(), to translate before passing the input on.
7. Re: Inputting Something without ''
At 12:38 AM 5/24/98 -0400, Alan Tu wrote:
>Here's the algorithm I'd like to use.
>
>1. input integer.
>2. Convert to ASCII sequence.
>3. system command line & space & ascii sequence.
>
>Can Euphoria do that? (G)
>
sequence track
sequence cmd
-- assume I enter a 7 each time (no quotes):
track = gets(0) -- this creates COMMAND 7
cmd = sprintf("COMMAND %s",track)
puts(1,cmd)
track = gets(0) -- this creates COMMAND 55
cmd = sprintf("COMMAND %d",track)
puts(1,cmd)
Does either of these do what you want?
Irv
8. Re: Inputting Something without ''
>I'm improving a program that launches another program with a
>parameter.
>I use a function to prompt for a parameter. The external program's
>parameters are strictly integers (the parameter of the track of the CD
>you want to play).
>
>I discovered that if I enter 7, Euphoria passes on ASCII 7 to the
>program, which doesn't make sense of course. If I type '7' at my
>prompt the program, as I expected, plays track 7. Well, I don't
>want to type the quotes. I just want to type say 7 and have Euphoria
>pass on '7', how do I remedy this?
Sounds like you are using get(). Try using gets() instead. get() is
reading 7 as 7, and returning the number 7. When you give get() '7', it
takes the ASCII value of the character 7 and returns it. gets()
automatically returns a sequence that contains the ASCII values of what
you entered. (Which is what you want.)
sequence test
puts(1, "Enter in track number: ")
test = gets(0)
test = test[1..length(test)-1]
-- If you entered 7, then test will contain: {'7'}, or "7". This sounds
like
-- what you want.
_____________________________________________________________________
You don't need to buy Internet access to use free Internet e-mail.
Get completely free e-mail from Juno at http://www.juno.com
Or call Juno at (800) 654-JUNO [654-5866]
9. Re: Inputting Something without ''
Boy, how one letter can make a different. I belive I was using get,
instead of gets. Thanks.
Regards,
Alan
=