RE: Question about includes
> From: Kat
<SNIP>
> I was looking at David's Eu about 3am today too. It would be
> a way to get a goto as
> well. You realise that if we had the ability to execute
> variables, this wouldn't be a
> problem?
Yes and no. As my code works, if there is an error in the script code
executed by Eu, the program doesn't crash, but I can return an error from
the script and keep running.
<SNIP>
> I am interested in how you get David's Eu to interact with
> the main program's variables.
Basically, I set up new 'built-in' routines to be called from within the
script.
I have a couple of functions that allow me to pass the subscripts as
sequences/integers (mostly borrowed from some stuff Jiri posted a while
ago):
function seq_fetch(object a, sequence b)
for i = 1 to length(b) do
a = a[b[i]]
end for
return a
end function
function seq_store(object a, object b, object c)
integer len
len = length(c)
if len > 1 then
-- recursively go into the sequence
return seq_store(a, b[c[1]], c[2..len] )
end if
-- get the index
c = c[1]
if c then
b[c] = a
else
b = a
end if
return b
end function
Then, to modify sequence x:
function get_x( object a )
return seq_fetch( x, a )
end function
procedure set_x( object a, object b, object c )
x = seq_store( a, b, c)
end procedure
Then, in the sequence 'builtin', add these elements:
{ "get_x", FUNC, 1, routine_id("get_x") }
{ "set_x", PROC, 3, routine_id("set_x") }
This scheme probably won't allow the kind of dynamic stuff you're after,
Kat, at least without doing some major restructuring of your code. In
another part of this project, I've created an internal heap (just an a-list
of var's and values) to allow me to pass things by reference. You could do
something like this, and it should work.
There were lots of other things I had to change (no support for includes,
since all the code is fed by a proc call) to get everything to work, but I'm
pretty happy with the results.
Matt Lewis
____________________________________________________________
T O P I C A -- Learn More. Surf Less.
Newsletters, Tips and Discussions on Topics You Choose.
http://www.topica.com/partner/tag01
|
Not Categorized, Please Help
|
|