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

-Collapse +Expand Paradox To/From
-Collapse +Expand Paradox Store

Prestwood eMagazine

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

   ► KBDesktop Data...Paradox & Ob...ObjectPAL Co...OPAL: Langua...   Print This    All Groups  
  From the June 2015 Issue of Prestwood eMag
Paradox OPAL: Language Basics:
A 10 Minute ObjectPAL Quick Start
Posted 13 years ago on 6/19/2008 and updated 11/7/2008
Take Away:

If you've never programmed in ObjectPAL, spend 10 minutes and see how easy it is to program Paradox for Windows.


Got 10 minutes? Want to get started with ObjectPAL?

This article is part of our series of 10 Minute Quick Starts. Each quick start is step by step, assumes you know very little about the subject, and takes about 10 minutes. You can use them to scratch the service of areas you want to learn and as a quick review when returning to something after a long absence.

Classic "Hello World"

This article is for someone who does not code in ObjectPAL and wants a very short introduction. In Paradox, you add ObjectPAL code to events of objects such as form open, pushing a button, etc. In 10 minutes, we cover how to enter code and the absolute minimal basics.

To get started, you have to have Paradox for Windows installed. This tutorial is based on Paradox 11 but you can use any version of Paradox for Windows you wish (there may be slight variations in menu options but we try to keep our 10 Minute Quick Starts as generic as possible).

In programming, it is traditional to display or print "Hello World" as your very first program to show the world that your program is alive. In your very first program, you will create a form with two buttons on it. The first button will display a message on the status bar and the second will display a message in a dialog box.

  1. Create a blank form. Select File | New | Form and select Blank to create a blank form.
    Paradox File New Form
  2. Add two buttons. Your form may look a bit different than the image below due to your preferences. When designing a form, the property toolbar changes and contains objects you can place on a form. When you design a report, it changes to contain objects you can place on a report. To place an object, you select the object then click where on the form (or report) you want the object to appear. You can move and resize it anytime as you see fit. For now, place two buttons on the form we created.
    Paradox Objects
  3. Change the labels of the buttons to "Hello World" and "Too Fun!". Select the first button, then select the label within the button. You could select one more time to edit the label directly but I want you to get used to using the Object Explorer so right click on the label and select Object Explorer.
    Select Paradox's Object Explorer
    This brings up the Object Explorer. Edit the Text property and set it to "Hello World". Repeat this procedure for the second button and set it's label to "Too Fun!".
    Paradox's Object Explorer
  4. Add code with the ObjectPAL Editor to the pushButton event of the button. To code in Paradox, you add ObjectPAL code to events of objects. To edit an event of an object, you use the ObjectPAL Editor. The first step is to select the object you wish to work with, display the Object Explorer, and select the Events tab.
    Make sure the first button is selected (not the label object within it), right click and select Object Explorer. Select the Events tab to view the events for this object. We are going to edit the pushButton event and some simple code to it. You can either double click the pushButton event, select the event and press enter, or right click and select Edit Event.
    Open ObjectPAL Editor
  5. You should now be working in the ObjectPAL editor. Type the following code into the editor.
    ObjectPAL Editor
  6. Check syntax. At this point, we could run our form and press the button but I want you to check your syntax first. When writing long passages of code, it's useful to check your syntax as you go. Right click on the ObjectPAL Editor and select Check Syntax.
    ObjectPAL Check Syntax
  7. Add code to the second button. Add the following code to the pushButton event of the Too fun! button.
    ObjectPAL msgInfo
  8. Run form. There are several ways to run the form. I prefer to use the Run icon Paradox Run Icon on the toolbar or press F8. You can also right click on the ObjectPAL Editor and select Run or select View | View Data from Paradox's main menu.
    Press the Hello World button and you should see "Hello World" on the status bar.
    Paradox status bar
    Press the Too fun! button which displays an OK message box. Select OK to close it.
    ObjectPAL msgInfo
  9. Now you're ready to explore code snippets. For a review, add a third button to the form and add the following code to it's pushButton event. Run the form and see what it does!
    method pushButton(var eventInfo Event)
    If msgQuestion("ObjectPAL Survery", "Do you like ObjectPAL?") = "Yes" Then
     msgInfo("Yeah!", "Keep going!")
     msgStop("oh...", "I was hoping you would like it.")

    Code Explanation
    An if statement allows you to execute code based on a condition. Optionally, it allows you to execute code if the condition is false too using the else keyword.

That's It! I hope you enjoyed coding in ObjectPAL. Refer below to some articles that dive deeper into ObjectPAL.

More Info

Article:  An ObjectPAL Primer: Part 1
Article:  An ObjectPAL Primer: Part 2
Article:  An ObjectPAL Primer: Part 3
KB Post:  Overview of Paradox's Project Viewer
Article:  Recommended Paradox Preferences


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 = P1237A1
Enter key:
Article 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

 KB Article #101209 Counter
Since 6/19/2008

Follow PrestwoodBoards on: 

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