Posted 16 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.
KB101209
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.
Setup 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.
Create a blank form. Select File | New | Form and select Blank to create a blank form.
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.
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.
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!".
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.
You should now be working in the ObjectPAL editor. Type the following code into the editor.
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.
Add code to the second button. Add the following code to the pushButton event of the Too fun! button.
Run form. There are several ways to run the form. I prefer to use the 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.
Press the Too fun! button which displays an OK message box. Select OK to close it.
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!") Else msgStop("oh...", "I was hoping you would like it.") EndIf endMethod
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.