xHarbour Reference Documentation > Statement Reference xHarbour Developers Network  

(struct)

Creates a new structure object

Syntax

<var> := (struct <StructureName>)
or
<var> := (struct <StructureName>*) <pointer>

Arguments

<var>
This is the name of a memory variable to assign the structure object to.
<StructureName>
This is the symbolic name of a structure declared with typedef struct.
<pointer>
This is the name of a memory variable holding a pointer. The pointer holds the memory address of the structure. The resulting structure object is initialized with the structure data pointed to by <pointer>.

Description

The (struct) statement provides the most convenient way of creating a structure object of a declared C structure. (struct) is not a statement in its strongest definition, since it is used on the right side of the assignment operator and produces a return value: a new C Structure object. The name of a declared structure <StructureName> must be provided with the (struct) statement. A corresponding structure object is then instantiated and assigned to the memory variable <var>. This structure object maintains an uninitialized C structure.

When the (struct) statement is coded with an asterisk, an additional memory variable <pointer> must follow the closing brace. This variable must be of Valtype()=="P", i.e. it is a pointer holding the memory address of structure data. The created structure object is then initialized with the structure data stored at the memory address of <pointer>. This is required in the special case when an external function called via DllCall() produces a pointer to a new structure. Data pointed to by <pointer> is then transferred into a new xHarbour structure object.

Note:  refer to the typedef struct statement for a usage example of (struct).

Info

See also:C Structure class, DllCall(), pragma pack(), typedef struct
Category: C Structure support , xHarbour extensions
Header:cstruct.ch, winapi.ch, wintypes.ch
Source:rtl\cstruct.prg
LIB:xhb.lib
DLL:xhbdll.dll


Copyright © 2006-2007 xHarbour.com Inc. All rights reserved.
http://www.xHarbour.com
Created by docmaker.exe