Xbasic Guide

Xbasic Guide

ALPHA SOFTWARE CORPORATION Xbasic Guide An introduction to Xbasic Examples used in this book are fictitious. Names, places, and incidents either are the products of the author’s imagination or are used fictitiously. Any resemblance to actual persons, living or dead, events, or locales is entirely coincidental. Copyright © 2020 by Sarah Mitchell and Alpha Software Corporation All rights reserved. First Published: January 13, 2020 Revised Edition: January 27, 2020 Published by Alpha Software Corporation www.alphasoftware.com Table of Contents 1 Welcome to Xbasic in Alpha Anywhere ................................................................................................ 4 1.1 Setting Up Your Workspace .......................................................................................................... 4 1.1.1 Create the Workspace........................................................................................................... 4 1.1.2 Create the Northwind Demo Connection String ................................................................... 4 1.2 The Interactive Window ................................................................................................................ 4 1.2.1 Interactive Window Commands ........................................................................................... 8 2 The Xbasic Programming Language .................................................................................................... 10 2.1 Variables & Data Types ............................................................................................................... 10 2.1.1 Data Types ........................................................................................................................... 11 2.1.2 Redeclaring Variables .......................................................................................................... 11 2.1.3 Converting Data Types ........................................................................................................ 13 2.1.4 Default Values ..................................................................................................................... 14 2.2 Expressions .................................................................................................................................. 16 2.2.1 Operators ............................................................................................................................ 16 2.2.2 Delimiters ............................................................................................................................ 20 2.2.3 Comments ........................................................................................................................... 21 2.3 Conditional Statements .............................................................................................................. 22 2.3.1 IF statements....................................................................................................................... 22 2.3.2 SELECT Statements .............................................................................................................. 23 2.4 Loop Statements ......................................................................................................................... 24 2.4.1 FOR Loops ........................................................................................................................... 24 2.4.2 FOR EACH: Looping Over Lists, Collections, or Arrays ........................................................ 25 2.4.3 Skipping FOR Loop Iterations .............................................................................................. 27 2.4.4 Exiting FOR and FOR EACH Loops ....................................................................................... 28 2.4.5 WHILE Loops ....................................................................................................................... 28 2.4.6 Exiting WHILE Loops ............................................................................................................ 29 2.5 Functions ..................................................................................................................................... 30 2.5.1 Passing Data to Functions ................................................................................................... 30 2.5.2 Declaring Optional Arguments ............................................................................................ 31 2.5.3 Returning Values ................................................................................................................. 31 ALPHA SOFTWARE CORPORATION 1 2.5.4 Returning Data Using Arguments ....................................................................................... 33 2.5.5 Function Pointers ................................................................................................................ 34 2.6 Arrays, Object Pointer Variables, and Collections ...................................................................... 35 2.6.1 Arrays .................................................................................................................................. 35 2.6.2 Object Pointer Variables ..................................................................................................... 45 2.6.3 Object Pointer Arrays (Property Arrays) ............................................................................. 46 2.6.4 Built-in Xbasic Objects ......................................................................................................... 48 2.6.5 Collections ........................................................................................................................... 50 2.7 Capturing and Logging Errors ...................................................................................................... 51 2.7.1 ON ERROR GOTO ................................................................................................................. 51 2.7.2 Logging: Using the Trace Log .............................................................................................. 52 3 Working with SQL Data Using Xbasic .................................................................................................. 53 3.1 AlphaDAO Connections ............................................................................................................... 53 3.2 The SQL Namespace .................................................................................................................... 55 3.3 Connecting to the Database ....................................................................................................... 56 3.4 Executing a Query ....................................................................................................................... 56 3.5 Processing the Query Results ...................................................................................................... 57 3.5.1 Reading Data from the Current Record .............................................................................. 57 3.6 Closing Connections .................................................................................................................... 59 3.7 Creating Queries with Arguments............................................................................................... 59 3.8 Converting Query Results to Other Formats............................................................................... 60 3.8.1 Converting a ResultSet to an Xbasic Variable ..................................................................... 60 3.8.2 Converting a ResultSet to JSON, XML, or CSV ..................................................................... 62 3.8.3 Writing a ResultSet to a JSON or Excel File ......................................................................... 63 3.9 Transactions ................................................................................................................................ 64 3.10 Writing Portable SQL Queries ..................................................................................................... 66 3.10.1 Portable INSERT Statements ............................................................................................... 68 3.10.2 Portable UPDATE and DELETE Statements ......................................................................... 69 3.10.3 SQL Query Genie ................................................................................................................. 72 3.11 Xbasic SQL Helper Functions ....................................................................................................... 74 3.12 Other Helpful Tools ..................................................................................................................... 77 3.12.1 Xbasic SQL Actions Code Generator.................................................................................... 77 ALPHA SOFTWARE CORPORATION 2 3.12.2 Xbasic Code Glossary .......................................................................................................... 78 4 Calling Xbasic Scripts in Your Applications .......................................................................................... 80 4.1 How does an Ajax Callback work?............................................................................................... 80 4.2 Where are Ajax Callback Functions Defined ..............................................................................

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    97 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us