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

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

Prestwood eMagazine

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

   ► KBParadox Knowledge Base  Print This    Tips Database All Groups  

Paradox Tips Page

These Tips are contributed by you (our online community members). They are organized by our knowledge base topics. Specifically, by the Paradox sub-topics.

Contribute a Tip

27 Corel Paradox / ObjectPAL Coding Tips

Group: Corel Paradox / ObjectPAL Coding

Topic: Paradox ODBC Drivers

1. To Use ODBC, Set Up a DSN

If you add an ODBC data source, you must define its DSN before you can connect to that database.

Topic: Paradox Tables

2. Deleting .Val files is sometimes okay and necessary.
Referential integrity and other settings stored in .VAL files sometimes interfere with the development of a project. This particularly is a problem when you are restructuring a child table in a referential integrity link. If this happens to you and you don't mind losing the validity checks for a table or for a set of tables, go ahead and delete or, better yet, rename them.

3. Equivalent Autoincrement Field Type
Autoincrement fields have the same type as a long integer. This is important to know when linking with detail tables.

4. Know Your Field Types!
If you are developing an application using local tables and you know you are eventually going to move the data onto a SQL server, then do yourself a favor and spend a few hours studying the field and table naming rules of your target SQL server before you create your first table. While creating your local tables, use a naming convention that uses common rules. If you use the naming rules in common between the two database types, then you will save yourself time when you move your data to the SQL server because SQL servers often have different naming rules from the naming rules in Paradox.

5. Paradox locking on edits
If your Paradox application appears to lock up when you attempt to edit a record, you may want to disable your virus scan application to see if that is the problem.

6. Table Lookups and Directory Paths (more than 8 characters)
Lookup tables for Paradox table level 5 or lower are limited to 8 characters. If you use lookup tables in other directories, upgrade all tables involved to the Paradox table level 7. You can do this with Table Repair or by defining a level 7 feature (for example, a descending index).

Topic: OPAL: Language Basics

7. Before You Code

Before you code in ObjectPAL, ask yourself two questions. Does Paradox already do this? Is there a better and easier way? Remember, simple solutions for simple problems.

8. Don't Leave Experiments In Your Code!

If, in experimentation, you use sleep(), doDefault, or DisableDefault to overcome some odd or misunderstood behavior, do not leave the commands in your code. If using the command didnt seem to make a difference, then take it out. Use commands only when they are called for. One great way to really learn the event model and the power of these and other commands is to experiment with adding them. Remember to take them out, however, if they do not do what you wanted.

9. Object.Method() Syntax

The syntax of object.method() is consistent throughout ObjectPAL. If an object with the name box has code on its mouseClick event, you can access that code with box.mouseClick() method from any other object. When this code executes, the UIObject method mouseClick() calls the mouseClick event.

How do you know when you can call the code in a built-in method of an object? Easy, if the run-time library has a method equivalent, then you can use itfor example, mouseClick() and pushButton().

10. ObjectPAL Level Beginner or Advanced?
Whether your ObjectPAL level is set to Beginner or Advanced, you can use all the ObjectPAL methods, procedures, properties, constants, keywords, and so on. The level panel is a help filter used just for learning purposes. However, because you could in effect "hide" code from yourself, I recommend setting this to Advanced (never use beginner).

11. Study The Experts

Paradox provides experts that generate code at the field level, in the form open, etc. It is a good idea to study the ObjectPAL generated by these experts.

Topic: Interactive Paradox: Getting Going

12. Disable Change Directory Warnings
You can disable the warning prompts that are displayed when you change working or private directories. Clear the check box for the Don't show warning prompts when changing directories option in the Preferences dialog (advanced tab). To do this, first display the Preferences dialog box by selecting Edit | Preferences. Then, select the Advanced tab and clear the check box for the Don't show warning prompts when changing directories option.

Topic: Interactive Paradox: Forms

13. Ctrl+Spacebar Displays Lookup Table
When users press CTRl-SPACEBAR to display a lookup table, remember to let them know that they can use CTRL-Q to locate a value. This is an interactive feature that can greatly enhance the user's perception of your application.

14. Design Your Apps to Look Like Windows
Design your forms using the default Windows color scheme. Your applications will look more professional and consistent with the predesigned Windows color schemes and various themes. I've seen WAY too many Paradox applications where the developer has used too many background colors on forms. Sometimes the use of a few nice colors for different areas of an application works well, most of the time it doesn't. I'm not saying don't add color, I'm just saying be tasteful. Some of the Paradox applications I've seen look HORRIBLE!

15. Objects On a Form Have Containership Hierarchy
You can alter the path of objects by moving objects around in the containership hierarchy. Move objects on the same level by selecting Format | Order | Bring to Front and Format | Order | Send to Back.

16. Paradox's Autofill Feature
Remember, autofill is a great feature that you should promote to your users. To automatically fill in a date field with today's date, for example, just press the SPACEBAR a couple of times. Make sure you add this type of help to any manuals or help files you develop for your application. Autofill works with Date, Time, Timestamp, and Logical fields and does not require a picture statement.

17. Rename Many Objects Quickly with the Object Tree
If you need to rename many objects one right after the other, use the Object Tree. By selecting and inspecting each object on the Object Tree, you can quickly rename many objects.

18. Study Apps and Build Great Forms!
The user interface is the first element of your application that a user sees. Because first impressions are important, the user interface carries more weight than any other part of your application. It deserves much planning and effort. Spend time just reviewing the applications on your computer. The more time you spend looking at various application user interfaces, the better your forms, reports, and applications will look.

Topic: OPAL: Language Details

19. Use Constants & Make Your Code Easier to Maintain
Two advantages of using constants are that they humanize your code and help make managing your code easier. They humanize your code by making your code easier to read. A constant named tax is easier to remember and understand than 8.125. Constants help you maintain your code by centralizing values. If the tax rate in your area changes from 8.125 to 8.5, you change the constant in one location.

Topic: Interactive Paradox: Using Data

20. Add Audit Fields
Add a field called ModifyTimeStamp to every table in your project and set its Default value to NOW. These types of audit fields can be very helpful in business situations and are critical in many. Other types of audit fields you can add to the end of tables include CreateTimeStamp and EmployeeID.

21. Use an Alias to Refer to Your Paradox Tables
Put your tables in a directory different from the one that contains the forms, reports, and libraries. Use an alias to refer to the tables. This makes your application instantly a network-compatible application by making the tables relocatable. When you install the application onsite, you simply have to ask where to put the data and where to put the application. The application can be local or on the network. Place the data files where they need to be, and change the alias path. If you eventually want to move your data onto a SQL server, then you will have less code to rewrite.

Topic: OPAL: Commands

22. Correct Event To Trap a Key Press
As long as a field has focus, key presses do not bubble because the key press is used up by the field. Therefore, the two best choices to trap for key presses are the form's prefilter or on the field itself.

23. Use a Dialog form with app.Hide()
If you wish to show ONLY your form and hide Paradox, use a dialog form and app.hide().

24. User ForceRefresh() to Update Calculated Fields
If you ever have a calculated field on a form not update when you think it should, then use forceRefresh() to make the calculated field display the correct values.

Topic: OPAL: Wicked Coding Tasks

25. Speed Up TCursors with setBatchOn()
You can speed up a TCursor in by using update(), setBatchOn(), or copyToArray(). If you use setBatchOn(), make sure to follow it with setBatchOff() every time you use it.

Topic: Runtime, PDE, Package-It!

26. Add ObjectPAL to a delivered form
You cannot directly add code to a delivered form. For example, methodSet does not work on delivered files. However, you can use executeString() to execute ObjectPAL code even on a delivered form.

27. Paradox Looks for Non-Delivered, Then Delivered

Whenever you open a form, report, library, or script using the open() method and do not specify a file extension, Paradox always looks first for the nondelivered .?SL file and then for the delivered .?DL file.

Follow PrestwoodBoards on: 

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