Simple Short Circuit Code Test
The following code snippet allows you to test out ObjectPAL's short circuiting. In the if statement of the pushButton event, the That() custom procedure executes even if This() is False.
To use the code, alter a pushButton event of a button as follows:
;This custom procedure.
proc This() Logical
msgInfo("", "This")
return False
endProc
;That custom procedure.
proc That() Logical
msgInfo("", "That")
return True
endProc
method pushButton(var eventInfo Event)
;Object always short circuits.
;The That() custom procedure executes even
;though This() returns false.
if This() and That() then
msgInfo("", "both are true")
endIf
endMethod
Using the Logical Not Operator
You can use the not operator in many contexts. One of my favorite uses for it is to toggle boolean properities with a single line of code:
BooleanProperty = Not BooleanProperty
Working Paradox Demo
The following demo works in all versions of Paradox for Windows. The demo uses the not operator to toggle the visible property of a box from a button.
- Create a new form and place a button and a box on it.
- Name the box "TheBox". To rename it, select the box, right click and click properties. In the Name of object field, change the name to MyBox.
- Edit the pushButton event and alter it as follows below. Select the button, right click, click Object Explorer. Double click the pushButton event on the Events tab.
method pushButton(var eventInfo Event)
TheBox.Visible = Not TheBox.Visible
endMethod
- Run the form and test. Select Program | Run and click the button. You'll notice the visible box toggles between visible and not visible with a single line of code.