Skip to content

GetAddress Command

Obsolete

Refer to the AddressOf function.

See Also

Purpose

The GetAddress Command returns the memory address of a DataFlex string variable. GetAddress is most often used to pass the address of a structure stored in a DataFlex string to an external function.

Syntax

GetAddress Of {variable-name} To {variable}

Argument Explanation

  • variable-name: The name of a string variable.
  • variable: The integer variable that stores the address of the named string variable.

What It Does

This function is used to pass the address of a structure to an external function. The following example is part of the example for the Field command. GetAddress is used to get the address of the string sCommDCB into the pointer pCommDCB that is passed to the Windows Win32 API function BuildCommDCB.

// Set up the Com port.
Function CommSetup Returns Integer
    String sCommDCB    // Buffer for accessing DCB.
    Pointer pCommDcb

    // Reset the structure. Fill it with nulls.
    // Note: The Type command automatically creates the _Size constant.
    // Its value is the size of the data structure in bytes.
    Move (Repeat(Character(0), commDCB_SIZE)) to sCommDCB

    // The commDCB structure requires the size as the first field.
    Put CommDCB_Size To sCommDCB At cDCBLength

    // Get a pointer to the DataFlex string.
    // Structures must be passed by pointer.
    GetAddress Of sCommDCB To pCommDCB

    // BuildCommDCB fills a CommDCB, based on a Mode command string.
    If (BuildCommDCB(ModeString(Self), pCommDCB)) 
        Function_Return TRUE
    Else 
        Function_Return FALSE
    End_Function

Notes

  • GetAddress can only be used with string variables.
  • The AddressOf function is simpler to use and more powerful.