Problem with private


Indy500

Recommended Posts

I'm trying to create a number of private variables with this code:

System.SequencePrint = 1
for (private i=1, i<=5, i++)
   execute("private sent"+i+" = 0")
endfor

? sent3

When I execute this, I get the following error on the "? sent3" line and I'm not sure why:

C1000 Channel or function not found: Test Line 6 - Uncaught error in sequence Test

Thanks!

-David

Link to comment
Share on other sites

Its because execute() runs in its own pseudo-scope. You can access privates from the parent sequence, but any privates you create inside the execute are local only to the code in the execute. So, for example, if you did:

execute("private x = 3" + chr(10) + "? x")

It would print the number 3. But if you did:

execute("private x = 3")

? x

you'll get an error like you saw because x only exists inside the execute(). As I said, its kind of a pseudo-scope because it can access privates outside:

private x = 3

execute("? x")

will actually print the number 3.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.