CALL question
TurnipTruck
Posts: 1,485
Greetings,
Can a CALL pass back a string to its DEFINE_CALL? I am having trouble with this.
This return a variable conversion warning at compilation.
Thank you for any help.
Can a CALL pass back a string to its DEFINE_CALL? I am having trouble with this.
CHAR cSCROLL_MSG[32] DEFINE_CALL 'SCROLL'(cSCROLL_MSG) { //sends a scrolling message } CALL 'SCROLL'('MESSAGE')
This return a variable conversion warning at compilation.
Thank you for any help.
0
Comments
Back to recursion; you need to be very careful with this. Whenever a CALL (or FUNCTION) calls itself, a new instance of it is allocated in memory, and if too many get called at one time before the originals close, it will eat up your memory until the master crashes. Use recursion carefully, and make real sure each iteration runs quickly and exits so this can't happen. Also be careful of endless recursions where it keeps calling itself forver with no exit point.
Anyway, what you are trying to do is assign an array of characters to a single character variable (I think) and that's not good.
To fix:
DEFINE_CALL 'SCROLL'(char cSCROLL_MSG[])
{
}
Yes, this appears to be correct and I was wrong. Modification of the value of a variable passed to a function or "call" changes the value of the variable in the calling scope. "Call by reference" and not "call by value."
But, changing the value of a local variable within a subroutine does not change the value of a global variable with the same name. For example:
DEFINE_CALL 'SCROLL'(char cSCROLL_MSG_2[])
{
local_var char cSCROLL_MSG[32]
cScroll_Msg = 'Inside Scroll'
}
will not change the value of a global variable named cScroll_Msg. I think.
In NetLinx, a DEFINE_FUNCTION would be a better use. If this is in Axcess, then the DEFINE_CALL is all that is available.
Just a note on recursion. The NetLinx Interpreter tracks the depths of recursion and the memory available when doing recursion, so if the interpreter task memory gets low due to recursion being too deep, the recursion is exited.
Chuck