Commit f49ddeba by kollo

fix c-usage example / demonstration

parent 2590eb9a
# Example how to link X11-Basic Object codes (produced by xbc)
# with your c-Program
# Example how to use the x11basic-Library
# with your c-Program (c) Markus Hoffmann
# Example how to link X11-Basic object codes (produced by xbc) with your C program
# and
# Example how to use the x11basic-Library from within your C program
# (c) Markus Hoffmann 2004
# demo1 simply uses some of the X11-basic commands provided by libx11basic
# demo2 links with library.bas and calls X11-Basic procedures and function and uses the X11-Basic Variables
# from within the c sourcecode. You can also make a shared library from library.o and dynamically link
# demo2 links with library.bas and calls X11-Basic procedures and function
# and uses the X11-Basic variables from within the c sourcecode.
# You can also make a shared library from library.o and dynamically link
# against it.
......@@ -15,10 +15,10 @@ all: demo1 demo2
demo1: c-demo.c
gcc -fomit-frame-pointer -o $@ -lx11basic -ldl -lm -lreadline -lncurses -lasound -lX11 c-demo.c
gcc -fomit-frame-pointer -o $@ $< -lx11basic -ldl -lm -lreadline -lasound -lX11
demo2: library.o c-demo2.c
gcc -fomit-frame-pointer -o $@ -lx11basic -ldl -lm -lreadline -lncurses -lasound -lX11 c-demo2.c library.o
gcc -fomit-frame-pointer -o $@ $^ -lx11basic -ldl -lm -lreadline -lasound -lX11
%.b: %.bas
xbbc -o $@ $<
......
......@@ -10,7 +10,7 @@
x11basic shared library. Also ohers are required as follos:
gcc -fomit-frame-pointer -o testme -L/usr/X11R6/lib -lx11basic -ldl -lm
-lreadline -lncurses -lasound -lX11 testme.c library.o
-lreadline -lasound -lX11 testme.c library.o
*/
......@@ -26,11 +26,10 @@ char ifilename[]="dummy"; /* Program name. Put some useful information her
char *programbuffer=NULL;
const char version[]="dummy"; /* Version Number. Put some useful information here */
const char vdate[]="dummy"; /* Creation date. Put some useful information here */
char *program[]={"Hallo"}; /* Other comments. Put some useful information here */
int prglen=sizeof(program)/sizeof(char *);
char **program=NULL;
int prglen=0;
int verbose=0;
/* Here your c program starts */
main(int anzahl, char *argumente[]) {
......@@ -54,9 +53,9 @@ main(int anzahl, char *argumente[]) {
kommando("SHOWPAGE");
kommando("KEYEVENT");
/* ... */
/* If you know the internals of libx11basic, you can also use the c-versions of the functions:*/
/* If you know the internals of libx11basic, you can also use the c-versions of the functions:*/
graphics();
i=form_alert(1,strdup("[1][Hi I am X11-Basic.][ OK ]"));
printf("You pressed button %d\n",i);
}
......@@ -13,7 +13,7 @@ xbc -l -virtualm library.bas
gcc -DNOMAIN -c library.c
gcc -fomit-frame-pointer -o testme -L/usr/X11R6/lib -lx11basic -ldl -lm
-lreadline -lncurses -lasound -lX11 c-demo2.c library.o
-lreadline -lasound -lX11 c-demo2.c library.o
*/
......@@ -48,7 +48,6 @@ int main(int anzahl, char *argumente[]) {
STRING str;
int i;
MAIN_INIT;
printf("Hallo\n");
/* Initialize Variables used by the main program */
double VARf_MX;
......@@ -61,8 +60,8 @@ printf("Hallo\n");
/* Initialize Variables used by the main program */
add_variable_adr("MX",FLOATTYP,(char *)&VARf_MX);
add_variable_adr("MY",FLOATTYP,(char *)&VARf_MY);
add_variable("MX",FLOATTYP,0,V_STATIC,(char *)&VARf_MX);
add_variable("MY",FLOATTYP,0,V_STATIC,(char *)&VARf_MY);
......
' This is an example, how to produce .o linkabel object files and
' shared object files (.so) under linux with X11-Basic:
' library.bas -- demonstration for X11-Basic (c) Markus Hoffmann
'
'
' This is an example how to produce .o linkabel object files and
' shared object files (.so) under linux (UNIX or MAC-OSX) with X11-Basic:
'
' Do a
' xbc -l -c library.bas
......@@ -11,23 +14,21 @@
'
' You can link multiple .o files together with normal (C) .o files.
procedure pa
print "This is procedure a"
alert 1,"Hello, this is a message|from your X11-Basic program library.bas",1," Wow! ",dummy
return
procedure b
print "This is procedure b"
return
procedure c(x,y)
print "This is procedure c with parameters: x=";x,"y=";y
return
function d(x,y)
print "This is function d with parameters: x=";x,"y=";y
return x+y
endfunction
function greeting$(n%)
print "This is function greeting with parameter: n%=";n%
return date$+" "+time$+" Hello!!!! "+str$(n%)
endfunction
PROCEDURE pa
PRINT "This is procedure a"
ALERT 1,"Hello, this is a message|from your X11-Basic program library.bas",1," Wow! ",dummy
RETURN
PROCEDURE b
PRINT "This is procedure b"
RETURN
PROCEDURE c(x,y)
PRINT "This is procedure c with parameters: x=";x,"y=";y
RETURN
FUNCTION d(x,y)
PRINT "This is function d with parameters: x=";x,"y=";y
RETURN x+y
ENDFUNCTION
FUNCTION greeting$(n%)
PRINT "This is function greeting with parameter: n%=";n%
RETURN DATE$+" "+TIME$+" Hello!!!! "+STR$(n%)
ENDFUNCTION
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