DBF

Description

An Alpha Anywhere User Guide to the Desktop.

Name
Description
About Indexes, Queries, and Ranges

This guide covers when to use indexes and queries, index files vs index tags, the components of an index tag, important index procedures, important query procedures, and more.

Active-Link Tables

Active-Link tables allow you to work with data in SQL tables. An active-link table is a local Alpha Anywhere table that is dynamically populated with data from a remote SQL database. Any changes that you make to the local active-link table are immediately persisted (i.e. saved) to the remote database. This means that you can build Alpha Anywhere forms that update, insert and delete records in remote SQL tables. In addition, it means that you can use your knowledge of how to work with tables using Xbasic to manipulate data in remote SQL databases.

Advanced Record Lists

Advanced record lists give you more control over the data that is displayed in the record list and the formatting of the record list. In addition, you are not restricted to showing data from the primary table of the session. You can display data from any table.

Applying a Range to a Table

To apply a range to a table while viewing a form or browse:

Copying Selected Records from another Table

You may copy selected records from another table to the current table using the Copy Operations or when viewing a table through a form or browse.

Create a New Table by Example

The Create Table - by Example process infers the table structure from sample data.

Create Linked Table Dialog

The Create Linked Table dialog helps you create a linked table.

Creating a New Table

Typically, you create new database tables by defining their data field structure in the Table Editor window. Other methods for creating tables include:

Creating a Previous Values Lookup

The Previous Values lookup is a great way to dynamically build a choice list from values that have already been entered. In a table containing product information, you might define a Product type field with a Previous Values lookup. Since the number of product types is limited, once you enter several product records, you can select the value from the list instead of typing it in. Many parameters available with the other lookup styles are available for use with a Previous Values lookup, including the ability to display lookup choices in a drop-down list box. If you selected "Conditional Table Lookup", optionally, un-check Display as Drop-down list box if you would like the choices to appear instead in a pop-up dialog box. Refer to Comparing Drop-down Lists and Popup Dialogs.

Creating a Table Lookup

You can use a record in another table as the source of the lookup values. You can also define a lookup that fills in several fields with values from fields you select from the lookup table. For example, you might define a lookup for the Prod_ID field. The lookup finds the matching Prod_ID record in the Product table and fills in the Price field.

Creating a Tree Control Based on a Set

This example shows how to create a tree control that shows the contents of a set. The set has four levels, as Described in this picture.

Creating Conditional Table Lookups

When one of several tables might supply the field's value, use a Conditional table lookup. Instead of choosing one lookup table, you complete the Table Conditions table, filling in the names of two or more tables along with a Conditional expression for each that determines which table is used for the lookup. The tables you use must have the same field names and types since there is only one field mapping.

Creating Many-to-Many Sets

A many-to-many set is created by defining a linking table that has one-to-many relationships with two different tables. In the sample AlphaSports database you can create a many-to-many set named Customer_Product with these steps:

Database Explorer

The Database Explorer provides a quick way to examine the properties of the tables and sets in your database. The Local Tables section lists the tables (including passive-link tables) and sets in your database. When you expand the Tables section and expand a table, you will see a list of the table's fields. The entry will contain the field type and length of each field. The Sets section lists the tables in each set and their linking relationships. A single arrow indicates a one-to-one relationship. A double arrow indicates a one-to-many relationship.

Displaying Data from a Table

As you can see in the above example, initializing the customer array is quite tedious. Alpha Anywhere offers two array methods that are particularly useful for initializing arrays of pointers. These are <ARRAY>.INITIALIZE_PROPERTIES()and <ARRAY>.INITIALIZE_FROM_TABLE(). In the above example, the company array could be initialized more concisely as follows:

Displaying Multiple Tables with a View

The Web Component Builder provides two methods for displaying data from multiple tables. The View technique combines fields from 2 or more tables in one-to-one relationships.

Displaying Selected Lookup Table Records (Filtered Lookups)

If you want to be able to choose from a subset of lookup table records, you can build a filter expression. Records that do not satisfy the filter do not appear in the lookup window.

Duplicate Records Genie

Alpha Anywhere adds another powerful productivity tool in the Delete Duplicate Records Genie. The Delete Duplicate Records Genie helps you find, review, and optionally mark or delete duplicate records. Alpha Anywhere has always had a facility to mark and delete duplicate records. Typically, users would use the Mark Duplicate Records operation to mark all duplicate records. Then they would manually preview the marked records to decide which marked records were indeed duplicates. Finally, they would delete the marked duplicates. This new genie makes it much easier to go through these steps because it allows you to easily compare the original record (the master record) with each of the duplicates of that record. as you compare the master record with its duplicates you can decide if you want to retain any record marked for deletion.

Duplicating a Record

Duplicating records is useful when you have repetitive data. For example, you might have several records with the same company name and address, but a different contact person. Instead of re-entering the company information for each contact, you can duplicate an existing record, and change the contact name field.

Duplicating a Table

To duplicate a table with the Duplicate Table dialog box:

Dynamic List Table Lookups

Many applications call for the contents of list boxes to dynamically change as variables (external to the list box) change.

Emptying a Set

To remove records from the tables in a set:

Emptying a Table

To remove records from the tables in a set:

Entering and Changing Records

You can enter or change records in any open table (assuming the table is not write-protected or being used exclusively by another user or session). Several open tables or related tables from a set can be in Enter or Change mode simultaneously. To enter a new record into a table, you do the following:

Export Operation - Excel

The 'Classic' Export Operation has an option to export to old Excel 2003 files. The 'Classic' Export Operation only offered Excel V4 files. (You could still export to Excel 2003 using the AlphaDAO export, but this is not as fast as the 'Classic' Export). If you used the 'Classic' Export Operation to create an Excel V4.0 file, the Excel 2010 Beta release was not able to open the file. Now, using the 'MS-Excel 2003' option shown below, the exported file can be opened in Excel 2010 Beta release.

Fetching Records

When a table is open, there is always one record that can be called the current record. This record is the record upon which the next set of field operations will be applied. A temporary record buffer holds the data from the current record. When a record is entered or changed, the new data values are entered through this buffer.

Filter Expression Dialog Box

The Filter Expression dialog allows you to specify an association between the current table and the lookup table. A typical circumstance when this would be desirable is when you selected a value in a vendor field and wanted the list that appeared in the product field to contain only the vendor's products.

Find Tables that Contain a Data Value

This utility displays the Search Selected Tables for Data Value dialog box. This dialog allows you to discover the names of the tables and of their fields that contain a specified value. In the example illustrated below, the dialog found that the phrase "Cali Pressureless Racquetballs" was found in the Description field of the Product table.

Formatting Record Lists

Alpha Anywhere allows you to set optional column headings for each column in a record list. You can also set a left column margin so that the text in each column has some spacing between the vertical line and the text. You specify column headings by enclosing the column heading between square brackets after each column specification.

FoxPro Compatibility

Alpha Anywhere uses FoxPro v2.6 tables. The current versions of FoxPro ( Visual FoxPro 6 and above) have a different file format. Alpha Anywhere cannot read these newer FoxPro formats. However, the newer versions of FoxPro can still read their old format (the format that Alpha Anywhere uses).

Importing Different File Types

A guide on importing excel spreadsheets and importing CSV, TXT and other ASCII Files,

Index Builder

Creating an index, rebuilding an index, and repairing an index

Layout Editors - Modeless Property Editor

You can now edit the properties of the objects on your Layout using a modeless, dockable Property Grid. This makes editing properties much quicker than having to right click on an object and bring up a modal properties dialog. The image below shows a Form in Design Mode with the Properties Dock Panel visible. As soon as you set a value in the Properties Dock Panel, the Layout is immediately updated to reflect the property value. If you don't like the change you just made, select the Undo command from the menu. You will notice that the property names have a + icon to their left. This allows you to define 'Dynamic Properties'. See the section on Dynamic Properties for more information.

Lookups

When entering values in a Character, Numeric, or Date field, it is useful to choose a value from a list. For example, in a table of invoice items, you can use a Lookup to display a list of products from which to choose.

Mapped Tables

Alpha Anywhere now allows you to create 'mapped' tables. A mapped table is a virtual table that displays data from one or more physical tables. The mapped table can include all, or a subset of, the field fields in the physical tables that it maps. It can also include calculated columns. Once you have created a mapped table, it appears in the Tables tab of the Control Panel just like any other table. You can create Forms, Reports, Labels, Letters and Operations for mapped tables just as you would for physical tables. Mapped tables can be read-only, or updateable, depending on how they are defined.

Ordering Lookup Entries

Often you will want to display a list of values selected from a table. It is often desirable to specifically order these entries, instead of allowing them to display in record order or alphabetically. Here is a technique for solving this problem. This example uses a combo box on a form.

Overview of Indexes and Queries

Two of the ways that Alpha Anywhere creates an ordered list of selected records is by using indexes and queries. Keys and key expressions are the basis for indexes and queries.

Packing a Table

Packing a table removes deleted records from the database and compresses memo fields. You should pack tables periodically so that they take up less space and to help database operations run more quickly. After packing a table, you can no longer undelete records. Also, if you select Compact Database before Backup in the Backup dialog box, Alpha Anywhere packs the records and you cannot undelete them.

Packing Alpha Anywhere Tables

After editing or deleting records and layouts, it is a good idea to pack and backup the tables in your database. When the database is remotely located on a Application Server, you need to create a page with the following code.

Passive Linked Table Programming Example

Creating a passive-link table using Xbasic:

Populate Dynamically from a Table

This example of a tree control shows how to use the X directive to dynamically populate the branches of a tree control from a table. It shows the use of the {DATA} command to return values different than displayed and the {EXPAND} command to display a message when populating a branch takes longer than 2 seconds.

Populate from DBF Table

The designer created this dialog with the List View Genie.

Record List - List Box Table Lookup

The Record List - List Box tab of the Table Lookups form contains two list boxes.

Record List Events

You can trap an event when the user clicks on the column heading of a column in a record list. For example, the following script traps events for the record list control. By including the directive:

Removing Selected Records from a Table

You can remove selected records from a table based on the records in another table called a "remove list". This is useful, for example, in mailing list applications when you receive notification from recipients that they want to be removed from your mailing list.

Renaming a Table

To rename a table:

Restructuring a Table

Once you have created a table, you can restructure it by adding, removing, or changing fields. To restructure a table, you need exclusive access to the table, which means no one else can be using the table. You restructure tables using the Table Editor, which has the same features as when creating a new table, except you cannot edit the indexes.

Searching the Text Fields of a Record

The following script shows how to search the text fields of a record to see if they contain a match to a character search value. This illustration uses the Customer table of the AlphaSports sample database. A new form named New_Customer contains a tabbed control with two pages. The first page contains a text field that sets the value of a global variable named var->search_word.

Selecting Records

Alpha Anywhere provides a variety of ways to order and select data to view, print, or use in data-processing operations. One of the easiest ways to select records and sort them is by using Query by Form, which lets you enter search and sort criteria in the same form you use for entering data. Refer to Sorting and Selecting Overview.

Send Table

To email one or more components of a table as a zip file:

Set Index

The Set Index sets the primary index or query list for a form or browse. The primary index controls which records are viewed, and in what order.

Setting Choices for Record Lists

A data field displayed as a record list-list box or record list-combo box accepts only new or changed values that are already in the list. The difference between the two control types is only in the display of the data. A data field displayed as a record list-edit combo box accepts both values in the list and new values entered by the user.

Simple Record Lists

A simple record list displays data from the primary table of the current session. You also have no control over column widths and what data is returned by the control. If you want more control, refer to the section on Advanced Record Lists. The syntax for a simple record list is:

Smart Buttons

You will see many smart buttons in Alpha Anywhere. Smart buttons can directly accept input, like any other type-in text control, but they also have built-in functions to help you along. One example is a File-select 'open folder' smart button in the Append Builder.

Specifying Multiple Images in a List Box

The owner-draw list boxes that we have shown so far have all used a single image in the list box. In a practical application, you will want to use multiple images in a list box, with the bitmap associated with each row of the list box determined dynamically, based on the text in the row.

Speed Typing

Speed typing is a shortcut for entering frequently used values. The speed typing glossary, A_GLOSS.DBF, is initially empty. You can expand and maintain your glossary as you work, so it contains data values you use often.

Table Information Dialog Box

When the Tables/Sets tab of the Control Panel is visible, select a table and click Table > Properties to display the Table Information dialog box. The Table Information dialog box displays the following information about a table:

Table Lookups

It is quite common in database application design to present the user with a list of choices. Occasionally, a list is static and hard coded, but often the list is table driven. Sometimes, a list needs to change dynamically, depending on the value of another form object, selection text, or variable. Often the developer will make the list selections more user friendly by presenting an "alias" for an encoded field. This topic explores how to develop these types of lists in Alpha Anywhere.

Table Overview

Alpha Anywhere tables store and arrange information in a database. Each table can contain an almost unlimited number of records while each record can contain up to 1,024 fields, storing individual bits of data. Tables generally contain information about people or things, such as Customers, invoices, bank transactions, and products. Fields may contain any one of eleven different data types.

Table Statistics Dialog Box

Selecting File > Database Information displays the Table Statistics screen.

Undeleting Records

To restore records marked as Deleted:

Using DBF Files

Alpha Anywhere stores its data in standard .DBF files. This means that, if you have data in .DBF file format, you can use it directly in Alpha Anywhere. You do not have to first import the data. Programs that create .DBF files that Alpha Anywhere can use directly include Alpha Four, ACT, and GoldMine.

Using Tables

A table is a spreadsheet-style file in which database data is stored. Data in a table is divided into records and fields, or rows and columns. For example, you want to create a table to store information from a checkbook register.

Using the Audit Trail Feature

Alpha Anywhere writes out an ASCII file which is an audit trail of all changes made to a record. The audit trail shows the date and time of the change, the original value in the field, and the new value in the field. To turn on the audit trail feature, you put the command: Addin.run("audit_trail") in the record's CanSaveRecord event. Also, if you want to keep track of deleted records, put Addin.run("audit_trail_deleteRecord") in the record's CanDeleteRecord event.

Why can't I open my DBF database?

When you are working in the Alpha Anywhere IDE and have a project open, Alpha Anywhere always knows what databases are in your project. That's not true if no project is open, or the IDE is not running. Suppose your project has a table called customer. If you go to the interactive window and type

Word Perfect Integration

Word Perfect offers a data integration tool that allows you to extract fields from an Alpha Anywhere table, merge them into a document, and format the results. While the most common application is probably is creating mail merge Letters, this tool can be used to create formatted reports of all types. You can save the merge form in Word Perfect and the reference to the data source is retained. Path information is absolute so you would like to avoid moving anything once it is set up. Word Perfect has excellent help. This is where users should go for further information about this process.

Working with Tables from another Session and with Child Tables on a Form

Assume that you have two forms open, FormA and FormB. It is possible for a script that is attached to a button or event in FormB to manipulate (i.e., enter, edit, delete records etc.) the table or tables that FormA is based on. Generally when a script needs to manipulate a table in the current session, you obtain a reference to the table in the current session using the TABLE.CURRENT() method. For example, the following script, which is attached to a button on a form, enters a record into the table on which the form is based:

Workspaces

Historically, Alpha Anywhere master projects were called "databases," because historically, Alpha Anywhere was oriented around Dbase-compatible DBF databases. It has been a long time coming, but we've finally changed the terminology, mostly to help new users feel more at home in the IDE. Alpha Anywhere now has Workspaces, giving it terminology that is consistent with many modern development environments. It's a small change, but you'll see it throughout the product.

Zap (Empty) Table

The Zap (Empty) Table action empties all records from a table.

Zip Table

To collect one or more components of a table into a zip file: