1. simple question (using euphoria 1.4)

--------------0FDD5D813B7FC9FFF346C6CF

please open the attachment to see my question about using "include"
inside a loop.  an attachment was the only way i could figure out how to
import text into a netscape email message.

please note that i am using euphoria 1.4, if that makes any difference.

thanks

joe


--------------0FDD5D813B7FC9FFF346C6CF
 name="question.txt"
Content-Disposition: inline;
 filename="question.txt"

i have been working on a program for some time now and have gotten to a point
where it needs a basic
redesign in order to be more easily maintained.

------------------------------------------------------------------

what i am doing now (with 8 functions instead of just two) :

function FirstFunction(parameter list)
        do stuff
        return value
        end function

function SecondFunction(parameter list)
        do stuff
        return value
        end function

while NotEndProgram
        FirstFunction(parameter list)
        do processing here
        SecondFunction(parameter list)
        do more processing here
        end while

this works but is almost 600 lines long and is quite difficult to maintain and
modify.  however, it does
work and allow the program to loop (requesting data, doing calculations, etc)
until i decide to stop it.

------------------------------------------------------------------

what i have managed to do so far :

include FirstFunction.ex
do processing here
include SecondFunction.ex
do more processing here
etc.

with FirstFunction, SecondFunction, and others in separate files.  this allows
me to have the functions
in separate files, and call them.  unfortunately, it runs only once and then
stops.  if i want to enter
more data to be processed, i have to start the program over again.

------------------------------------------------------------------

what i would like to do :

while NotEndProgram do
        include FirstFunction.ex
        do processing here
        include SecondFunction.ex
        do more processing here
        end while

with FirstFunction, SecondFunction, and others in separate files. 
unfortunately, euphoria doesn't seem
to like "include" inside a while loop.  is there any way around this, that
allows the program to loop and
still have the functions in separate files?

thanks




--------------0FDD5D813B7FC9FFF346C6CF--

new topic     » topic index » view message » categorize

2. Re: simple question (using euphoria 1.4)

I'm guessing that you're moving the body of the functions into seperate
include files so they run automatically when they are included. You could try
putting the whole function in the include files, include the files once,  then
call the functions. You can't put include statements in a loop, and once
you've included a file, it doesn't run the next time you include it. For
example:

-- a.e
puts(1,"Hello, world!\n")

-- a.ex
include a.e
include a.e

If you run a.ex, it will display Hello, world! only once, since the
interpreter recognizes that a.e has already been included, and therefore
doesn't load it again.

Jeffrey Fielding
JJProg at cyberbury.net
http://members.tripod.com/~JJProg/

EUPHORIA at LISTSERV.MUOHIO.EDU wrote:

> please open the attachment to see my question about using "include"
> inside a loop.  an attachment was the only way i could figure out how to
> import text into a netscape email message.
>
> please note that i am using euphoria 1.4, if that makes any difference.
>
> thanks
>
> joe
>
>   ------------------------------------------------------------------------
>                    Name: question.txt
>    question.txt    Type: Plain Text (text/plain)
>                Encoding: 7bit

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

3. Re: simple question (using euphoria 1.4)

>joe you wrote:
>i have been working on a program for some time now and have gotten to a
point where it needs a basic
>redesign in order to be more easily maintained.
>------------------------------------------------------------------
>what i am doing now (with 8 functions instead of just two) :

Joe: maybe this will help

global constant
  forever = -1,
  TRUE    = -1,
  FALSE   =  0

global atom endofprogram
  endofprogram = FALSE

function FirstFunction(parameter list)
  do stuff
  -- to exit set endofprogram = TRUE
  return value
end function

function SecondFunction(parameter list)
  do stuff
  -- to exit set endofprogram = TRUE
  return value
end function

while forever do
  FirstFunction(parameter list)
  if endofprogram then exit end if
  SecondFunction(parameter list)
  if endofprogram then exit end if
end while

finish up here


Bernie

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

4. Re: simple question (using euphoria 1.4)

On Sun, 12 Dec 1999, Joe wrote:
> >%_please open the attachment to see my question about using "include"
> inside a loop.  an attachment was the only way i could figure out how to
> import text into a netscape email message.
>
> please note that i am using euphoria 1.4, if that makes any difference.
>

You can put the functions into separate include files, and call them as often
as you want from a loop:

-- file hello.e
global function sayHello() -- note: these could be procedures,
puts(1,"Hello\n")             -- since in this example they don't
return 0                         -- return anything useful
end function

-- file goodbye.e
global function sayBye()
puts(1,"Bye Now\n")
return 0
end function

-- file boorring.exu
include hello.e
include goodbye.e

integer x
while 1 do -- this will run forever, hence the name
  x = sayHello()
  x = sayBye()
end while

Hope that helps,
Irv Mullins

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

Search



Quick Links

User menu

Not signed in.

Misc Menu