In short it implements the most common (and simple) elements of the langugage plus some Grafic facilities; anyone, who has ever written basic-programs on a C64 should feel at home.
This page is the html-description of the yabasic. There is no further
documentation, neither a unix-man-page nor a win95-helpfile.
yabasic
[options] [filename]
Where filename is the name of the file, containing the
basic-Program.
If you type yabasic
without any filename, the program
will read from standard input until you type RETURN
twice.
-h
-help
or
-?
are accepted as well.
-fg
foreground-color
-bg
background-color
-geometry
geometry-string
+10+10
),
but any window size will be ignored.
-display
Name-of-Display
-font
Name-of-font
-i
w
contains f
and e
).
and can be one of:
d
n
w
e
f
w
.
yabasic -i d test.yab
calls the interpreter to execute the file test.yab
,
reporting in detail about its work.
yabasic test.yab
The same as above, but with inolevel=warning (the default).
yabasic
Now You have to type in your program by hand. Press RETURN
twice, when done.
yabasic*foreground: blue yabasic*background: gold yabasic*geometry: +10+10 yabasic*font: 9x15
-h
-help
or
-?
are accepted as well.
-geometry
geometry-string
+10+10
will place the grafic-window 10 pixels below
and left of the upper left corner of the screen.
-font
Name-of-font
decorative, dontcare, modern,
roman, script, swiss
-i
w
contains f
and e
).
and can be one of:
d
n
w
e
f
w
.
Yabasic stores its defaults under:
HKEY_LOCAL_MACHINE/SOFTWARE/yabasic
The first one introduces half of the language:
Among others, the following things can be seen:rem this is a simple test-program ! REM This is a comment # this is a comment too label loop for a=1 to 100 step 2:print a:next a input "once more ? (y/n)" a$ if (a$="y" or a$="j") then goto loop fi clear screen input at (10,5) "please enter your first and second name: " first$,second$ print at(10,10) "bybye ",first$," ",second$
REM
-statement is used to start comments, which
extend til the end of the line. A hash ('#') has the same effect,
except that it must appear as the very first character within a line.
This feature is intended for Unix allowing a yabasic-program to
specify yabasic as the appropriate interpreter (e.g. something
like "#!/usr/bin/yabasic")
for
-loop. The step
-part
is optional, its got to be a plain number !
a,b,LongName
and strings
like a$,b$
marked with a trailing Dollar sign.
if
statement has an optional else
branch, and has to be ended with fi
or endif
first$
receives all the input up to the
first space and second$
receives all the rest.
clear screen
-command clears the terminal.
at(x,y)
-clause, that places the cursor at the
specified position. x
and y
are bounded by the size of your terminal; this size is stored
within the internal variables
yabscreenwidth
and yabscreenheight
.
Before using the at(x,y)
-feature, any program has to call
clear screen
.
gosub
statement
In fact, it shows the even coolerrem This Program is good for nothing ... input "Please enter a number" num on num gosub one,two,three,four,five,six,seven end label one:print "one":return label two:print "two":return rem rem guess you can imagine the rest ... rem
ON GOSUB
statement;
depending on the value of num
the execution is continued
at the labels
one
, two
and so on. ON GOTO
can be used as well.
Furthermore you see, that the input statement can handle an
optional prompt string (which is not separated by a comma)
READ
, DATA
,
RESTORE
:
Therem Show READ,DATA,RESTORE and ARRAYS ! restore table:read length dim number(length),name$(length) rem NOTE: number has length+1 elements ! rem The index can start from zero ! for a=1 to length:read number(a),name$(a):next a label table:rem here comes the data data 4,1,"one",2,"two",3,"three",4,"four"
RESTORE
statement comes with an optional label;
DATA
lines can appear anywhere in the code.
As you see, every array has to be dimed before first use;
there is no limit on array size but array dimension has to be
less than 10.
Every file has to be opened; giving it:open 1,"numbers","w" print #1 "one, two, three" close 1
fopen()
; so its meaning
can be found in any C-book.
Here is a selection:
r
: read only.
w
: overwrite file if it already exists, create
and write otherwise.
a
: append to file.
close
(e.g. close 1
) and you may test with eof()
if a file has reached the end
(e.g. if (not eof(1)) then ...
)
wait
seconds
pause
will be understood as well.
bell
sin(3.14159)
gives -1.0.
By the way: there is a predefined variable PI
,
so you might as well write sin(PI)
.
atan
offers an additional feature:
atan(x/y)
can be replaced by atan(x,y)
;
the latter comes from the C-function atan2()
and
has the advantage of giving the right angle in the full span
from 0 to 2*PI.
EULER
sqrt(2)
gives 1.41421.
int(3.141)
gives 3.0 and frac(3.141)
gives 0.141.
min(2,3)
gives 2 and max(2,3)
gives 3
as a result.
left$("12345",2)
gives "12"right$("12345",2)
gives "56"mid$("12345",3,2)
gives "34"a$="123456":mid$(a$,3,2)="ab"
a$
with the content "12ab34". The same
applies for left$
and right$
.
len("123456")
gives 6.0.
val("12.0")
gives
12.0 and val("Hello2.0")
gives 0.0.
str$(12.0)
gives "12.000000".
asc("b")
gives 98.
chr$(98)
gives "b".
lower$("ABcd12")
gives "abcd12".
upper$("ABcd12")
gives "ABCD12".
instr("abcdef","bc")
gives 2.
inkey$
as
a command (without assignement); in this case inkey$
just waits for a key to be pressed.
system$("ls")
(for Unix) or system$("dir")
(for Windows) give back
a directory listing.
You may use the internal variable
yabos$
to find out what's your operating system.
system$
, but sends its
output directly to the terminal.
The command gives back the return-code
of its argument, but you can ignore this value and call
system()
as a command (i.e. without assignement).
As You can see from the listing, there are commands to open, clear and close a single window, to draw lines, circles, text and dots.rem rem All features of grafic rem print "Test of Grafic" open window 400,400 line 200,0 to 200,400 line 0,200 to 400,200 text "test",120,120 text 100,100,"test" : rem both variants work ... input "press RETURN ..." a$ clear window for a=0 to 400:dot a,200+100*sin((a-200)/30):next a circle 200,200,150 input "Press RETURN ..." a$ clear window close window
open window
takes three arguments, specifying the x,y-extension
of the window to be created and the height of the font, used
for printertext. You can just as well call open window
with zero or two arguments. Missing data will be taken from
the appropriate internal variables
yabwinwidth, yabwinheight, yabfontheight
.
This is all there is for grafic !
So, you can not change colors or any line properties, you can not open multiple windows and you can not erase any single dot. Some of these features might be added in the future ...
The size of the window is specified in the open window
command;
any value given in the geometry-resource is ignored.
As you see, there are only two commands related with printing:open printer "printeroutput" open window 400,400 line 200,0 to 200,400 close printer close window
open printer
[filename]
close printer
open printer
and
close printer
is mirrored to paper.
The grafics will be scaled to fit on a DIN-A4-sheet.
If you want to print without opening a window, you've got to tell
the computer, how large the window would have been. Yabasic needs
this info to scale the printer-output correctly.
This information can be passed using the three
internal variables yabwinwidth, yabwinheight,
yabfontheight
.
yabwinwidth=100
).
But their value influences the way, yabasic works. Every internal
variable starts with yab
.
As yabasic runs under Unix and Windows, a yabasic-program may want to
know, which operating systems it is using; this information
can be found in the string-variable yabos$
. This variable
contains the string "windows" or "unix", depending on your operating
system.
Two internal variables are connected with your terminal:
yabscreenwidth
and yabscreenheight
contain the width and height off your terminal window
(e.g. 80 and 25).
clear screen
has been called.There are three internal variables connected with grafics:
yabwinwidth
: specifies the the default width of the
grafic window. This value will be used, if the call of
open window
doesn't specify this value. The initial
value is 100.
yabwinheight
: specifies the the default height of the
grafic window. This is a fallback-value too. The initial value is 100.
yabfontheight
: specifies the the default height of the
graficfont. This is a fallback-value too. The initial value is 10.
yabinfolevel
set this to any of the next five
variables, to change the infolevel during execution of the program.
yabfatal
: fatal-infolevel.
yaberror
: error-infolevel.
yabwarning
: warning-infolevel.
yabnote
: note-infolevel.
yabdiagnostic
: diagnostic-infolevel.
yabinfolevel=yabnote
, setting
the infolevel to note.
Although yabasic behaves mostly like an interpreter, in fact it is not;
Rather it's a compiler: If you give it any basic-code for execution,
the code is compiled yielding instructions for a simple stack-machine;
these instructions are then interpreted immedeately, so that you will never
get in touch with the stack-machine. You can find out the time
needed for this process, if you invoke yabasic with infolevel set to
note
.
COPYING
which comes along as part of the distribution, or
can be obtained from the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA.
When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights.
We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations.
Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all.