heres a simple script interperator, (you'll have to use your imagination though!!)
the script is run from the command line, in the form script.exe [script file]
there are three code files (at the minute) because I've only coded two very smple function, "add" and "writeword", there is currently no other function and no support for variables...
(I'll add some more functions later).
everyone should feel free to add to this language, it's a first come first server affair,
so if someone wants to write a function with a stupid name, or indeed a stupid function. respect the fact that they did that, and don't go changng other peoples functions name or functions function...
It's currently written in C and is compilable on both windows Linux and Mac, (a truly portable scripting language?)...
feel free to write OS specific functions, but don't to also write the code to make it so that it'll still compile (albeit ignoring your functins) on another OS...
heres the code so far....
int main(int argc, char *argv)
float a,b,c; /*declare some random variables incase they are needed later*/
char inpath, task, arg;
for (x=0; x<argc; x++)
printf("you can only run one script at a time");
printf("Usage is scrip.exe [scriptname]");
printf("script names are limited to 50 chars");
input = fopen(argv,"r");
printf("Error 1 - could not find input file - %s\n\n\r",inpath);
/*here we decide what functions we'll be allowing, and the permissible arguments for each function
for this example the functions that I have decided to allow are
add some numbers (because it's simple)
while (x=fscanf(input,"%s",&task)!=EOF) /*scan for task*/
c = addfunc(a,b);
fscanf(input,"%s",&arg); /*not all scripting functions will need a seperate function, echo to the screen is a good example of this*/
/*list functions here*/
float addfunc(float, float);
/*declare functions that will be available
these are global variables, just because it
was easier and cleaner to do it like this*/
char *addfunction = "add";
char *printwordfunction = "writeword";
char *printstringfunction = "writestring"; //not included this but you get the picture right
and lastly the function specific file
float addfunc(float a, float b)
result = a + b;
I've tried to structure the programming so tat new functions can be added without bloating the software.
For some users they may have to add lines to include the addfunc.c file at the start of the functionslist.h file... the IE I used was VS.NET and having these three files added to the solution meant that the addfunc.c file was added automatically...
so like I say, if anyone is intersted, please feel free to extend this language.
just for completion... the script I used was called hello.txt and looked like this