Struct_Len function

 

Description

Returns the length in bytes of a structure based on the structure's definition.

Syntax

length = Struct_Len(structname)

Parameters

Often API functions require a pointer to structure and the length of the structure as parameters. Some API functions take structures as parameters that contain the size of the structure. In either case, the size of the structure can be determined using the Struct_Len function.

The structure definition must be predefined using the Define_Struct routine.

See also

Blank_Struct(), Build_Struct(), Define_Struct, Var_To_Struct(), Chapter 7

Example

declare subroutine Set_Property, PrintDlg
declare function   Struct_Len, Build_Struct

$insert Logical

/* the Windows API function PrintDlg() takes one parameter, a PRINTDLG structure, and uses the information within it to display the standard print dialog.  the first element in the PRINTDLG structure is the size of the structure, allowing the PrintDlg() function to be modified over the past decade without breaking code that passes it earlier versions of the PRINTDLG */

lStructSize = Struct_Len("PRINTDLG")
printstruct = Build_Struct(lStructSize, ...)

/* since the printer dialog is being constructed in a DLL call, block events from OpenInsight while the dialog is displayed */

Set_Property("SYSTEM", "MODAL", TRUE$)
PrintDlg(printstruct)
Set_Property("SYSTEM", "MODAL", FALSE$)