Re: HELP! scope or interpreter problem (I think) with include files

new topic     » goto parent     » topic index » view thread      » older message » newer message
jessedavis said...

... have numerous problems with include files like map.e, prime.e, etc. The error message says that a value internal to the include file has not been initialized. I look at the include code and the variable has clearly been set. Any thoughts as to what I am doing incorredtly ...

Here is some sample code that will give the error message you mentioned...

object x = next_prime(1000) 
include std/primes.e 


will give us ...

c:\projects\eu_proj\eu40\include\std\primes.e:187 in function next_prime() 
variable list_of_primes has not been assigned a value 
 
... called from c:\temp\test.ex:2 
 
--> See ex.err 
The problem is that you are using a function before the file the declares that function is included, and that included file needs to do some initialization before it can be used.

The workaround is to move the include statement to somewhere before the first use of any of its routines. eg...

include std/primes.e 
object x = next_prime(1000) 

As a general principle, always put your include files near the top of your application code, before your code executes any routine from the included files.

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu