Using the Xbasic Code Editor



The Xbasic Code Editor is used to write Xbasic scripts in applications. It includes features, such as syntax highlighting and auto-complete, to make it easy to read and write Xbasic.


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. The Code Editor 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.

Xbasic Code Editor Features and Topics 

  • Adding and Removing Code Indents 

    How to indent and outdent single or multiple lines of code.

  • Auto-Completion 

    Auto-completion helps you with the syntax and arguments of functions and methods.

  • Automatic Code Formatting 

    The Code Editor includes a format command that formats all code. The function converts all language elements to uppercase and indents the code.

  • Bubble-Help 

    Bubble help makes it easier to find functions and understand what arguments they require.

  • Check Syntax 

    Alpha Anywhere examines your script or function and reports the line number of the first syntax error that it finds.

  • Code Library 

    The Code Library is a dockable toolbar that stores and organizes an unlimited number of Xbasic and Xdialog code snippets, retrieving and inserting them into your project with just a couple of keystrokes.

  • Color Coding 

    Color coding makes Xbasic scripts easier to read and understand. In addition, you can customize the colors that the editor displays.

  • Combining Commands on a Single Line 

    How to combine multiple commands on a single line.

  • Continuing a Command on a Second Line 

    How to continue a long line of code over multiple lines.

  • Creating and Using Bookmarks 

    Bookmarks allow you to quickly move the cursor to a location in a script or function.

  • Email Scripts and Functions 

    Email a script or function as an attachment.

  • Finding and Replacing 

    Search an entire script or just selected text, forward or backward, for whole words, and with case sensitivity.

  • Find Un-dimmed Variables 

    Find variables that have not been dimmed, generate the correct DIM expression, and paste the resulting code into your script.

  • Global Search of Scripts and Functions 

    The Global Search of Scripts and Functions dialog box allows you to search for text in any one of your scripts or functions.

  • Goto Function Declaration 

    When using the Code Editor this command repositions the cursor to the referenced function.

  • Insert Image 

    The Insert Image dialog box allows you to insert the name of any embedded image into your script or function.

  • Insert Function 

    The Function Finder helps you to find the right function and then insert that function into your script.

  • Insert Field Name 

    The Insert Field dialog box allows you to inspect the characteristics of any field in any table and insert a fully qualified reference to a field into your script or function.

  • Insert Color Name 

    The Select Color dialog box allows you to insert the name of any Alpha Five color into your script or function.

  • Insert Key Codes 

    The Insert Key Codes dialog box generates the code sequences needed to represent control keystrokes on the keyboard.

  • Inserting_Comments 

    Comments make code easier to understand and maintain.

  • Invert Order of Lines 

    Select any number of contiguous lines in the editor and reverse their order.

  • Line Numbering 

    Turn line numbering in the Code Editor on and off.

  • Multi_Pane_Editor 

    The Code Editor lets you edit multiple scripts simultaneously. You can have up to 15 Xbasic Scripts, Functions, or Action Scripts open at the same time.

  • Creating a New Script or Function 

    How to start using the Code Editor.

  • Password Protecting Your Scripts 

    Control access to a script or function by assigning it a password.

  • Printing Scripts and Functions 

    Print a script or function.

  • Remove Blank Lines 

    Remove blank lines from any portion of your script or function.

  • Renaming a Script or Function 

    Rename or duplicate a script or function.

  • Set Relationship Between Tables 

    The Set Relationship Between Tables dialog box generates the Xbasic code necessary to open a parent and child table in a set relationship.

  • Setting the Variable Frame 

    When using the Interactive window, set and read the variables of another window.

  • Show Function Declaration 

    When using the Code Editor this command displays the referenced function in a separate window.

  • Sort 

    Sort any contiguous group of lines in ascending or descending order.

  • Status Bar 

    Track your location in a script by function name and line number.

  • Transform Code Utility 

    Create an expression that transforms or reformats any group of lines in your script or function.

  • Writing and Reading Text Files 

    Save a script or function as a text file or import a script or function from a text file.

Utilities Available from the Code Editor 

  • ADO Record Set Genie 

    The ADO Record Set Genie allows you to create an Xdialog form that is bound to an ADO data source. The Xdialog form will allow you to view, edit, delete, and enter records.

  • Button Genie 

    The Button Genie generates all the Xdialog code for a button.

  • Interactive Window 

    When you want to see the result of an Xbasic method, command or expression immediately, you can type an Xbasic statement directly into Alpha Anywhere's Interactive window.

  • OLE Automation Object Browser 

    The OLE Automation Object Browser allows you to investigate the properties, methods, events, and constants of ActiveX controls and then copy values back to your script.

  • Script Debugger 

    The Script Debugger allows the programmer to step through an Xbasic script or function and watch as Alpha Anywhere executes each line. You can selectively debug only portions of your code, set breakpoints, and examine the values of variables.

  • Script Navigator 

    The Script Navigator is a floating toolbar that shows a list of the functions that have been declared in the script and lets you quickly navigate, within the script, to a particular function.

  • Static Text Genie 

    The Static Text Genie makes the process of creating sophisticated and attractive Xdialog forms easier, faster, and more reliable by generating properly formatted Xdialog code for static text.

  • Style Editor 

    The Style Editor generates HTML style attribute codes.

  • Trace Window 

    When you are developing and debugging scripts, the Trace Window displays detailed warning and error messages which would otherwise be too long or numerous for display in a dialog box.

  • Xbasic Explorer 

    The Xbasic Explorer is a complete reference of all of the commands, functions, methods, properties and constants in the Xbasic language.

  • Xbasic Script Genie 

    The Xbasic Script Genie generates the Xbasic code associated with the library of Action Scripting actions. The result of the process is code that is ready to be copied and pasted into your script or function.

  • Webform Style Builder 

    The Webform Style Builder allows you to edit and create cascading style sheets.

Code Editor Toolbar 

Creating a New Script or Function 

There are several ways to open the Code Editor :

  1. Display the Code tab of the Control Panel, then select View > Code Editor.

  2. The Code Editor appears. When the Code Editor opens, only the Interactive window is shown. To create a new script or function, click the appropriate button on the toolbar:

    • The new script button creates a new script using the Xbasic Editor.

    • The Action Scripting button creates a new script using the Action Scripting Editor.

    • The function button creates a new function using the Xbasic Editor.

  3. Alternatively, you can click the Code tab on the Control Panel, click the New button, and select Interactive Window, Script, or Function.

The Scripts menu on forms and browses let you design and execute scripts without switching to the Control Panel. Creating a new script gives you the option of using Action Scripting or Xbasic.

Opening a Script or Function 

If you wish to open both the Code Editor and an existing script at the same time.

  • Method 1 

    • 1. Display the Code tab of the Control Panel.

    • 2. Select the script or function and click Design.

  • Method 2 

    • 1. Display the Code tab of the Control Panel.

    • 2. Select File > Open.

    • 3. Display the Text Files, Scripts, Functions, or Recent Files tabs, depending on what you want to open.

    • 4. Select the filename in the list and click OK.

  • Method 3 

    • 1. Display the Code tab of the Control Panel.

    • 2. Select Code > Recent Files....

    • 3. Select a script or function from the sub-menu.

  • Method 4 

    • 1. Display the Code tab of the Control Panel

    • 2. Select Code > Edit Script or Function.

    • 3. Optionally, click the 'function' icon to hide or display functions and scripts.

    • Optionally, click this to hide or display functions and scripts.

    • 4. Optionally, enter the name of the script or function, using "*" and "?" as wildcard characters to shorten the list.

    • 5. Optionally, click the 'footsteps' icon to display recently edited files.

    • 6. Select the filename from the list and click Open.

  • Method 5 

    • 1. Display the Code tab of the Control Panel.

    • 2. Select Interactive Window.

    • 3. Make a selection from the drop-down list box at the upper left corner of the Code Editor window. The options are"

      • "Scripts/Functions"

      • "Text Files"

    • 4. Click either the Open/Script Function or the Open Text File button to display a list.

    • 5. Optionally, toggle the and to hide or display functions and scripts.

    • 6. Optionally, click the 'footsteps' icon to display a list of recent files.

    • 7. Select the file of interest and click Open.

Multi-Pane Editor 

The Code Editor lets you edit multiple scripts simultaneously. You can have up to 15 Xbasic Scripts, Functions, or Action Scripts open at the same time. The Code Editor is re-sizeable, and Alpha Anywhere remembers its size and position every time you open it.


When you type in the Code Editor, the Alpha Five auto-completion logic displays a list of functions or methods starting with the characters you have typed. You can then press Enter to have Alpha Five fill in the command. The Alpha Five auto-completion logic and Bubble Help make typing Xbasic commands and functions much easier because whenever a table name, field name, index name, or constant are required, you can simply right-click on the Bubble Help, and Alpha Five displays a list of all of the parameters from which you can select. Also, after you have declared a variable, Alpha Five shows all the variable names, making it less likely that you will introduce an error by transposing a letter while typing a variable name in a script.


The Code Editor provides extensive context-sensitive bubble-help as you type. This bubble-help is an invaluable aid in showing you the list of available methods, functions and properties, and in showing you the syntax for any particular function or method that you select. For example, as you begin typing, the bubble-help pops up with available choices. The list of available choices is narrowed as you type. In the picture below, Alpha Five shows the functions that start with "loo".

To accept an entry from the bubble-help, use the down arrow to highlight an entry and then press Enter, or simply click the mouse on the selection that you want. TIP: You can configure Alpha Five to use a Tab key rather than the Enter key to accept a bubble-help entry. Select the View > Settings command and navigate to the Auto-Help category. Once you have selected a function or method, bubble-help will help you with the syntax of the function or method by prompting for each argument. For example, in the picture below, Alpha Five shows that the first argument for the LOOKUP() function is "tablename".

Many of the argument prompts allow you to right click on the argument name (or press Control-Down ) to get a list of choices. For example, in the picture below, right clicking on the "tablename" argument gives a list of tables in the current database.

Locally defined functions are also included in the auto-completion feature. For example, if you are writing a script and you define several functions in the script, Alpha Five will list all of the locally-defined functions, in addition to global functions and system functions.

Adding and Removing Code Indents 

You can indent code by selecting one or more lines and clicking TAB. You can remove an indent level by selecting one or more lines and clicking SHIFT + TAB. The same functions are found on the right click menu.

Word Navigation 

Pressing CTRL-LEFT will move the cursor by a word to the left, and pressing CTRL-RIGHT will move the cursor by a word to the right.

Inserting Comments 

You can add comments to a script to clarify and explain its operations. A comment must be preceded by the single quote (') comment marker. All text on a program line that follows the comment marker is part of the comment. A comment can appear either on a line by itself or at the end of a line shared with program code. For example, the following script has two comments:

' This script will count from 1 to 10.
for i = 1 to 10
  trace.writelni? 'prints the number in the Trace window
next i

Creating and Using Bookmarks 

You create a bookmark by putting in a special comment that looks like this. Note that there must not be any space characters after '// .

'//My Bookmark

After opening a script, you can move to a bookmark by selecting Edit > Goto. Select the Goto tab, select the bookmark from the drop down list, and click Goto.

You can get quick access to any bookmarks you insert into the script or function you are editing by clicking the 'Bookmark' icon on the status bar. A bookmark is any comment that starts with //. For example:

'//bookmark1  (Xbasic)
//''Bookmark1 (Javascript)

Combining Commands on a Single Line 

You can combine multiple commands on a single line by separating each command with a semi-colon. This is particular useful in the Interactive window. For example, to test the previous example, you could enter the following code in the Interactive window:

for i = 1 to 10 ; trace.writelni?; next i

Continuing a Command on a Second Line 

You can continue a command onto a second line by ending the line with the continuation character, a backslash (.e.g.). For example:

ui_msg_box("Test of Message Box", "This is the text of \
the message box")

Color Coding 

Xbasic scripts are color coded. This makes them easier to read, and it helps you spot errors. For example, as shown in the picture below, function names are shown in green, comments are shown in blue, commands to declare variables are shown in purple, constant values (i.e. text values) are shown in gray etc.

When a script has been edited, but has not yet been saved, an asterisk appears next to the script name on its tab.

Dockable Panels 

The Code Editor contains four dockable panels that are initially located at the right side of the window. These are:

  • Xbasic Explorer 

    allows you to examine the properties of Alpha Five and your application

  • Code Library 

    organizes, stores, and inserts code elements into your scripts and functions

  • Function Explorer 

    helps you to navigate to a function within the current script

  • Scripts/Functions 

    helps you to find and open a script or function within your application

Status Bar 

The status bar at the bottom of the Code Editor window is customizable. Features of the status bar include:

  • User customizable layout ( View > Settings > Preferences > Script Editor > Statusbar ). Refer to Status Bar Editor.

  • Display of the name of current function (if any) that you are editing

  • The ability to jump to any line number in the script.

  • A pop-up menu showing all functions in the current script. Select a function to navigate to the function.

See Also