An Alpha Anywhere User Guide to the Desktop.

A Procedure for Building Complex Expressions

Filter expressions are character strings. However, it is often very difficult to compose a filter expression. Handling quotes and variable names becomes confusing. The following procedure, written by Cal Locklin, makes the process easier and more understandable. The desired result of a filter expression - like when you want to pass a filter to a report - is a character string. The result that is passed to the report must be exactly the same as if you typed it into the report filter itself. This is an important concept because many people forget that the report has no idea what the variables were in the script that called the report unless those variables were dimensioned as GLOBAL. So a filter like this...

Benefits of Viewing Xbasic

There are many benefits of displaying the Xbasic code for an operation. Inexperienced users who wish to learn about Xbasic can see how their operations are formed, and see the Xbasic syntax in action. Intermediate and expert users can use the Xbasic generated by the Operation Builder as a starting point for an extended Xbasic script. Used this way, viewing the Xbasic from the Operation Builder can save a lot of time by generating the bare-bones code for you.

Closing a Dialog Box

When a dialog box is displayed using the FORM.DIALOG() method, the user action of closing the dialog window actually closes the window.

Code Editor File Functions

You write Xbasic scripts in the Code Editor. The Code Editor is a multi-tabbed window that lets you edit multiple scripts at the same time. It always includes at least one tab called the Interactive window where you can test individual lines of Xbasic code and see immediate results. The Code Editor lets you write scripts in two ways. You can use the graphical Action Scripting method, or you can type in Xbasic commands. For more information on Action Scripting, see the Introduction to Action Scripting book.

Code Editor Functions

The Alpha Anywhere Code Editor has many functions to make you more productive.

Creating a Low Resolution Viewfile

When you create an image database, you may want to have a low resolution viewfile to represent a higher resolution image. Typically, the viewfile would be used when you want to quickly put an image on the screen, without moving megabytes of data.

Creating and Programming Hotspots with Xbasic

Many of the forms in the AlphaSports application have a set of images in the lower right corner. At first, you might think these were buttons with image labels. In fact, they are actually composed of two layered images and a set of Hotspots. A hotspot is similar to a button without a visible component. It is a rectangular region that responds to an OnPush event and will run either an Action Script or Xbasic code.

Ending the AlphaSports Application

The CanExit event provides the developer with a way to intercept a close form (and, in this case, exit application) command, and then:

Global (User Defined) Functions

Like the properties and methods and events of objects, the functions you saw in the previous section are all built-in to Alpha Four. Like object methods, you can call a function to accomplish a pre-designated task. Object events, however, you can define yourself. You control what happens when you write Xbasic code for an object event.

Learning Xbasic - Using Xbasic with SQL Tables

A tutorial about learning Xbasic. Includes a number of videos and procedural guides for working with Xbasic and sql tables.

Opening the Default Form or Browse

You can open the default browse or form for a table or set in Xbasic with FORM.VIEW():

Other Code Editor Functions

Covers setting the relationship between tables, using the script navigator, OLE automation browser, Xbasic script genie, global variables, and the cascading style sheet builder.

Referring to Form and Browse Objects

Using Xbasic you can control form and browse windows in much the same way that the user does when he or she makes selections from menus and presses toolbar buttons. For example, you might have opened a form called Customers. If you want to enter a new record in this form, you could press the New Record icon on the speed bar. To accomplish the same thing using an Xbasic method, you could type this in the Interactive window:

Specifying Images in the Data

We have seen how the embedded owner-draw directives can control the font, color and background color of the data. In this lesson, we will show how you can specify bitmaps in the data that you display. The directive for specifying an image is:

Testing if a Form or Browse is Already Open

It is often necessary in an Xbasic program to test if a form or browse window is already open. To do this, use the IS_OBJECT() function. For example, the following command tests if a form called Customers is already open. If not, it opens the form. If it is open, it gives focus to the form.

Thread Example

This is an example of using background threads. This thread is going to look for a specific file.If that file is found, it will be read in and executed (making the assumption that the text file is an Xbasic script). If the file doesn't exist, the thread will sleep for a while before looking for the file again.

Trapping Other Events

In addition to trapping the change event, which fires when the value in a control changes, you can also trap other events, such as when a control gets and loses focus, or when a user double-clicks on an entry in a list box. If you wish to trap more than just the change event for a control, you use the following syntax:

Trapping Tab Control Events

You can generate an event when the user changes the tab page. The syntax is:

Trapping the Change Event

Alpha Anywhere automatically generates an event when a button on a dialog is pushed. In addition to the button push event, it is often necessary to generate an event when the value in a control on a dialog box changes. To do this, you specify the name of the event in the syntax for the control. The syntax for generating a change event for a control is:

Understanding Functions

You may use two types of functions in your A5W pages:

User Settings

Alpha Anywhere stores certain user settings (specified in View > Settings) in the system registry database under the init key (which is relative to the root key.

Using AlphaDAO with Xbasic

Includes: What is AlphaDAO?, terminology, the AlphaDAO object, and creating an object,

Using the << Delimiter

The Format parameter in the UI_DLG_BOX() command can be extremely long. It is not practical to enter the dialog Format on a single line between quotes. The << delimiter in an Xbasic script is used when you want to enter a long quoted string over many lines. The syntax of the << delimiter is:

Using the Thread UI_Disable Property

UI_Disable is a property of all threads. When set to .T., much UI-related functionality within Alpha Anywhere is disabled. This is useful in a background thread, for example to prevent a print progress dialog from being displayed.

Using Xbasic to Control Access to a Form

The Invoice form contains the btnEditItems0 ( Zoom ... ) button. The Xbasic code run by the button's OnPush event creates and sets the value of the global variable varInvoice_Number, then displays the Items form (from the AlphaSports sample database). The result is that the global variable varInvoice_Number only exists when the Items form is called by the Invoice form.

Using Xbasic to Create Queries

The RADIO2 option button asks the user whether to preview or print, and stores the result into a form variable named print_option. BUTTON1 executes an Xbasic routine that examines all these variables and calls the appropriate preview or print functions.

Variable Scope

A variable does not exist until it is declared. When the script, form, or session, in which it is declared, goes away, the variable leaves with it (unless the variable was defined with a Global or Addin scope). The duration of a variable definition, and the extent to which it is accessible from other places, is called the variable's scope. The scope of a variable can be local, layout, session, or global. A special kind of scope called Addin is also available. Addin variables are primarily used by Alpha Anywhere itself.

Xbasic methods for the HTML and HTMLHOST Xdialog Commands

This article describes the new Xbasic methods that can be used on the HTML that is rendered by either the {html} or new {htmlhost} commands.