Description

Converts a binary structure to a dynamic array, placing each element from the structure into the corresponding field.

Syntax

var = Struct_To_Var (struct, structname)

Parameters

Use Struct_To_Var when you want to convert a structure into an @fm-delimited array and none of the structure elements are char or char array types containing character values greater than an @vm (hex FD, decimal 253). Alternatively, use Parse_Struct to parse a structure into separate variables.

This function is the opposite of the Var_To_Struct function.

The structure definition must be predefined using the Define_Struct routine.

See also

Define_StructParse_StructVar_To_Struct()

Example

/* Assumes the structure called RECT has been defined as being composed of 4 "signed short" elements, 
and the API function GetWindowRect has been defined in DLL_USER as:
VOID PASCAL GetWindowRect(USHORT, LPCHAR) */
 
declare function Get_Property, GetWindowsRect
declare function Blank_Struct, Struct_To_Var
 
hwnd = Get_Property(@window, "HANDLE")
rect = Blank_Struct("RECT")
GetWindowsRect(hwnd, rect)
Size = Struct_To_Var(rect, "RECT")
 
* build the SIZE property out of the returned rectangle
 
Size<3> = Size<3> - Size<1>  ;* convert right to width
Size<4> = Size<4> - Size<2>  ;* convert bottom to height
  • No labels