Xbasic

DECLARESTRUCT

DECLARESTRUCT is deprecated and slated for removal in a future release. Use .NET Integration instead.

Syntax

DECLARESTRUCT Structure_Name Type1 Size1 Variable1 [, Type2 Size2 Variable2 [, ... TypeN SizeN VariableN ]]

Arguments

Structure_Name

The generic name of the type of structure being created. You would later dim variable_name as structure_name.

Type1 ... TypeN

The type. All types are single character. Preceding the Type with an ampersand "&" in front of it (e.g &L1Z ) means you are passing it by reference. In most cases, the associated Size will be 1. You can also include user defined types that have more than one character in their name by putting parentheses around the type name. See the user defined type called rect that is used in the GetWindowRect function example.

Single character types are listed below:

"L"

32 bit long

"I"

32 bit integer

"W"

16 bit short

"B"

byte

"N"

IEEE 8 byte Double

"F"

IEEE 4 byte float

"C"

character (address of characters)

Size1 ... SizeN

An integer value

Variable1 ... VariableN

The names of the variables included in the structure.

Description

The DECLARESTRUCT command provides a means of representing structures ( 'struct' for those who know C, RECORD to those familiar with Pascal, and TYPE for those who know Visual Basic) .

Discussion

These structures are used by the Windows API and other externally defined functions. All structures passed to DECLARED functions are passed by reference. The DECLARESTRUCT's Structure_Name is used by DECLARE in the argument list to represent pointers to defined structures. Also DECLARESTRUCT can include other structures (i.e. structures within structures). The types are the same as those passed to and returned from DECLARED functions (see DECLARE predefined types).

Alpha Anywhere recommends that you use the TYPE ... END TYPE syntax instead of DECLARESTRUCT. See also DECLARE.

Extra spaces are added for readability. Remove all spaces from the finished statement, except those between DECLARESTRUCT and Structure_Name and between Structure_Name and Type1.

Examples 

Declaring the equivalent of the POINT structure which in C is

typedef struct {
    int x;
    int y;
} POINT;

In Xbasic is 1 long called X and 1 long called Y.

declarestruct point L1X,L1Y

An array of 100 points whose type declaration in C is:

typedef POINTS POINT[100];

In Xbasic is:

Declarestruct pts point100points

The following example shows how DECLARESTRUCT was used to call a TWAIN driver.

dim ftemp as P
declarestruct hwndapp L1hwndapp
declarestruct sFile C255sFile
DECLARE Eztwain3 TWAIN_AcquireToFilename L(hwndApp)(sFile)
ftemp.sFile="C:\\test\\pict1.jpg"
TWAIN_AcquireToFilename(0, ftemp)

See Also