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

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

   ► KBDesktop Data...Paradox & Ob...P9 Book: Pow...   Print This     
  From the February 2013 Issue of Prestwood eMag
 
Paradox P9 Book: Power Programming:
Power: Chapter 10, Using Table Windows
 
Posted 16 years ago on 3/20/2003 and updated 3/31/2003
Take Away: Chapter 10, "Using Table Windows" from Paradox 9 Power Programming by Mike Prestwood.

KB100196



In Paradox, a table window is an object that displays data in its own window. A table window is what opens when you select File | Open | Table and choose a table. A TableView object (variable) in ObjectPAL is a handle to that window. Sometimes, you want to display a table and work with it in a TableView. Although a TableView is limited in functionality, you can open and manipulate it similarly to how you open and manipulate a form. Included in the list of methods and procedures for the TableView object type are open(), close(), action(), bringToTop(), and isMaximized(). Refer to Paradox’s help for a complete list.

The TableView Object

Just as there are Application and Form variables, there is a variable for use with a table window. It is the TableView variable. As soon as you declare a variable as a TableView and open the TableView, you establish a handle to a table window. With that handle, you can open, wait, and close table windows.

You also can use ObjectPAL to manipulate TableView properties. For example, similarly to manipulating a form with a Form variable, you can manipulate the TableView object such as background color, grid style, and the value of the current record. You also can manipulate the field-level data in the table (TVData), such as font characteristics and display format. Finally, you can manipulate the TableView heading (TVHeading), such as changing fonts, colors, and alignment.

The following code declares a TableView variable named tv:

1: Var
2: tv TableView
3: endVar

Because this variable now exists, you can use it to open a table window, as follows:

1: tv.open("CUSTOMER.DB")
2: tv.wait()
3: tv.close()

The TableView action() method is powerful. It gives you access to many of the form methods and procedures. For example, to put a table windows into Edit mode, use the following:

1: tv.action(DataBeginEdit)

The TableView object has several other methods and procedures you can use, including hide and show. For example:

1: tv.hide()
2: message("Table is hidden for 3 seconds")
3: sleep(3000)
4: tv.show()

To instruct the user in how to use a table window, you can use the TableView setTitle() method to set the title of the table window. For example, to tell the user how to start and end Edit mode, do the following:

1: TableViewVar.setTitle("F9 for edit mode :: Close to return")

The next example demonstrates opening a table window from a button.

Displaying a Table Window from a Button

Suppose that you want to have a button on a form bring up a table window. In this next example, you will declare a TableView variable and use the open() method to open up the CUSTOMER.DB table.

Step By Step

    1. Set your working directory to Paradox’s Samples directory. Create a new form and put a button on it labeled CUSTOMERS.DB.
    2. Add lines 4–8 to the pushButton event of the button. This routine opens CUSTOMER.DB in a table window. Line 5 declares tv as a TableView variable, which line 8 uses to open the table.
    3. 1: ;Button :: pushButton
      2: method pushButton(var eventInfo Event)
      3: ;This routine brings up a TableView
      4: var
      5: tv TableView
      6: endVar
      7:
      8: tv.open("CUSTOMER.DB")
      9: endMethod

    4. Check the syntax, save the form as TVIEW1.FSL, and run it. Click the button. Figure 10-1 shows how the form and table window look when you click the button.

Figure 1: TVIEW1.FSL demonstrates how to open a table window

Getting a Table Window Ready for Input

The next logical step in learning how to handle a table window is to get it ready for data entry. You can use the action() method with constants to manipulate a table window. I like the technique presented in the next example because of its simplicity. It demonstrates how to get a table window ready for input. Suppose that you want to have a button on a form that opens a table window ready for input when the user clicks it. In this example, you will use the setTitle() method to set the text in the title bar of the table window, and action() to move to the end of the table, put it in Edit mode, and insert a record by moving past the last record.

Step By Step

    1. Set your working directory to Paradox’s Samples directory. Create a new form and place a button on it labeled Add a Customer.
    2. Add lines 4–11 to the pushButton event of the button to open the CUSTOMER table window that is ready for input. Line 5 declares tv as a TableView variable. It's used in lines 8–11. Line 8 opens the CUSTOMER.DB table with the tv variable in a table window. Lines 9–11 use action constants to move to the end of the table, to switch into Edit mode, and to move to the next record. Now, the table window is ready for input.
    3. 1: ;Button :: pushButton
      2: method pushButton(var eventInfo Event)
      3: ;This routine brings up a table view ready for input.
      4: var
      5: tv TableView
      6: endVar
      7:
      8: tv.open("CUSTOMER.DB")
      9: tv.setTitle("Enter a record and close Table Window")
      9: tv.action(MoveEnd)
      10: tv.action(DataBeginEdit)
      11: tv.action(DataNextRecord)
      12: endMethod

    4. Check the syntax, save the form as TVIEW2.FSL, run it, and click the button. The TableView does exactly what you told it to do, and it's ready for input. Your form should look similar to Figure 10-2. The CUSTOMER.DB table is ready for input.

Figure 2: TVIEW2.FSL

Illustration 1

Summary

This short chapter is important because it gave you the tools to control the displaying of data to a user using a table window. Now you can easily add the ability to display the raw table data to your users in table windows using the ObjectPAL TableView object. This is particularly important when using the Paradox runtime because the runtime does not surface the File | Open | Table option to the user. It is important to note that these techniques do work with the runtime edition of Paradox.


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 = P1222A1
Enter key:
KB Post 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 #100196 Counter
7227
Since 4/2/2008
Follow PrestwoodBoards on: 


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