The 'Set To' operator: ":=" as used with an Object...
Jul 29, 2023 17:32:46 GMT 1
scalion likes this
Post by (X) on Jul 29, 2023 17:32:46 GMT 1
I was surprised to stumble upon something that I knew nothing about:
There is a way to assign Object property values using the 'Set To' operator: ":="!
I don't know if it would ever be vitally important, but, it may come in handy.
Here is a demonstration:
'#################################################################################
'
' DISCLAIMER: THIS CODE IS OFFERED AS IS FOR EDUCATIONAL PURPOSES.
' YOU ARE FREE TO USE, COPY AND DISTRIBUTE.
' THE USE OF THIS CODE IS AT YOUR OWN RISK.
' I ACCEPT NO LIABILITY NOR MAKE ANY CLAIM OF
' CORRECTNESS OR SUITABILITY IN PART OR IN WHOLE.
'
'#################################################################################
'
' FILENAME Demo Set To.G32
'
' DESCRIPTION A curious addition to the means available to assign values to
' Object properties in a "custom" sequence.
'
' I am not sure why or when this might be useful or required, but,
' it is another tool that I just learned about that may solve a
' problem one day.
'
' AUTHOR (X)
' EMAIL xman.gb32@gmail.com
' WEBSITE https://gfabasic32.blogspot.com/
' FORUM https://gb32.proboards.com/
' STARTED 2023-07-29
' UPDATED <ISO date>
'
'
$ManifestOff
$Library "GfaWinX"
$Library "UpdateRT"
UpdateRuntime
Mode Date "-"
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' := ASSIGNMENT OPERATORS
'
' PURPOSE
' Assigns an expression or value to a variable.
'
' SYNTAX
' varname := value
'
' DESCRIPTION
' Assignment operator := is often used with assignment of arguments of OLE object
' properties, this is called passing named arguments.
'
' Using named arguments are provided as a shortcut for typing argument values.
'
' With named arguments, you can provide any or all of the arguments, in any order,
' by assigning a value to the named argument.
'
' You do this by typing the argument name plus a colon followed by an equal sign
' and the value ( Argument := Value) and placing that assignment in any sequence
' delimited by commas.
'
'
OpenW 1
Ocx Label lbl1
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' You can provide the values of the object properties as shown below in a set
' order:
'
' Object.Move [left] [, top] [, width] [, height]
'
lbl1.Move 10, 10, 100, 30
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Or, by stating the properties explicitly in a custom order as follows:
'
lbl1.Move Height := 30, Left := 10, Top := 10, Width := 100
Do
Sleep
Until Me Is Nothing
You can find more information by searching the GFA-BASIC 32 for Windows Help Document for: ":=".