Commit ee788d46 authored by kollo's avatar kollo

lof() etwas verbessert und docu von MODE() verbessert, ausserdem README etc.

parent f6daff48
Guide to contributing to X11-Basic
==================================
X11-Basic exists for quite a while now. Therefore I consider
it to be in a quite mature state. I am planning not to extend the language much,
e.g. I do not want to add many more commands or functions. The language as it is
should stay much the same as it is now.
X11-Basic exists for quite a while now. Therefore I consider it to be in a
quite mature state. I am planning not to extend the language much, e.g. I do
not want to add many more commands or functions. The language as it is should
stay much the same as it is now.
However, there are still some bugs and also some of the features mentioned in
the manual are not implemented. As there are
the manual are not implemented.
As there are:
1. The Array operators a(1:2,3) with a specified range are not implemented.
Always a complete row must be used: a(:,3) works fine.
......@@ -16,7 +19,7 @@ the manual are not implemented. As there are
systems time). However, an array with index range as a lvalue does already
work.
These issues should be fixed somewhen. Also there are Ideas for adding Bluetooth
These issues should be fixed somewhen. Also there are ideas for adding Bluetooth
support and USB support to the Android version of X11-Basic. This should lead
to as few additional commands and functions as possible. Maybe it can be done
usinge external binaries called via the shell (like the SQL support is
......
......@@ -12,7 +12,7 @@
VERSION 1.24
(C) 1997-2015 by Markus Hoffmann
(C) 1997-2016 by Markus Hoffmann
(kollo@users.sourceforge.net)
Name : X11Basic
......@@ -31,21 +31,13 @@ Description :
The structure of the language is similar to the ATARI-ST GFA-BASIC.
This package includes the basic interpreter named xbasic and a set of
different compilers. The interpreter can be used as a shell, and can so run
basic-scripts. You can make excecutable scripts p.ex. *.cgi-Scripts for
handling web-input.
A compiler (xbc) is included which makes stand alone binaries out of the
scripts, which run more than 10 times faster than the interpreted code. The
compiler can either pseudo-compile the X11-Basic sources by attaching the
source to a run-only interpreter (in which case the program will not run
faster than is the interpreter is used, but you have everything in one
excecutable file), or the compiler can do a real compilation of the BASIC
source into bytecode, then C, and finally machine language. This way the code
excecutes about 10 times faster.
different compilers.
A compiler manager (xbc) is included which makes stand alone binaries out of
the BASIC programs, which run more than 10 times faster than the interpreted
code.
X11-Basic programs can also be compiled into a bytecode (see xbbc). This
bytecode can be interpreted by a virtual machine (see xbvm). Finally, the
bytecode can be interpreted by a virtual machine (see xbvm). Finally, the
bytecode can be converted to C sourcefiles (see xb2c) which can be compiled
with the gnu C compiler (or the tiny C compiler) to native excecutables.
......@@ -54,9 +46,11 @@ Description :
You will find the compiler sourcecode and some other sample programs in
/usr/share/doc/packages/X11Basic/examples. A variety of other sample programs
can be found in X11-Basic-examples-1.24.zip, which you can download from the
homepage (http://x11-basic.sourceforge.net/). Also an up-to-date pdf-version
of the manual can be found there.
can be found in an X11-Basic examples repository on gitlab
(https://gitlab.com/kollo/X11-Basic_examples/tree/master) or in a package
X11-Basic-examples-1.24.zip, which you can download from the homepage
(http://x11-basic.sourceforge.net/). Also an up-to-date pdf-version of the
manual can be found there.
Please read the file ./doc/X11-Basic-manual.txt for further information.
......@@ -73,9 +67,9 @@ ADDITIONAL CONFIGURATION OPTIONS
================================
After generating the Makefile, look at the file `options.h' (sparsely
commented) and see if there is anything you want to change. The only option
commented) and see if there is anything you want to change. The only option
that you might need to change is GERMAN, which should be defined if you
like to have a german version of X11-Basic. The default language is english.
like to have a german version of X11-Basic. The default language is English.
COMPILING a standalone excecutable
==================================
......@@ -90,7 +84,7 @@ library and does not need the x11basic framework to be installed.
After X11Basic has been compiled and linked successfully, you can start it
by typing
./xbasic
./xbasic.static
The command-line options can be listed with the `-h' option (`./xbasic -h').
INSTALLING the standalone excecutable
......@@ -136,8 +130,8 @@ make xbcinstall
man-page
After doing all this, you will also find a xbasic.dyn executabe. This is the
interpreter, dynamically linked and much shorter.
After doing all this, you will also find an executabe called xbasic. This is
the interpreter, dynamically linked and much shorter than the static one.
regards and have fun
Markus Hoffmann
......
......@@ -19,3 +19,4 @@ Release notes for Version 1.24 (Sept 2015 -- )
- fixed bug in RADIX() and fixed bug in arbint/arbfloat evaluation
- fixed bug in FILL and ELLIPSE/PELLIPSE (for big screens)
- fixed power operator in compiler for integer operands
- little bugfix in compiler (PRINT #)
......@@ -224,13 +224,34 @@ Syntax: m%=MODE(filename$)
DESCRIPTION:
Return the file permissions of the file or directory.
Return the file permissions and the file type of the file or directory
given. With these values one can find out what kind the file is of.
The bits of the returned integer have the following meaning:
xxxx xxxx xxxx xxxx
| |||| |rwx-- permission for others (read, write, excecute)
| ||rw x----- permissions for group
r wx--------- permissions for user
s------------- sticky bit
g-------------- set group id bit
u--------------- set user id bit
++++----------------- file type:
0 -- regular file
1 -- fifo
2 -- charackter device
4 -- directory
6 -- block device
8 -- regular file
10 -- symbolic link
12 -- socket
COMMENT:
May not work on WINDOWS systems.
EXAMPLES:
PRINT OCT$(MODE(".")) ---> Result: 40750
DEFFN isdir(f$)=(MODE(f$) AND 0x4000)>0
SEE ALSO: INODE(), EXIST()
##############################################################################
......
/* file.c (c) Markus Hoffmann */
/* Erweiterungen fuer die Datei Ein- und Ausgabe .... */
/* Extensions for the standard file i/o operations.
Erweiterungen fuer die Datei Ein- und Ausgabe .... */
/* This file is part of X11BASIC, the basic interpreter for Unix/X
* ============================================================
* ================================================================
* X11BASIC is free software and comes with NO WARRANTY - read the file
* COPYING for details
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
......@@ -18,7 +18,6 @@
#include <unistd.h>
#include <fcntl.h>
#include "file.h"
#ifndef FALSE
......@@ -61,14 +60,18 @@ char *input( FILE *n, char *line,int size) { /* liest bis Komma oder Zeilenend
/* Returns the length of the open file n */
size_t lof(FILE *n) {
size_t laenge,position;
position=ftell(n);
if(fseek(n,0,2)==0){
laenge=ftell(n);
if(fseek(n,position,0)==0) return(laenge);
long position=ftell(n);
if(position==-1) {
io_error(errno,"lof");
return(0);
}
return(-1);
if(fseek(n,0,SEEK_END)==0) {
long laenge=ftell(n);
if(laenge<0) io_error(errno,"ftell");
if(fseek(n,position,0)<0) io_error(errno,"fseek");
return(laenge);
} else io_error(errno,"fseek");
return(0);
}
......@@ -104,9 +107,7 @@ int bsave(const char *name, char *adr, size_t len) {
*/
size_t bload(const char *name, char *adr, size_t len) {
FILE *fdis;
fdis=fopen(name,"rb");
FILE *fdis=fopen(name,"rb");
if(fdis==NULL) return(0);
if(len==-1) len=lof(fdis);
if(len>0) len=fread(adr,1,len,fdis);
......@@ -117,8 +118,8 @@ size_t bload(const char *name, char *adr, size_t len) {
/* Checks if a give file name exists */
#if 0
int exist(const char *name ) { /* This is a save but slow implementation */
int fdis=open(name,0x8000);
int exist(const char *name ) { /* This is a safe but slow implementation */
int fdis=open(name,0x8000);
if (fdis==-1) return(FALSE);
close(fdis);
return(TRUE);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment