Built in functions and passing vars by reference


#1

I remember Tomasz had said that if we pass values by reference, built in functions do not work, or give error message. I do not find the documentation where this is explained, after some googling. Is this explained somewhere?

printf gives error message. However NZ() function does not. I setup an example that demonstrates it:

function myFunc( fType )
{
local ltmp;
    ltmp = fType;
    fType = 26;
    ftype[4] = 30;
    ltmp = fType;
    
    ftype=Nz(ftype);  // This command messes up the ftype var
    ltmp=Nz(ltmp);  // This command is ok    
    
    ftype = ltmp;   // a way to fix it
    return true;
}

    local
    xx1, xx2;

    xx1 = 5; 
    xx1[2]=Null;
    xx1=Nz(xx1);  // This command is ok
    xx2 = myFunc( &xx1 );

#2

For additional info on this topic, see also this thread.

Passing arguments as a reference is still a BETA feature, so the documentation available is only the one that came in the release notes with the beta versions, plus the examples provided by @Tomasz here in the forum.

As any beta feature, IMHO it is better to consider it subject to possible changes in the next stable version.


#3

Thank you very much beppe. This is the thread I had read too.


#4

You can't pass references to built in functions in 6.27.1 yet. As @beppe wrote it is work in progress.