| 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.
- In File Explorer, go to the folder containing the xblite installation.
- The environment variables PATH and INCLUDE for XBLite need to set.
- 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.
- Now it is OK to run the XSED editor program, xsed.exe, which can be found in the \xblite\bin folder.
- 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.
- From the top menu, choose File > New. There will be a new tab with a file name of untitled1.x.
- Type or copy/paste the following lines in the editor.
CONSOLE
IMPORT "xst"
DECLARE FUNCTION Entry()
FUNCTION Entry ()
PRINT "hello world"
a$ = INLINE$ ("press enter to quit")
END FUNCTION
END PROGRAM
With the completed program entered in the editor, save, compile, build, and run the program helloworld.exe.
- From the top menu, choose File > Save, and save the file with the same or helloworld.x name with an .x extension.
- From the top menu, choose Run > Compile, or press the Compile toolbar button (a popup tooltip will display the purpose of each toolbar button)
- From the top menu, choose Run > Build, or press the Build toolbar button.
- 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:
hello world
press enter to quit
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.
- In XSED, from the menu, select File > New
- Then Code > Template Code > New Console Program
'
' A console program template
'
VERSION "0.0001"
CONSOLE
'
IMPORT "xst" ' Standard library : required by most programs
' IMPORT "xsx" ' Extended standard library
' IMPORT "xio" ' Console input/ouput library
' IMPORT "xst_s.lib"
' IMPORT "xsx_s.lib"
' IMPORT "xio_s.lib"
' IMPORT "gdi32" ' gdi32.dll
' IMPORT "user32" ' user32.dll
' IMPORT "kernel32" ' kernel32.dll
' IMPORT "shell32" ' shell32.dll
' IMPORT "msvcrt" ' msvcrt.dll
'
DECLARE FUNCTION Entry ()
'
'
' ######################
' ##### Entry () #####
' ######################
'
FUNCTION Entry ()
a$ = INLINE$ ("Press Enter to quit >")
END FUNCTION
END 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:
Library | DLL | Description |
---|---|---|
BigNumXB | bignumxb | BigNumXB is large integer arithmetic library |
GreenXML | gxml | GreenXML is simple, fast, XBL parser |
Turtle | turtle | Turtle is a graphics library which draws using a virtual “turtle” using simple instructions |
U64 | u64 | U64 is a 64-bit unsigned integer arithmetic library |
UNC | unc | Unc is a collection of functions to aid in the making and managing of unicode structures |
Xbm | xbm | Xbm is a bitmap library for loading and saving bitmap images |
Xdb3 | xdb3 | Xdb3 is a simple dbase III+/IV file access library |
Xil | xil | Xil is an image processing library to transform, filter, and perform masking operations on images. |
Xinftp | xinftp | XinFtp is an ftp file transfer protocol library |
Xmao | xmal | Xmal is a LONGDOUBLE floating point math library |
Xpr | xpr | Xpr contains functions to print text, pages, bmp images, or drawing graphics to the printer |
Xsp | xsp | Xsp is sprite animation library |
Xsts | xsts | Xsts is a statistics library |
Xwav | xwav | Xwav 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.