Creates a Constants object.
ObjectConstantsGet( object )
(r) object reference COM object reference.
(r) constants reference Constants object reference.
Use this function to create a constants object for a COM Automation object:
adoApp = ObjectCreate("ADODB.Connection")
adoConst = ObjectConstantsGet(adoApp)
The function will produce an error, if the supplied parameter is not a COM object or is a COM object that does not have any associated constants.
A constants object is a special WIL language construct that allow you to access the constant values associated with a COM object by name. You access values by using the constants.name syntax where constants is the name of the variable holding this function’s return and name is the name of constant whose value you wish to use. For instance, if the constants object from the example above is used, then
conVal = adoConst.adBSTR
assigns the value of the constant adBSTR to the variable conVal. In this case, the constant adBSTR has the value eight(8), so after the assignment the variable conVal will hold the number 8.
You can use the constants.name syntax anywhere you would use a literal. This includes using it as an object method parameter, as the right-hand-side of an object property assignment, and in relational and arithmetic expressions. You cannot, however, assign a new value to an individual constant name. They are in effect read-only.
NOTE: This function may have an impact on the performance of yor scripts. Some COM objects have thousands of constants and you may experience a small delay while the function collects the constants’ names and values.
This example uses the ObjectConstantsGet function To obtain the constants associated with the ADODB.RecordSet object. The constants are Then used To set the CursorLocation property and To specify the data types For each record field. ; Get a recordset object reference. objRs = ObjectCreate("ADODB.RecordSet") ; Get the constants object for RecordSet conRs = ObjectConstantsGet(objRs) ; Set cursor source using constant. objRs.CursorLocation = conRs.adUseClient ; Create record fields using constants ; for Appends data types parameter. objRs.Fields.Append("MyText",conRs.adVarwchar,30) objRs.Fields.Append("MyDecimal",conRs.adDecimal) objRs.Fields("MyDecimal").DefinedSize = 19 objRs.Fields("MyDecimal").Precision = 18 objRs.Fields("MyDecimal").NumericScale = 6 objRs.Fields.Append("MyBoolean",conRs.adBoolean) objRs.Fields.Append("MyDate",conRs.adDate) ; Commit the record metadata objRs.Open() objRs.Addnew() ; ... Add data to the record set here... ; ... save records to disk here... ; Clean up. objRs.Close() conRs = 0 objRs = 0