slang-users mailing list

[2004 Date Index] [2004 Thread Index] [Other years]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]

Re: [slang-users] Accessing Functions using an array


Michael / Doug - Perfect. That is exactly what I want to do.

There has been a lot more interest of late in my SLAG project, so
over the holidays, rather than be bored, I am back workin on it.

The next biggie to get down is the Pull-down Menu system.

FWIW, the look and feel so far has taken on something along the lines
of Foxpro / Delphi / Alpha Four / Dbase / Paradox ..etc..etc..

Michael Noble wrote:
Is it possible and how would you do it, to set up an
array that contains function names (slang, not C)
like such (pseudo code below):

define functioname_1 { .....}
define functioname_2 { .....}
define functioname_3 { .....}


You probably want function references, not function names.
In which case something like
   MyArray = [&functionname_1, &functionname_2, ...];

should suffice.

There is a catch, however.  In SLang 1 there exists a bug
which prevents using the natural idiom

	(@MyArray[i]) (...);

to invoke the i-th function within the array.  Instead, one must
use a temporary variable to store the function reference, then
deref the variable to invoke the function, along the lines of

	variable func = MyArray[i];
	(@func) (...);

HTH,
Mike


--
Ben Duncan   - VersAccounting Software LLC 336 Elton Road  Jackson MS, 39212
"Never attribute to malice, that which can be adequately explained by stupidity"
       - Hanlon's Razor


_______________________________________________
To unsubscribe, visit http://jedsoft.org/slang/mailinglists.html


[2004 date index] [2004 thread index]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]