I also mad a dotpup once:
http://puppyfiles.org/dotpupsde/dotpups ... -3.0.3.pup
I think it includes Glade and all required libs.
I think I renamed glade to glade3 , so you might rename it to glade.
Concerning own functions:
You cannot run functions from external .so or .dll files, as they have no interfaces in wxBasic (Gtkbasic is based on wxBasic).
But you can add own functions to Gtkbasic, if you are a bit common with C.
Look at builtin.h in the sourcepackage, I'll explain it using a function I added in the past.
A function is declared by 2 lines:
and
Code: Select all
{"xwin_system", wBuiltin_xwin_system, 1, 0},
The "1" means, that this function expects 1 argument.
"xwin" is an extension I once wrote, similar to the Gtk extension.
Now where is the code for this function?
in main.c you find:
#include "xwin.c"
So that file has my function.
Lets look at it:
Code: Select all
void wBuiltin_xwin_system()
{
wVariant *variant;
variant = (wVariant *)wMalloc( sizeof( wVariant ) );
variant = wStackPopString();
char bufline[10240];
char mystring[1000];
wVariant *mylist;
wVariant *myvariant;
wVariant *mykey;
int c=0;
myvariant = (wVariant *)wMalloc( sizeof( wVariant ) );
mylist = (wVariant *)wMalloc( sizeof( wVariant ) );
wTableNew(mylist);
mykey = (wVariant *)wMalloc( sizeof( wVariant ) );
FILE *fp;
int status;
fp = popen(wStringChar( variant ), "r");
if (fp == NULL){
return;
}
while (!feof(fp)){
fgets(bufline,10240,fp);
//-- create a key
sprintf( mystring,"%d" , c );
wVariantFromChar( mykey, mystring ,3,3 );
//-- create a string
wVariantFromChar( myvariant, bufline ,4,4 );
//-- append it to the list
wTableInsert(mylist , mykey, myvariant );
c++;
}
status = pclose(fp);
if (c>0){
wTableRemove(mylist , mykey );
}
//-- return the wList to wxBasic
wVariantMove( wStackPushNothing(), mylist );
sprintf( mystring,"%d" , status/256 );
wVariantFromChar( mykey, mystring ,3,3 );
wVariantMove( wStackPushNothing(), mykey );
//-- cleanup
wVariantDeref( myvariant );
wFree(myvariant);
wVariantDeref( mylist );
wFree(mylist);
wVariantDeref( mykey );
wFree(mykey);
return;
}
Confused?
I'll explain it.
wxBasic internally uses variant as datatype. Variant allows to use variables without declaration, so they can be int, char or others.
In C you had to declare
char mystring[1024];
int mynumber;
In Basic you just do:
myvariable = "test"
or
myvariable = 1 + 4
When a Basic-function passes an argument to C, it is a variant lying on a stack.
So you do not pass it as it usually is done in C, like
Code: Select all
void myfunction ( char *argument){
Instead you pass nothing directly to the function, but get the argument later.
So we must get it from there with this inbuilt function of the interpreter:
variant = wStackPopString();
As C does not know variant, we then must convert it to a standard C type.
wStringChar( variant )
It is used in a typical C function, that in this case runs the command(program) passed as argument using popen(), and then returns the result.
This result can have several lines (for example if you run "ls").
So the resulting lines then are converted to a wxBasic table/list and returned to wxBasic.
xwin.c is rather old, it were my first serious attempts to program C.
In gins.c , I meanwhile have added some more functions that simplify the use of variants, like
Code: Select all
//-- gets an argument from the wxBasic stack and returns it as string --
gchar *getstringarg(){
and
Code: Select all
//-- return a string to wxBasic
void returnstring(char *thestring){
If you added own functions, run
make&&make install
to compile your own Basic-interpreter
Mark