Assigns an object reference to a variable or property.
Set objectvar = objectexp | Nothing
objectvar:name of variable or property
objectexp:any object expression
When you use Set to assign an object reference to a variable, no copy of the object is created for that variable. Instead, a reference to the object is created. More than one object variable can refer to the same object. Because such variables are references to the object rather than copies of the object, any change in the object is reflected in all variables that refer to it.
objectexp is an expression consisting of the name of an object, another declared variable of the same object type, or a function or method that returns an object of the same object type.
The Dim, Global, Public, Local, and Static statements only declare a variable that refers to an object. No actual object is referred to until you use the Set statement to assign a specific object.
In GFA-BASIC 32 new instances of user interface Ocx objects are created with Ocx, OcxOcx, LoadForm, Form, and the window creation commands. OLE automation objects are created using CreateObject and GetObject. A mouse cursor object is created using LoadCursor, a Picture object with CreatePicture or LoadPicture.
Local pic As Picture
Set pic = LoadPicture("c:\pict.bmp")
Other intrinsic Ocx objects, like DisAsm, Collection, are created with the New keyword in the declaration. Set together with New cannot be used in GFA-BASIC 32, because GFA-BASIC 32 provides other means of creating object instances.
When Nothing is assigned to an object variable, the association of the object variable with the object is discontinued. Assigning Nothing to the object variable releases all the system and memory resources associated with the previously referenced object when no other variable refers to it.
Set pic = Nothing
Set Me is provided to assign a Form object to the Me Form object. Set Me redirects the output to the specified form without activating it.
Set Me = Win_1
Dim dis As DisAsm
1
Set dis = CreateDisAsm()
2
dis.Addr = LabelAddr(1) // start address
Debug.Print dis.DisAsm // disassembly of 16 bytes
While dis.Addr < LabelAddr(2)
Debug.Print dis
Wend
Debug.Show
Function CreateDisAsm() As DisAsm
Dim dis As New DisAsm // a new instance of disassembler
dis.ByteFlag = True // code bytes and Hex bytes
dis.HexDump = False // disassembly or a HexDump
dis.HexDumpCount = 16 // bytes per line 1-32 (16=default)
dis.PreferHex // addreses in hex format
Set CreateDisAsm = dis
EndFunc
{Created by Sjouke Hamstra; Last updated: 23/10/2014 by James Gaite}