次の方法で共有


Passing Parameters by Reference

You can pass parameters by reference every time or only in a specific instance.

To pass parameters by reference

  • Use the TO REFERENCE clause of the SET UDFPARMS command before calling the UDF:

    -or-

  • Use the @ token to pass a variable or array by reference, as in the following example:

    ? "UDF value: " + STR(plusone(@nX))
    
  • To properly reference a variant data type in a COM object, you first must create an instance of the variable to the type you expect to retrieve. This applies only when you use Visual FoxPro as an early binding client.

       DEFINE CLASS varianttest AS SESSION OLEPUBLIC
          FUNCTION varret(outVal AS VARIANT@, inVal AS VARIANT) AS VOID
             OutVal = inVal
          ENDFUNC
       ENDDEFINE
    

    After this class is built into a DLL named myServer, you can reference the data as in the following code:

       x = CREATEOBJECT("myServer.varianttest","","")
       ov = ""
       tt.varret(@ov, "string")      && Sets string value
       ov = 0
       tt.varret(@ov, 123)         && Sets ov to an integer value
       ov = 0.0
       tt.varret(@ov, 44.44)      && Sets ov to a real numeric value
       ov = l
       tt.varret(@ov, f)            && Sets ov to a boolean value
    

See Also

Passing Parameters by Value | SET UDFPARMS Command | User-Defined Functions | Data Manipulation