11:45 08 Oct 2007 Console functions getrow getcol / New console.prog with 'Doskey' line recall facility
00:15 07 Oct 2007 '). '.' duplication operator/ ? help command for console / METABASIC html reporting
as source / further Assemberising.
as source.
11:45 30 Sep 2007 More boundary protection for stacks.
3: type 2 dots '..' at the R$ console and press ENTER.
5 info ENTER will generate the instruction list from the basic source code into file 'info.txt'
6: single dot '.' and ENTER to quit the console.
If you want to try this this in Linux, I can supply the r$ binary.
This page will be frequently updated as the R$ project progresses.
This uses a very simple console, itself written in R$, enabling single line expressions to be tested and recorded in 'log.txt' with their results.
This is automatically derived from the R$.bas source file, so will always be 'in sync' with the latest version.
The numbers in the second column specify how many parameters are used by each function followed by the change to the the stack pointer.
| | R$ ' |
| | An Object Oriented postfix Language ' |
| | Charles E V Pegge ' |
| | Start: 1 Sept 2007 - ' |
| | updates 12:43 15 Oct 2007 ' |
| | ' |
| | ' |
| | Preprocessed with R$ self coding manager ' |
| | Compiled with Freebasic v0.18 ' |
| | ' |
| | ' |
| | -----------------------------------' |
type | 0+1 | create a type definition |
union | 0+1 | created a union definition |
| | INTRINSIC TYPES USED IN type STATEMENT |
| | --------------------------------------- |
cdecl | | c C call |
stdcall | | k standard system vall |
int1 | | b single unsigned byte |
int2 | | i 1 byte signed integer |
int4 | | l 4 byte signed integer |
int8 | | q 8 byte signed integer |
real4 | | s 4 byte single precision floating point |
real8 | | d 8 byte double prevision floating point |
| | z n bytes fixed length string including null terminating byte |
| | --------------------------------------- |
gettype | 1+1 | get variable type code |
settype | 2-1 | set variable type code |
getname | 1+1 | get name of variable (derefrenced) |
nderef | 0+0 | suppress derefencing on next variable |
getid | 1+0 | get the index if the quoted variable |
setname | 2-1 | set the name of a variable |
machinex | 0+1 | machine code sequence of opcodes, extended call |
machine | 0+1 | machine code sequence of opcodes. simple call |
args | 1-1 | number of args taken from stack in a 'def' procedure |
incr | 0+0 | increment a number variable |
decr | 0+0 | decrement a number variable |
len | 1+1 | get length of any variable |
then | 0+0 | optional word with no effects |
if | 0+0 | if (followed by condition word) .. endif |
| | -------------------------------------- ' |
eq | | if equal |
lt | | if less than |
le | | if less than or equal |
gt | | if greater than |
ge | | if greater that or equal |
ne | | if not equal |
true | | if equal |
false | | if not equal |
is | | if non zero (or len string>0) |
null | | if zero (or empty string) |
void | | if zero (or empty string) |
| | -------------------------------------- ' |
endif | 0+0 | the end of an 'if' block |
cmp | 2-1 | compare operands and set the sign flag but make no changes |
def | 0+1 | define a procedure (and step over) |
exit | 0+0 | exit from a bracket block |
exec | 2+0 | call a string containing R$ script |
end | 0+0 | end of def procedure |
returns | 1+0 | number of params to leave on stack after leaving a def |
array | 1-1 | specify array eg: 40 array myarray |
idx | 1-1 | index to array eg: 40 idx myarray |
pop | 0-1 | deallocat the last var by decrementing the stack pointer (this is a build upwards |
repeat | 0+0 | block repeat The block is defined by () brackets |
ref | 0+0 | put a reference to a variable on the stack eg: ref myvar |
to | 0+0 | assign current stack content to a named variable eg: 42 to myvar |
swap | 2+0 | swap last 2 members on the stack |
state | 0+0 | store R$ state in locations @1..@7 / a snapshot |
exist | 1+0 | does something exist eg: "myvar" exist if false then 42 : myvar endif |
find | 1+0 | find a variable and place it in current posotion eg: "myvar" find if true ? endif |
examine | 1+1 | markup structure and content of a low level UDT and. place result on stack. |
asc | 2+0 | get ascii code from char in a string |
chr | 1+0 | convert asci to character |
ltrim | 1+0 | trim left spaces |
rtrim | 1+0 | trim right spaces |
lower | 1+0 | convert to lowercase |
upper | 1+0 | convert to uppercase |
mid | 3-1 | extract part of a string by position and length |
midl | 3-1 | extract part of a string by position and boundary position |
insert | 4-3 | insert / delete string into prior string at position and exclusion position |
patch | 3-2 | patch string into prior string at specified position. |
pos | 3-1 | search for string in prior string starting at position |
hex | 1+1 | return hexadecimal string of a number |
oct | 1+1 | return octal string of number |
bin | 1+1 | return binary string of number |
str | 1+1 | return string of number |
many | 2-1 | return repeating string elements |
read | 1+0 | set up a string to read its words (no effect on stack) |
word | 0+0 | read the next word in a read string (see read) |
reword | 1+0 | alter current word eg: "a_" word, reword (inserts prefix a_) |
val | 1+1 | return the value of any number, text or binary |
date | 0+1 | return the date in US mm/dd/yyyy format |
time | 0+1 | return the time in hh:mm:ss format |
getcol | 0+1 | get the cursor column position |
getrow | 0+1 | get the cursor row position |
getkey | 0+1 | get the string generated by the last key press |
getline | 1+0 | print the string promt and wait for line input from the console |
setcolor | 2-2 | set the forground and background color of console output |
cls | 0+0 | clear the console display |
beep | 0+0 | console beep |
locate | 3-3 | place the console cursor at the specified row, column and specify cursor visibili |
shell | 1-1 | invoke a shell command eg: "dir *.txt>t.t" shell |
file | 1+1 | open a file and return the file handle: eg "myfile.txt" file : myfile |
filein | 1+1 | open a file to read individual lines of text (using in) |
fileout | 1+1 | open an output file to print text strings (using out) |
fileappend | 1+1 | append to an existing output file (using out) |
save | 2+0 | save a string to a file |
out | 2-1 | print text to an output file eg "hello" myfile out (see fileout) |
eof | 1+0 | sets the sign flag if end of file is eached eg: myfile eof if true then ... endif |
loc | 1+0 | return the position in a random access file (opened with file) eg: myfile loc |
lof | 1+0 | return the length of a random access file (see file): eg myfile lof |
in | 1+0 | return line of text from an input file (see filein) eg: myfile in |
load | 1+0 | eg: "myfile.txt" load |
get | 2+0 | get a string of bytes from a file (see file) of specified length eg: 50 myfile ge |
seek | 2-1 | move position in a random access file (see file) eg: 4001 myfile seek |
lock | 3-3 | lock region of a file to prevent shared access |
unlock | 3-3 | unlock locked region of file |
put | 2-1 | put a string of bytes into a random access file at the current location eg: "X" m |
close | 1-1 | close an open file eg: myfile close 0 to myfile |
and | 2-1 | bitwise and |
or | 2-1 | bitwise or |
xor | 2-1 | bitwise xor |
not | 1+0 | not / bit inversion |
abs | 1+0 | absolute value |
frac | 1+1 | frac rturn the fraction of a number |
int | 1+1 | return integer |
round | 2-1 | round a number to n places eg: 1234.56789 3 round (result 1234.568) |
sgn | 1+0 | return sign of a number eg -0.23 result: -1 |
neg | 1+0 | negate / reverse sign |
mod | 2-1 | modulus (supports floating point) eg: 4.5 3 mod Result: 1.5 |
sqr | 1+0 | square root |
log | 1+0 | natural log |
exp | 2+0 | exponent |
min | 2-1 | minimum of 2 numbers |
max | 2-1 | maximum of 2 numbers |
range | 3-3 | within range? eg: 1 nyvalue 10 range if true then .. endif |
rnd | 1+0 | random return a random number eg: 1 rnd |
randomize | 0+0 | seed randomiser (no effect on stack) |
degrees | 0+0 | do trig functions in degrees |
radians | 0+0 | do trig functions in radians |
cos | 1+0 | cosine |
sin | 1+0 | sine |
tan | 1+0 | tangent |
atn | 1+0 | arctangent |
libload | 1+0 | get a dll handle: eg: "opengl32.dll" libload : opengl |
libfun | 2-1 | get dll function address eg: opengl "GLgetmatrix" libfun : GLgetmatrix |
libfree | 1-1 | free dll eg: opengl libfree |
replace | 1+0 | replace a tagged structure in a string eg: "<xx>#1</>" replace myvec.x |
| | -------------------------------------- ' |
dbl quote | 0+1 | 0x22 ".." quoted text ' |
sgl quote | 0+1 | 0x27 '..' quoted text |
( | 0+0 | 0x28 ( left bracket block start (loop and block scoping) ' |
) | 0-n | 0x29 ) right bracket block end (restore stacks / diallocate vars) ' |
, | 1+0 | 0x2c , comma as concatenation operator eg: a b, appends b to a ' |
. | 1+0 | 0x2e , dot as duplication operator eg: 3 . * result: 9 ' |
), | 0+0 | 0x2c , concatenates last param inside block to last param before the block ' |
). | 0+1 | 0x2e , pushes then last param inside the block onto the cleaned stack ' |
+ | 2-1 | 0x2b + add eg: 2 -3 4 + + ' |
- | 2-1 | 0x2d - subtract eg: a b c - - ' |
* | 2-1 | 0x2a * multiply eg: 32 q * ' |
/ | 2-1 | 0x2f / divide eg: a b / ' |
^ | 2-1 | 0x5e ^ power eg: 2 ^ .5 (square root of 2) ' |
$ | 0+1 | 0x24 quoted text eg $ ' "hello" ' ? $ |
` | 0+n | 0x60 inverted quotes eg $a`42 chr`b $ result: a*b ' |
& | 0+0 | 0x26 absolute address prefix eg: &aa (absolute address of aa) ' |
: | 0+0 | 0x3a assign name to last variable on the stack eg: 42 : univ ' |
@ | 0+0 | 0x40 pointer prefix eg @1 (a system var) @a (a pointer var) ' |
vert bar | 0+0 | 0x7c | comment till end of line ' |
? | 0+0 | 0x3f print data to console with crlf eg "hello"? ' |
?? | 0+0 | 0x3f print to console without crlf ' |
< | 0+0 | 0x3c markup left tag mark ' |
> | 0+0 | 0x3e markup right tag mark ' |
| | -------------------------------------- ' |
| | |
| | |
| | Number of intrinsic commands/functions : 153 |