[DGD] How to make a more powerful function call?

Brandon Rush bcr124 at psu.edu
Wed Aug 8 03:56:00 CEST 2001


Hello all, I'm in my familiar position of knowing what I'd like to do
but not knowing how to code it. I'll give you the background of what I
want to do and if anyone has some ideas/tips/general directions to point
me in I'd appreciate it. (You need to code an extension to do that, you
need to <do this>, that's not possible in DGD, etc).

I was talking to another coder (not using DGD) who was telling me about
a foreach() kfun/efun. It's called in a form like

foreach( var in *array) { block of code }.

What it does is step through every element in *array, assigning it to
var and running the block of code. It would replace code similar to

for (i=0,i==sizeof(*array),i++) {block of code}

except instead of referring to array[i] you could refer to var which is
a little cleaner and easier to read.
I can make an afun which takes a mixed var and mixed *array argument,
but I can't find a way to send execution back from the function, run
{block of code}, then return to the function again so I can set var to
the next value and run {block of code} again. If someone knows a way for
me to pass {block of code} to the function too, that might do the
trick--or like I said, any suggestions/advice on what I should be trying
to do to make this work.

Thanks,

Brandon Rush

_________________________________________________________________
List config page:  http://list.imaginary.com/mailman/listinfo/dgd



More information about the DGD mailing list