Application Development with Harbour/Understanding Workareas
What is a workarea in the Clipper/Harbour language?
[edit | edit source]Let us for a moment think back at the old times when commonly used computers had no mouse and GUI. Nevertheless, if we wanted to use several tables for a task, we had to use some way to tell the computer which tables he should consider. Let us take for example a library. Oversimplifying, we need to use at least three tables to manage it (one for the books, one for the customers and one for the loans).
We might issue these commands:
SELECT 1 USE Books SELECT 2 USE Customers SELECT 3 USE Loans SELECT Books
We might visualize the result as the three windows in the picture below:
Here the command SELECT works like clicking on a window to activate it, and the workareas themselves look like windows having a number (the workarea number) and a name (the workarea alias).
To close workareas one uses one of the following commands:
- CLOSE
- CLOSE ALL
- USE
Why should you want to use workareas?
[edit | edit source]Workareas are the natural way of managing database tables in dBASE [...]
Examples of workareas
[edit | edit source]As we've seen above, we can use the following workareas in program to manage a library:
- Books workarea: a table to store information about the books in the library (fields could include book title, author, publication date, ISBN, etc.)
- Customers workarea: a table to store information about the library's customers (fields could include customer ID, customer name, address, contact information, membership status, etc.)
- Loans workarea: a table to track information about book loans (fields could include loan date, due date, customer ID, book ID, return status, etc.)