Re: Bugs (my program, not yours)
At 05:35 PM 6/3/98 -0400, you wrote:
>Hello all -
>
>Euphoria at times can be very confusing.
>
>I have written a program and am now trying to make it run.
>Here are some segments from the program:
>
include get.e -- added by Irv to enable the get()
object hcopy, outspec, x -- added by Irv to make it work for testing
clear_screen()
--kb = open("CON","r") -- you don't need this - device 0 IS the kbd!
puts(1,"Do you want hard copy? - y/n\n")
--hcopy = getc(kb) -- try instead getc(0)
hcopy = getc(0) -- this is easier
puts(1,"Specify output... ")
--outspec = getc(kb)
outspec = getc(0) -- easier
puts(1,"Number to be analyzed\n")
puts(1,"Enter 0 to end program\n")
--x = gets(kb) -- gets() gets a string, you want a number
x = get(0) -- use get() to get a number
if x[1] = GET_SUCCESS
then x = x[2] -- checks for a good input
else x = 0
end if
if x = 0 then
abort(0)
end if
>
>Today (Wednesday) it's hanging up on 'gets'. The sequence entered from the
>keyboard ends when I press the 'return' key. If I enter two numeric digits,
>which should be a two-element sequence, and press the 'return' key, the
>program hangs up again. (The program should be able to handle any input up
>to a billion or so, the top of Euphoria's normal range.) 'ex.err' says the
>sequence has three elements, the third one being an extra 'line feed'
>character (ASCII 10).
---------------------------------------------------------------
When you read in a string, you always get a 10 at the end.
Nothing to do with keyboard bounce.
---------------------------------------------------------------
This happens repeatedly, even when I press the
>'return' key *very* gently, to prevent its possible 'bouncing'.
>
>The manual says x should be declared as an object, so that x can be either
>an atom or a sequence. I had x defined as an atom; I changed it to an
>object. That made the program hang up on the very next statement, 'if x = 0
>then abort(0)'. Euphoria says x must be an atom.
>
>Like Hamlet, Euphoria apparently can't make up its mind.
>
>What's going on here?
-----------------------------------------------------------------
To quote from the manual:
get - input from file fn, a human readable string of characters
representing a Euphoria object. Convert the string into
the numeric value of that object. s will be a 2-element
sequence {error status,value}.....
------------------------------------------------------------------
It's just a matter of using the right command. Nothing to be
ashamed of here, this is the hardest part of Euphoria to
grasp, because it is different from what we're used to.
There is some sound reasoning behind the way RDS did this,
however.
I think.
Irv
|
Not Categorized, Please Help
|
|