ADDRESSOF function

Purpose:

ADDRESSOF returns the address of the location, in computer memory, where a variable is stored.

Syntax:

RetVal = ADDRESSOF(TheVariable)

Return Value:

  • Data type: INTEGER
    RetVal The address of the location, in computer memory, where TheVariable is stored.

Parameters:

  • TheVariable The name of the variable.

Example 1:

PRINT GetMachineName$()

FUNCTION GetMachineName$ ()
  DIM A$
  DIM b AS DWORD
  b = 256
  GetComputerName(A$, ADDRESSOF(b))
  FUNCTION = A$
END FUNCTION

Result:

Deus Ex Machina

Example 2:

BCX_SHOW_COM_ERRORS(TRUE)

DIM RetBool
DIM app AS OBJECT
app = COM("Excel.Application")
 
app.workbooks.add
app.visible = TRUE
app.ActiveSheet.Cells(3,1).Value="Hello"
app.ActiveSheet.Cells(4,1).Value="From BCX"
app.ActiveSheet.Cells(5,1).Value="Console program!"
 
RetBool = BCX_GET_COM_STATUS(ADDRESSOF(app))
IF RetBool <> 0 THEN
  MSGBOX "Loaded app.ActiveSheet.Cells"
END IF

DIM temp_var$
 
temp_var$ = app.ActiveSheet.Cells(3,1).Value
MSGBOX temp_var$, "value of cell(3,1)", 4096
 
RetBool = BCX_GET_COM_STATUS(ADDRESSOF(app))
IF RetBool <> 0 THEN
  MSGBOX "Displayed value of cell(3,1)"
END IF

MSGBOX "BCX COM Example!" & CRLF$ _
     & "Using Office automation to manipulate Excel." & CRLF$ _
     & "Program will close Excel in 1 second.","finished!", 4096

SLEEP(1000)

app.activeworkbook.saved = TRUE
app.quit
UNCOM(app)

RetBool = BCX_GET_COM_STATUS(ADDRESSOF(app))
IF RetBool = 0 THEN
MSGBOX "Nothing means Nothing"
END IF