Server Side Processing


Tasks like generating large reports, sending batches of email, and other resource-intensive tasks are typically run on the server, to limit the burden on the mobile device or browser.

The code that Alpha Anywhere uses to run these tasks is written in Xbasic, a programming language similar to Visual Basic. Most of the Xbasic code for an application is written automatically when you create your application. However, there may be instances in which you want to include your own server-side code to add functionality that is not included in Alpha Anywhere. This can be accomplished in several ways.

To create your own server side code, you can:

  • Write your own Xbasic code.

  • Use a point-and-click interface called Action Scripting to write Xbasic for you.

  • Use another programming language to create a .NET assembly and call the assembly from Xbasic.

  • Use Javascript to create a Node.JS module and call the module from Xbasic.


Node.JS is a popular program for writing server side utilities in Javascript. Alpha Anywhere now has tight integration with Node and you can now define your own Node modules that can be called from Xbasic.

To create a new 'Node Service' that can be called from Xbaisc, you create a new .js file in the Node_Services folder in the Alpha Anywhere executable folder. The syntax for this .js file is the syntax you would use for any Node module. To call a Node service from Xbasic, you:

  • dim an instances of the helper::V8 object

  • construct a JSON string that defines the Node service you want to call and the parameters you wan to pass to the Node service

  • call the .NodeRequest() method of the helper::V8 object instance

In the following example, we have defined a trivial Node service that takes as its input two variables, 'firstname' and 'lastname' and sends back a string showing:

Hello firstname lastname.

The Node service in this example is called 'hello'. Therefore the '_command' property of the JSON command object is set to 'hello' You must also set an '_id' property in the JSON command object. This can be any value. Using a UUID for this value is convenient.

The Node service is called using the .NodeRequest() method and the result is returned as a JSON string with properties for the error text (if there was an error) and 'result' - the result of the request. The JSON response can be parsed to get Xbasic varibles, or the json_extract() function can be used to extract the 'result' property.

dim n as helper::V8
dim p as p
'generate an id for the request we are about to send to Node.
'we just use a GUID for convenience
p._id = api_uuidcreate()

'set the _command property. This is the name of the Node service we want to call
p._command = "hello"

'specify any variables you want to pass to the Node service
p.firstname = "Nellie"
p.lastname = "Jones"

'convert the Xbasic .dot variable to a JSON string.
dim jsonCommand as c 
jsonCommand = json_generate(p)

= {"_id":"id1","error":"","result":"Hello Nellie Joness"}

Here is how the corresponding Hello.js file is defined. This file must be in the Node_Services folder in the Alpha Anywhere executable folder. This is a standard Node module. It can 'require' any other Node modules that you have written, or that have been installed using NPM (the Node Package Manager).

exports.handler = function(packet,response,sendResponse) {
    var e;
    var attachments = null;
    var msg = 'Hello ' + packet.firstname + ' ' + packet.lastname;
    response.result = msg;

If you edit the .js file in the Node_Services folder after having called it, your edits will not be seen until you shutdown the Node service. The next time you call the Node service you will see a short delay as Node starts up.

To shut down the Node service you can all the .NodeShutDown() method on the helper::V8 object instance. For example, in the above example the helper::V8 object instance was called 'n', so the following command will shut Node down.

Node.exe is automatically installed in the Alpha Anywhere executable folder when you install Node. You do not need to install Node yourself.


Xbasic is the server-side programming language of Alpha Anywhere, and is similar to Visual Basic and other languages.

  •  Xbasic Tutorials

    The Xbasic tutorial is the recommended way to get acquainted with and start programming in Xbasic. This tutorial uses a Windows desktop application as the example, but still shows you the basics for mobile and desktop/web applications. See more.

  •  The Interactive Window

    The Interactive Window allow you to test snippets of code before you add them to a script. See Using the Interactive Window.

  •  Libraries and Modules

    Keeps code organized and lets you share code with multiple components.

    •  AEXs

      let you compile your scripts and functions into a compiled file, allowing global access to functions. For details about creating AEX files, see Compiling Scripts and Functions. For details on loading AEX files onto the server so that you can use them see Making User-Defined Functions Available to a Web Application.

    •  Xbasic Function Libraries

      are a newer alternative to using AEX files for reusing Xbasic code. They can be linked into components (Grids, UXs, custom components, and tabbed UIs) in the properties section of these components. See video.

    •  Modules

      let you package up Xbasic functions and classes for reuse, in a method similar to the method used by Node.JS. Functions are then brought into any Xbasic code using the Require() method. (This is not to be confused with the "Module" object in Xbasic) click here to watch the video.

  •  Xbasic Reference Guide

    includes a language reference and information about functions, expressions, operators, variables, the interactive window and more. Much of the material uses Windows desktop applications as examples, but the information also applies to mobile and desktop/web applications as well. See the Xbasic Reference Guide.

  •  Directory of Functions and Methods

    includes links to organized tables of functions and methods that are included with Xbasic.