I.T. Discussion Community!
-Collapse +Expand
Paradox
Search Paradox Group:

Advanced
-Collapse +Expand Paradox To/From
To/FromCODEGuides
-Collapse +Expand Paradox Store
PRESTWOODSTORE

Prestwood eMagazine

February Edition
Subscribe now! It's Free!
Enter your email:

   ► KBDesktop Data...Paradox & Ob...ObjectPAL Co...OPAL: Langua...   Print This     
  From the January 2016 Issue of Prestwood eMag
 
Paradox OPAL: Language Basics:
ObjectPAL Logical Operators
 
Posted 10 years ago on 2/12/2009 and updated 9/19/2009
Paradox Code Snippet:
 A flashcard from our Paradox Flashcards Library
 A code snippet from our Paradox Code Snippets Page

KB101898



Languages Focus: Logical Operators

Logical operators perform conditional and, or, and not operations. Some languages support both binary logical operators that link two and unary logical operators negate (make opposite) the truth value of its argument. Finally, some languages short circuit logic. For example, with this or that, if this is an expression returning true, then that is never executed.

ObjectPAL Logical Operators

ObjectPAL logical operators:

and and, as in this and that
or or, as in this or that
Not Not, as in Not This

Like VBA, ObjectPAL never short circuits. Given the expression this or that as well as this and that, if this evaluates to false, then that is still executed.

Syntax Example:
;Given expressions a, b, c, and d:
if Not (a and b) and (c or d) then
  ;Do something.
endIf

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.

  1. Create a new form and place a button and a box on it.
     
    Paradox form.
     
  2. 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.
     
    Demo of using not operator.
      
  3. 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

      
  4. 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.
     

More Info


Comments

0 Comments.
Share a thought or comment...
 
Write a Comment...
...
Sign in...

If you are a member, Sign In. Or, you can Create a Free account now.


Anonymous Post (text-only, no HTML):

Enter your name and security key.

Your Name:
Security key = P1182A1
Enter key:
Code Contributed By Mike Prestwood:

Mike Prestwood is a drummer, an author, and creator of the PrestwoodBoards online community. He is the President & CEO of Prestwood IT Solutions. Prestwood IT provides Coding, Website, and Computer Tech services. Mike has authored 6 computer books and over 1,200 articles. As a drummer, he maintains play-drums.com and has authored 3 drum books. If you have a project you wish to discuss with Mike, you can send him a private message through his PrestwoodBoards home page or call him 9AM to 4PM PST at 916-726-5675 x205.

Visit Profile


Linked Certification Question(s)

The following are practice certification questions with answers highlighted. These questions were prepared by Mike Prestwood and are intended to stress an important aspect of this KB post. All our practice questions are intended to prepare you generally for passing any certification test as well as prepare you for professional work.

Beginner

1 Beginner Level Question

Question #1: Multiple Choice

What are the logical operators?

Answer:
1. 
  • and
  • or
  • not
  • xor
2. 
  • and
  • or
  • not
3. 
  • and
  • andAlso
  • or
  • orElse
  • not
4. 
  • and
  • andAlso
  • or
  • orElse
  • not
  • xor

 KB Article #101898 Counter
12723
Since 2/12/2009
-
   Contact Us!
 
PrestwoodBoards.com was developed and is maintainted by me. Do you have a question or suggestion? Do you see a problem? Contact me now. My goal is to build an ad-free and spam-free source of I.T. information with many contributers (ok to promote your website/company in your bio). Yes, my company Prestwood IT Solutions is mentioned in my bio which shows with every post, but you can contribute and promote your pet project too!

2,970 People Online Now!!  
Sign In to see who's online now!  Not a member? Join now. It's free!
Show more stats...


©1995-2019 PrestwoodBoards  [Security & Privacy]
Professional IT Services: Coding | Websites | Computer Tech