Disclaimer: TOTAL GUESS!
I'd say that in the case of a function that *returns* a value, that
value must be created on the stack. So your MID is creating a new
string. That "new" string is then either assigned to a string
variable or returned to the calling function.
So: you're not passing ByRef in this case, but essentially "returning
ByVal". Meaning, you don't need to use temp$.
The MID(SomeExisting...) is creating a new string, passing it ByRef
to Fudge, which then modifies that *new* string (by the REMOVE()).
I think...
I'll have to test that theory - but not now... it's Beer O'Clock!
Enjoy your weekends everyone!
Ol
--- In Crestron@..., "Chip Moody" <cfm@...> wrote:
This is actually something I was wondering about when I made the
XM
Now Playing module, and just couldn't bring myself to write TBTS on
this.
In the XM module, I take the result of a MID function and pass it
to
one of my own functions that in turn manipulates the results of the
MID and returns the result of THAT manipulation.
If I could abbreviate/abstract it, it might look something like
this:
STRING_FUNCTION Fudge (STRING src$)
{
// Among other things, do something along these lines:
Garbage$ = REMOVE(";",src$);
// Blah blah, more code here...
RETURN (MyProcessedString$);
}
PUSH Go
{
tx$ = Fudge (MID(SomeExistingStringVar$,3,6));
}
My mindset was that the result of MID doesn't exist as a variable,
so I can't really mess around with the contents of that result like
I
show in that snippet up there. So in the ACTUAL module, one of the
first things that happens inside Fudge is I copy "src$" into local
variable "temp$", then work on temp$ exclusively:
STRING_FUNCTION Fudge (STRING src$)
{
temp$ = src$;
// Among other things, do something along these lines:
Garbage$ = REMOVE(";",temp$);
// Blah blah, more code here...
RETURN (MyProcessedString$);
}
Does that make sense? Does anyone know for certain if what I did
was required, or does the result of MID (or any other string
function
for that matter) exist in some malleable state that I can operate
on?
Thanks,
- Chip
--- In Crestron@..., "Oliver Hall" <oliver.hall@> wrote:
This is where foo pipes up to say that Crestron's implementation
of
ByRef does actually make a copy the data 8)