| Getting_Started

To get a simple Hello World program to run in the XSED editor, it is first necessary to make sure the installation of XBLite has been completed.


Setup

If you installed XBLite manually by downloading and then unzipping the XBlite package, then one more step is required before opening XSED, the XBLite editor.

  1. In File Explorer, go to the folder containing the xblite installation.
  2. The environment variables PATH and INCLUDE for XBLite need to set.
  3. From the c:\xblite\bin folder, run the program xblite_set_env_vars.exe. This will set the proper environment variables needed for the compiler xblite.exe to find the \include and \lib folders.
  4. Now it is OK to run the XSED editor program, xsed.exe, which can be found in the \xblite\bin folder.
  5. Optionally, dragging the xsed.exe file to the desktop will create a desktop shortcut.

If you installed XBLite with the setup installer, then it is OK to open/run XSED, the XBLite Editor.

To ensure that the editor can find the path to xblite.exe, in the main top menu, go to Options > Compiler. This will open the Compiler Options dialog. At the top of this dialog, there is the path variable setting. This should reflect the full path of the xblite.exe compiler; eg, c:\xblite\bin\xblite.exe. If the path variable setting is not displayed, then click to the right and select the xblite.exe file location from the Open File dialog.


A_Hello_World_program

In XSED, in just a few steps, it is easy to create a simple Hello World console program.

  1. From the top menu, choose File > New. There will be a new tab with a file name of untitled1.x.
  2. Type or copy/paste the following lines in the editor.

With the completed program entered in the editor, save, compile, build, and run the program helloworld.exe.

  1. From the top menu, choose File > Save, and save the file with the same or helloworld.x name with an .x extension.
  2. From the top menu, choose Run > Compile, or press the Compile toolbar button (a popup tooltip will display the purpose of each toolbar button)
  3. From the top menu, choose Run > Build, or press the Build toolbar button.
  4. From the top menu, choose Run > Execute Without Compiling, or press the Execute Without Compiling toolbar button.

Running the program helloworld.exe should open a console window and look like this:

Next we will quickly mention the purpose of each line in the program.

Line 1 : The CONSOLE statement is used to build the program as a console application.

Line 2 : The IMPORT statement will import the DLL library xst.dll which contains the instructions to handle the CONSOLE, IMPORT, PRINT statements and the INLINE$ intrinsic function. The library xst.dll is a default library required for all XBLite programs.

Line 3 : DECLARE FUNCTION is used to declare a function Entry() which may or may not have any parameters. An XBLite program must have at least one function. Functions must be defined/declared before they can be called in the program. The first declared function in the prolog is the entry function which is the program’s instruction starting point.

Line 4 : FUNCTION Entry() begins the code for the function.

Line 5 : The PRINT statement will print to stdout (console) the text “hello world”.

Line 6 : The INLINE$() intrinsic function halts the program, prints a message, and waits for input keystrokes. Without this function, the program would end and the console window would immediately close. Any input keystrokes are returned in variable string a$.

LIne 7 : END FUNCTION defines the end of a function.

LIne 8 : END PROGRAM statement (optional)


Using_Templates

To quickly start a new console program, a template file can be imported.

  1. In XSED, from the menu, select File > New
  2. Then Code > Template Code > New Console Program

Additional_Libraries

Many additional XBLite libraries are included with the XBLite installation are are found in the \xblite\xlibs folder.

These libraries include bignumxb, gxml, turtle, u64, unc, xbm, xdb3, xil, xinftp, xmal, xpr, xsp, xsts, xwav:

LibraryDLLDescription
BigNumXBbignumxbBigNumXB is large integer arithmetic library
GreenXMLgxmlGreenXML is simple, fast, XBL parser
TurtleturtleTurtle is a graphics library which draws using a virtual “turtle” using simple instructions
U64u64U64 is a 64-bit unsigned integer arithmetic library
UNCuncUnc is a collection of functions to aid in the making and managing of unicode structures
XbmxbmXbm is a bitmap library for loading and saving bitmap images
Xdb3xdb3Xdb3 is a simple dbase III+/IV file access library
XilxilXil is an image processing library to transform, filter, and perform masking operations on images.
XinftpxinftpXinFtp is an ftp file transfer protocol library
XmaoxmalXmal is a LONGDOUBLE floating point math library
XprxprXpr contains functions to print text, pages, bmp images, or drawing graphics to the printer
XspxspXsp is sprite animation library
XstsxstsXsts is a statistics library
XwavxwavXwav has functions to create and play wav format files

Before these libraries can be accessed and used, they all need to be compiled and built into individual libraries (DLLs). They can be built individually by running their batch file from a Command Prompt or by double clicking on the .bat file in File Explorer:

c:\xblite\xlibs\turtle>turtle.bat

Or, more easily, run build_all_xlibs.bat which will build all of the xlibs at once.

The build_all_xlibs.bat file is located in the \xblite\bin folder.

c:\xblite\bin>build_all_xlibs.bat

ATTENTION!!
The libraries adt and winx require special compilation due to their use of the M4 preprocessor so they are already pre-compiled and installed. If problems arise, then help is available at the XBLite forum on google groups.


Participate_in_the_XBLite_Community

Join the XBLite forum on Google Groups and get answers to your questions about programming with XBLite.