GUID Data Types

PowerBASIC introduces another new variable class: GUID variables.  These are a special form of 16-byte string that are used to contain a 128-bit Globally Unique Identifier (GUID), primarily for use with COM Objects.

Generally speaking, a GUID variable is assigned a value with the GUID$ function, or with a string equate, and that value usually remains constant throughout the program.  The GUID variable is typically used only as a parameter, rather than as a term in an expression.

GUID variables must be explicitly declared with DIM, LOCAL, etc, and are used in much the same way as a 16-byte fixed-length string or a user-defined type of that size.  A GUID variable is only valid as a parameter when its 16 bytes of data are in an appropriate format.  For example:

$idNull = STRING$(16,0)

...

DIM abc AS LOCAL GUID

DIM def AS LOCAL STRING

DIM xyz AS GLOBAL GUID

abc = $idNull

abc = GUID$("{00000000-0000-0000-C000-000000000046}")

xyz = abc

def = GUIDTXT$(xyz)

' def contains "{00000000-0000-0000-C000-000000000046}"

 

 

See Also

GUID$ function

What is an object, anyway?

Just what is COM?

How are GUID's used with objects?