1. bug in the dos32 version?

I made a (very) simple program to just collect data, like stuff that would
be in an address book. Menu driven, and very basic. The problem is that
after entering two records in, everything has an extra carriage return
after it. I couldn't figure out why it was happening, and then I tried
running the file with exw.exe and the problem went away, so I assume it's
a bug in the Dos32 version. If this is a known bug, I'm sorry to bother
you, but if you didn't know about it I'll be happy to send you the code.
Also, is it just me, or are you supposed to access variables from
inside a procedure that you want to be changed when you exit the
procedure 'globally'? i.e. you don't put the variables in the parameter
list? Thanks for your help.

Keith

new topic     » topic index » view message » categorize

2. Re: bug in the dos32 version?

-----Original Message-----
De: Keith B. Devens <Keith83 at SPRYNET.COM>
Para: EUPHORIA at cwisserver1.mcs.muohio.edu
<EUPHORIA at cwisserver1.mcs.muohio.edu>
Fecha: viernes 22 de mayo de 1998 15:40
Asunto: bug in the dos32 version?


>I made a (very) simple program to just collect data, like stuff that would
>be in an address book. Menu driven, and very basic. The problem is that
>after entering two records in, everything has an extra carriage return
>after it. I couldn't figure out why it was happening, and then I tried
>unning the file with exw.exe and the problem went away, so I assume it's
> bug in the Dos32 version. If this is a known bug, I'm sorry to bother
>you, but if you didn't know about it I'll be happy to send you the code.

Send the code and I'll check it. Without some code (or pseudo code) it's
difficult to determine if it's an algorithmic, programming or interpreter
error.

>Also, is it just me, or are you supposed to access variables from
>inside a procedure that you want to be changed when you exit the
>procedure 'globally'? i.e. you don't put the variables in the parameter
>list? Thanks for your help.

Do you mean like Pascal VAR parameters? No. If you want your variable data
to be persistant among calls you must declare it OUTSIDE and before the
procedure declaration. This makes your variable in-scope (declare it as
global and it will never loose scope) when the procedure is called.

Ex1:
    procedure myproc()
        integer x
        -- do something with 'x'...
    end procedure

    Each time myproc() is called, the value of 'x' is reseted. And when the
procedure ends, 'x' no longer exists.

Ex2:
    procedure myproc()
        -- do something with 'x'...
    end procedure
    integer x

    Euphoria will signal an error message. Variable 'x' isn't in scope
inside of myproc().

Ex3:
    integer x
    procedure myproc()
        -- do something with 'x'...
    end procedure

    Variable 'x' is in scope within myproc() and also is persistant. Variabl
e 'x' is accesible from other functions/procedures as well (if they are
declared AFTER variable 'x').

Ex4:
    integer x
    procedure myproc()
        integer x
        -- do something with 'x'...
    end procedure

    Here Euphoria resolves the conflict by using myproc() LOCAL 'x'
variable. As a result the outside variable 'x' isn't used/changed by
myproc().


Please correct me if my examples/descriptions are wrong.

Regards,
    Daniel Berstein
    daber at pair.com

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

3. Re: bug in the dos32 version?

At 02:05 AM 5/22/98 -0500, Keith B. Devens emitted a stream
of bits that resembled:

>Also, is it just me, or are you supposed to access variables from
>inside a procedure that you want to be changed when you exit the
>procedure 'globally'? i.e. you don't put the variables in the parameter
>list? Thanks for your help.
>

Generally (just my opinion) it is good programming practice to
have very few to zero global variables. That makes it easier
to re-use your code modules, and makes tracking down
bugs easier as well. Especially with long programs.

Actually, working in an object-oriented manner is even
better.

Irv

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

4. Re: bug in the dos32 version?

--Message-Boundary-3417
Content-type: text/plain; charset=US-ASCII
Content-description: Mail message body

oh man, sorry. I forgot to attach the code to the second e-mail. I'm
sorry, I'm tired. It's too late. Anyway, here it is.

Keith


--Message-Boundary-3417
Content-type: text/plain; charset=US-ASCII
Content-description: Text from file 'Test.ex'

include get.e

constant Name = 1
constant Address = 2
constant Phone = 3

atom menunum

sequence client
sequence clientel

clientel= {}

--------------------------------------------------------------------------
procedure readclient ()

client = {Name, Address, Phone}

puts (1, "Enter the Name: ")
 client[Name] = gets(0)
 client[Name] = client[Name][1..length(client[Name])-1]
puts (1, '\n')
puts (1, "Enter the Address: ")
 client[Address] = gets(0)
 client[Address] = client[Address][1..length(client[Address])-1]
puts (1, '\n')
puts (1, "Enter the Phone Number: ")
 client[Phone] = gets(0)
 client[Phone] = client[Phone][1..length(client[Phone])-1]
puts (1, "\n\n")
end procedure
--------------------------------------------------------------------------
procedure putclient(sequence client)
 clientel = append(clientel, client)
end procedure
--------------------------------------------------------------------------
procedure printclientel(sequence clientel)

if length(clientel) = 0 then
    puts (1, "The client list is empty.\n")
else
puts (1, "Name                    Address                            Phone\n")

for clientcount = 1 to length(clientel) do
    puts (1, clientel[clientcount][Name])
        for temp = 1 to 24-(length(clientel[clientcount][Name])) do
            puts (1, ' ')
        end for
    puts (1, clientel[clientcount][Address])
        for temp = 1 to 35-(length(clientel[clientcount][Address])) do
            puts (1, ' ')
        end for
    puts (1, clientel[clientcount][Phone])
puts (1, '\n')
end for
end if
puts (1, '\n')
end procedure
--------------------------------------------------------------------------
procedure menu()
object input
puts(1, "Enter 1 to Enter a new client\n" &
        "Enter 2 to Delete a client\n" &
        "Enter 3 to Print the client list\n" &
        "Enter 4 to exit the program\n\n" &
        "Enter now: ")

input = get(0)
menunum = input[2]

puts (1, "\n\n")

end procedure
--------------------------------------------------------------------------
procedure clearclientel()
    clientel = {}
    puts (1, "The client list has been cleared.\n\n")
end procedure
--------------------------------------------------------------------------

menunum = 0
while menunum != 4 do
menu()
if menunum = 1 then
    readclient()
    putclient(client)
elsif menunum = 2 then
    clearclientel()
elsif menunum = 3 then
    printclientel(clientel)
end if
end while
--Message-Boundary-3417--

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

5. Re: bug in the dos32 version?

Keith wrote:
> I made a (very) simple program to just collect data, like
> stuff that would be in an address book. Menu driven, and very
> basic. The problem is that after entering two records in,
> everything has an extra carriage return after it. I couldn't figure out
> why it was happening, and then I tried running the file
> with exw.exe and the problem went away,
> so I assume it's a bug in the Dos32 version.

I tried your program. It worked fine except for the
extra line feed created when the user hits Enter on the
last line of the screen and DOS scrolls the screen.
It doesn't happen with exw.
It's a "feature" of DOS that has been reported
to me before. I don't plan to change Euphoria to
compensate for it. You can use position() if you
really have to control the line spacing.

Regards,
     Rob Craig
     Rapid Deployment Software

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

Search



Quick Links

User menu

Not signed in.

Misc Menu