Xbasic Guide - An introduction to Xbasic
Description
A guide to Xbasic for web and mobile application developers.
Welcome to Xbasic in Alpha Anywhere
Alpha Anywhere is a powerful application development software package. Most of what you need to do can be built in Alpha Anywhere without writing any code. That being said, server-side scripts can extend the core functionality that comes with Alpha Anywhere to incorporate data validation, create workflows, or build complex server-side routines to automate reporting, business processes, and more. In Alpha Anywhere, Xbasic is used to create server-side scripts to perform various tasks.
The Xbasic programming language implements many of the same constructs (including variables, arrays, functions, conditionals, and loops) as other languages, such as C and JavaScript. Xbasic can also interact directly with Node.js modules and C# .NET libraries.
This guide assumes you are already familiar with Alpha Anywhere and understand how to create workspaces and connection strings.
The goal of this guide is to give you a solid grounding in basic programming concepts needed to use Xbasic to customize your Alpha Anywhere applications to your exact business requirements. You can refer to the Alpha Anywhere Documentation to explore everything Xbasic can do. The best way to learn different Xbasic commands and techniques is through experimentation.
Alternative Learning Resources
A consolidated, beginner-oriented introduction to this Xbasic section is also available as a downloadable PDF: Alpha Anywhere Xbasic Guide (PDF)
Topics Overview
In this guide, we will cover the topics listed below. At the end of each section, you will find a "Next" button you can click to take you to the next section.
- Name
- Description
- The Interactive Window
An introduction to using the Xbasic Interactive Window for writing and testing Xbasic scripts line-by-line.
- Variables and Data Types
An overview of declaring variables, understanding data types, and converting values in Xbasic.
- Expressions
An overview of Xbasic expressions, including operators, precedence, delimiters, and comments.
- Conditional Statements
A guide to using conditional statements, such as IF...THEN and SELECT...CASE, in Xbasic.
- Loop Statements
A guide to using FOR, FOR EACH, and WHILE loop statements in Xbasic to execute code blocks multiple times.
- Functions
Learn how to define, call, and pass arguments to reusable Xbasic functions.
- Arrays, Object Pointer Variables, and Collections
A guide to using arrays, object pointer variables, and collections in Xbasic.
- Capturing and Logging Errors
Learn how to capture and log Xbasic runtime errors using ON ERROR GOTO statements and the Trace Log.
- Working With SQL Data Using Xbasic
A guide to connecting to databases and performing SQL operations (CRUD) using AlphaDAO and the Xbasic SQL namespace.
- Calling Xbasic Scripts in Your Applications
An overview of how to call Xbasic scripts via Ajax callbacks and server-side events in Alpha Anywhere applications.
- The Xbasic Debugger
Learn how to use the Xbasic Debugger to inspect variables, step through code, and troubleshoot scripts in Alpha Anywhere.
Setting Up Your Workspace
Before you begin, you need to create a new Alpha Anywhere workspace and a connection string named "AADemo-Northwind," which is used later in this guide to interface with the sample Northwind database included in the Alpha Anywhere installation.
Create the Workspace
1. Launch Alpha Anywhere
2. Create a new Workspace named "XbasicGuide."
Create the Northwind Demo Connection String
1. Open the Web Projects Control Panel
2. Select Tools > AlphaDAO Connection Strings
3. Click the "Create AADemo-Northwind Connection String" link at the bottom of the window.
4. Confirm creating the connection. Then, return to the Web Projects Control Panel.