![]() |
maxreason@gmail.com | max reason |
XBasic web-pages
XBasic
overview - features, capabilities, screenshots.
XBasic newsbits - the latest news and views of XBasic.
XBasic freeware - download & installation instructions.
XBasic questions - frequently asked questions -- FAQs.
XBasic quick-start - begin programming XBasic quickly.
QuickBasic to XBasic - translate QuickBasic to XBasic.
QuickBasic keywords - QuickBasic to XBasic keywords.
XBasic documentation - complete HTML
documentation online.
XBasic keywords/operators/scopes/types - language reference.
XBasic projects - enhance & extend applications &
documentation.
XBasic e-links - other web-sites with XBasic samples and
information.
XBasic forum - mail-list forum for all
XBasic programmers - questions, answers, advice, samples, etc.
comments, suggestions, corrections
XBasic FAQ - frequently asked questions
The following answers to frequently asked questions about XBasic are broken into sections, but kept on one large and growing web-page so you can find all FAQs that mention your topic in a single Edit + Find.
sections
XBasic history
XBasic portability
XBasic implementation
XBasic troubleshooting
XBasic programming language
XBasic function libraries - Xma = math
XBasic function libraries - Xst = standard
XBasic function libraries - Xui = GuiDesigner
XBasic function libraries - Xgr = GraphicsDesigner
XBasic function libraries - Xcm = complex numbers
XBasic function libraries - Xin = internet / networking
When
was XBasic developed?
The first implementation of XBasic was developed in 1988 for the Motorola 88000 RISC CPU
and UNIX. XBasic ported to WindowsNT in 1992 and tested on alpha and beta developer
pre-releases of WindowsNT so XBasic was available when WindowsNT was released.
XBasic was also ported to SCO and ESIX UNIX. Finally, XBasic was ported to Linux in
1995. XBasic was made available as freeware on ~ 1999 May 5th.
How
many implementations of XBasic exist?
Two up-to-date implementations of XBasic exist - one for Windows95/NT one for Linux.
Implementations of XBasic for Motorola 88000 RISC CPU and SCO UNIX were not kept
up-to-date. XBasic has not been worked on in a major way since 1995, but works okay
on Windows95/98/NT/2000 & most Linux systems. Some minor enhancements and bug
fixes have been added to Windows XBasic since it has been freeware, but the Linux
implementation was not brought into sync because I've had no Linux system for many months.
How
portable are XBasic programs between the Windows and Linux implementations?
XBasic programs developed on either implementation will run on the other without any
changes, even programs with lots of graphics and/or extensive GUIs. Of course this
portability is lost if your program calls any operating-system, API or
non-portable-function-library functions. The XBasic function libraries are quite
extensive and are available in both implementations, so few programs need to "go
around them".
How
can XBasic programs with graphics be portable between Windows and Linux?
One of the most fundamental built-in XBasic function-libraries is GraphicsDesigner.
XBasic programs draw graphics by calling functions in GraphicsDesigner, which is available
on all XBasic implementations. GraphicsDesigner provides a comprehensive set of
fundamental graphics and message-queue capabilities upon which all additional graphics and
message processing is based.
How
can XBasic programs with GUIs be portable between Windows and Linux?
Another built-in XBasic function library is called GuiDesigner.
GuiDesigner draws all graphics and processes all messages by calling functions in
GraphicsDesigner. Since every function in GraphicsDesigner is available on all
implementations of XBasic, GuiDesigner is automatically portable. Put another way,
GuiDesigner does not call any operating-system or API functions. In fact,
GuiDesigner is written entirely in XBasic and can even be loaded and run as an application
in the XBasic program development environment.
Is
the XBasic programming language more like QuickBasic or VisualBasic or what?
XBasic syntax is much closer to QuickBasic than VisualBasic. But XBasic is far
cleaner and more consistent than QuickBasic, so XBasic is much easier to learn, read and
understand. XBasic is also vastly more flexible and powerful than any previous
BASICs.
What
language is XBasic written in?
XBasic is written entirely in XBasic, except for 400KB of assembly language - most of that
is comments. XBasic does not call any functions in any C function library.
XBasic is self-contained - the only functions XBasic calls are operating-system API
functions. Linux XBasic implements all its graphics and message processing by
calling functions in the low-level XWindows xlib function library.
Is
XBasic really a compiler, or does it interpret some intermediate language?
When you run programs in the XBasic program development environment, XBasic translates
your XBasic source program directly into executable binary machine instructions in RAM
memory, then executes it. When you have finished debugging an XBasic program, you
can compile it into an assembly language file. XBasic also creates a makefile
containing the steps required to assemble and link the assembly language file to create an
executable - either an EXE or DLL.
FAQ - XBasic programming language
Is
the XBasic language case-sensitive like C, or case-insensitive like QuickBasic?
The XBasic programming language is entirely case-sensitive, like C and most languages.
If XBasic had not been written in this way, its compatibility with
operating-systems, APIs, and function-libraries would have been severely limited.
Can
XBasic programs do simple console input/output, for example the PRINT statement?
Yes. XBasic has a default console window and classic BASIC input/output statements,
including PRINT. Even XBasic programs with GUIs can display and PRINT to the console
window.
Can
XBasic programs call operating-system or API functions?
Yes. XBasic programs can call operating-system and API functions directly. But
XBasic programs should not call operating-system or API functions unless you cannot
accomplish what you want with a function in one of the XBasic function-libraries. In
particular, do not try to work around the XBasic message queue.
Can
XBasic programs call functions written in C?
Yes. XBasic functions are C compatible. By default, XBasic functions follow
STDLIB protocol, but you can specify "classic C function protocol" by declaring
a function with CFUNCTION. Virtually all Windows API functions follow the STDLIB
protocol, and are therefore inherently compatible with XBasic.
Does
XBasic save XBasic source programs to disk as text or in another form?
The XBasic program development environment saves XBasic programs to disk as text files -
always.
Does
XBasic hold source programs as text or in token-form?
When the XBasic program development environment loads an XBasic program, it converts the
program text into binary "tokens" and holds the program in that form during
execution and debugging.
Does
XBasic display the whole source program or only one function at a time?
XBasic displays only one function at a time, but you can switch between functions freely.
You can also convert programs back and forth between "program-mode" and
"text-mode". When in text-mode, a program is treated as text, so the
entire text of the program is visible. Of course you cannot execute or debug the
program in text-mode. When you switch back into program-mode, XBasic converts the
program back into its binary tokens. Whenever you switch from one function to
another, XBasic converts the tokens for that function into text and displays it.
Does
XBasic maintain the format of my program text?
Yes. The XBasic binary tokens contain space and tab information, so no matter how
many times a function is converted back and forth between text and tokens, the text form
is unchanged.
Can
XBasic pass function arguments "by-value"?
Yes. In fact, XBasic passes function arguments by-value unless otherwise specified.
In contrast, most BASICs pass function arguments by-reference. XBasic
programs can pass function arguments by-value or by-reference, as in
a=xfunc(a,@b) respectively. When a program passes a variable
by-value, any changes the called function makes to the argument have no effect on the
value of the variable in the calling function when the called-function returns. When
a program passes a variable by-reference, any changes the called function makes to the
argument effect the value of the variable in the calling function when the called-function
returns.
Can
XBasic programs pass arguments by-address as many C functions require?
Yes. XBasic can pass/receive function arguments by-address
to/from C functions, as in
a=cfunc(&c). However, the notion of passing arguments by-address
in this manner is a fiction - in both XBasic and C. Actually, both XBasic and C always pass arguments by-value, but both have the & address-of operator, which lets
the program pass the address of a variable by-value, which has the same result.
If
XBasic always passes arguments by-value, how can passing by-reference work at all?
XBasic is tricky! In fact, XBasic does always pass
function arguments by-value. The question is, therefore, how can the called-function
change the value of an argument variable in the calling-function? Answer: it can't.
In fact, the called-function cannot even know whether the arguments it receives
were passed to it by-value or by-reference - after all, a function can be called from many
places and the arguments can be passed in any mix of by-value and by-reference each time!
Yikes! How can XBasic do the "impossible"? Easy, in fact.
When XBasic compiles a function-call, XBasic passes arguments by-value, then calls
the function. The next code XBasic generates will be executed when the
called-function returns. XBasic knows exactly which arguments were passed
by-reference, and where it passed them. So XBasic generates code to read the final
value of arguments passed by-reference and assign them to the corresponding variable in
the calling function, thereby creating the effect of pass-by-reference.
How
do I declare how a function argument is passed?
As mentioned in the previous answer, XBasic programs can pass
arguments in any mix of by-value and by-reference each time it calls an XBasic function!
Thus the notion of declaring how a particular argument is passing is meaningless.
Which
kind of argument passing is more efficient in XBasic?
XBasic passes numeric variables by-value more efficiently
because no code is required to read the final value of the argument and assign it to the
variable.
XBasic passes string variables by-reference more efficiently because XBasic simply passes the address of the string variable directly. When the called-function returns, XBasic need only read the argument and assign it to the string variable. Any changes the called-function made to the argument string are thereby instantly and automatically made to the string variable. When an XBasic program passes a string variable by-value, the string is duplicated, the duplicate is passed by-reference, and final result is freed.
XBasic passes array variables and composite variables by-reference only.
How
does the XBasic parser determine the boundary between language elements?
First, XBasic skips "white-space", which includes space-characters,
tab-characters, every character whose value is less-than 0x20 or greater-than 0x7F.
Starting with the first non-white-space character, XBasic appends characters until the
cumulative result would not be a valid language-element. To contrast this parsing
method with old-style BASIC, consider the following source line: FORK=ATOM .
In old-style BASIC, FORK=ATOM means:
' FOR is a statement
' K is a variable
' = is an operator
' A is a variable
' TO is a keyword
' M is a variable
In XBasic, FORK=ATOM means:
' FORK is a variable
' = is an operator
' ATOM is a variable
How
does the Linux version of XBasic draw graphics and GUI elements?
XBasic calls functions in the XWindows xlib library only -
nothing else.
When
will you answer more questions?
When I receive questions by email I generally point the person at this FAQ, the
documentation in \xb\doc, or answer the question. Whenever I have free time I review
my email and add more questions and answers.
Question?
Answer.
Question?
Answer.
What are some important features of XBasic?
![]() |
sophisticated source level debugger with breakpoints, stepping, frames, variables, etc. | |
![]() |
function libraries for advanced math, complex math, matrix math, graphics, etc. | |
![]() |
interactive GuiDesigner and GUI function library | |
![]() |
integer data types: SBYTE, UBYTE, SSHORT, USHORT, SLONG, ULONG, XLONG, GIANT | |
![]() |
floating point data types: SINGLE, DOUBLE | |
![]() |
built-in single and double precision complex number types: SCOMPLEX, DCOMPLEX | |
![]() |
built-in single and double precision complex arithmetic (+, -, *, /) | |
![]() |
scopes: AUTO, AUTOX, STATIC, SHARED, SHARED /group/, EXTERNAL, EXTERNAL /group/ | |
![]() |
arrays of all types, including strings and composites | |
![]() |
arrays are manually elastic (they can be resized anytime) | |
![]() |
strings are automatically elastic (they resize automatically) | |
![]() |
complete set of bitfield operators and intrinsics | |
![]() |
arithmetic shift operators ( <<< and >>> ) | |
![]() |
bitwise shift operators ( << and >> ) | |
![]() |
logical operators (!, !!, &&, ||, ^^) | |
![]() |
functions are fully encapsulated by default | |
![]() |
function arguments are passed by value by default | |
![]() |
function arguments can be passed by value, reference, address | |
![]() |
function arguments can be numerics, strings, arrays, composites | |
![]() |
XBasic functions can call C functions, and be called by C functions | |
![]() |
XBasic memory allocation is faster than C equivalent | |
![]() |
strings testable for TRUE/FALSE in IF, CASE, WHILE, UNTIL, etc. | |
![]() |
arrays testable for TRUE/FALSE in IF, CASE, WHILE, UNTIL, etc. | |
![]() |
arrays redimensionable without losing contents | |
![]() |
conventional regular arrays and tree-structured irregular arrays | |
![]() |
subarrays can be detached from any node and attached to any other | |
![]() |
computed GOTOs, GOSUBs, function calls | |
![]() |
functions can return values of any type, or no value (VOID) | |
![]() |
DO...LOOPs can have WHILE or UNTIL tests at top, bottom, both | |
![]() |
enhanced loop constructs (DO DO, DO LOOP, DO FOR, DO NEXT) | |
![]() |
shell and subtask execution directly from XBasic | |
![]() |
complete type conversion with natural syntax | |
![]() |
system constants with pre-defined values | |
![]() |
SELECT CASE substantially enhanced |