M
Malcolm
After some days' hard work I am now the proud possessor of an ANSI C BASIC
interpreter.
The question is, how is it most useful?
At the moment I have a function
int basic(const char *script, FILE *in, FILE *out, FILE *err);
It returns 0 on success or -1 on fail.
and I'm calling it with stdin, stdout and stderr (err is for reporting
errors in the script, not for user errors).
This is fine for test purposes, but realistically it is not going to be
useful for anything beyond teaching newbies how to program in BASIC.
The main motive is to use the BASIC interpreter as a component of editors.
The idea is that a game designer can write a little BASIC program, maybe to
control the diffusion pattern of smoke particles, or maybe for some
AI-related stuff. Since the script is interpreted there is no reason to
recompile.
However setting up temporary files to pass data in and out of the BASIC
seems clumsy. There is also no way in C to specify a "user" FILE *,
something that pops up a Window to get input, for example.
I'm also not happy with the BASIC INPUT statement, it's fine for stdin, but
not so good for reading values from a typical formatted text file. However I
don't want to stray too far from core BASIC, or else the user will have to
learn a new programming language to use the program.
interpreter.
The question is, how is it most useful?
At the moment I have a function
int basic(const char *script, FILE *in, FILE *out, FILE *err);
It returns 0 on success or -1 on fail.
and I'm calling it with stdin, stdout and stderr (err is for reporting
errors in the script, not for user errors).
This is fine for test purposes, but realistically it is not going to be
useful for anything beyond teaching newbies how to program in BASIC.
The main motive is to use the BASIC interpreter as a component of editors.
The idea is that a game designer can write a little BASIC program, maybe to
control the diffusion pattern of smoke particles, or maybe for some
AI-related stuff. Since the script is interpreted there is no reason to
recompile.
However setting up temporary files to pass data in and out of the BASIC
seems clumsy. There is also no way in C to specify a "user" FILE *,
something that pops up a Window to get input, for example.
I'm also not happy with the BASIC INPUT statement, it's fine for stdin, but
not so good for reading values from a typical formatted text file. However I
don't want to stray too far from core BASIC, or else the user will have to
learn a new programming language to use the program.