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. 9 2198
"Malcolm" <ma*****@55bank.freeserve.co.uk> wrote in message
news:bt**********@news8.svr.pol.co.uk... After some days' hard work I am now the proud possessor of an ANSI C BASIC interpreter.
I doubt it. How do you deal with things like PEEK, POKE, PLOT and all the
other graphics or sound commands in ANSI C?
The question is, how is it most useful?
No, the question is, what is your C question? ;-)
Peter
Peter Pichler <pi*****@pobox.sk> scribbled the following: "Malcolm" <ma*****@55bank.freeserve.co.uk> wrote in message news:bt**********@news8.svr.pol.co.uk... After some days' hard work I am now the proud possessor of an ANSI C BASIC interpreter.
I doubt it. How do you deal with things like PEEK, POKE, PLOT and all the other graphics or sound commands in ANSI C?
Perhaps his interpreter interprets a BASIC version which doesn't have
them? ANSI BASIC is incredibly small. It's even smaller than C=64 BASIC
V2.
--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"The question of copying music from the Internet is like a two-barreled sword."
- Finnish rap artist Ezkimo
"Joona I Palaste" <pa*****@cc.helsinki.fi> wrote: ANSI BASIC is incredibly small.
ANSI BASIC? One learns something new every day!
Peter Pichler <pi*****@pobox.sk> scribbled the following: "Joona I Palaste" <pa*****@cc.helsinki.fi> wrote: ANSI BASIC is incredibly small.
ANSI BASIC? One learns something new every day!
Yes. I didn't know about it either until Dan Pop told me. Apparently
it's even missing the IF... THEN structure. The only thing ANSI BASIC
can do in an IF statement is a GOTO. Several other BASIC dialects allow
calling other statements too.
(Though I would be surprised if this was valid BASIC:)
10 FOR I=1 TO 10
20 IF I<9 THEN NEXT I
--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"As a boy, I often dreamed of being a baseball, but now we must go forward, not
backward, upward, not forward, and always whirling, whirling towards freedom!"
- Kang
Joona I Palaste <pa*****@cc.helsinki.fi> scribbled the following: Peter Pichler <pi*****@pobox.sk> scribbled the following: "Joona I Palaste" <pa*****@cc.helsinki.fi> wrote: ANSI BASIC is incredibly small.
ANSI BASIC? One learns something new every day!
Yes. I didn't know about it either until Dan Pop told me. Apparently it's even missing the IF... THEN structure. The only thing ANSI BASIC can do in an IF statement is a GOTO. Several other BASIC dialects allow calling other statements too. (Though I would be surprised if this was valid BASIC:)
10 FOR I=1 TO 10 20 IF I<9 THEN NEXT I
Well, C=64 BASIC V2 seems to accept it... it's treating "NEXT I" as
"increment I and go back to the FOR command". So therefore the above
is equivalent to:
10 FOR I=1 TO 10
20 IF NOT(I<9) THEN END
30 NEXT I
--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"Peter Pichler" <pi*****@pobox.sk> wrote in message After some days' hard work I am now the proud possessor of an ANSI C BASIC interpreter. I doubt it. How do you deal with things like PEEK, POKE, PLOT and all the other graphics or sound commands in ANSI C?
It's a cut down BASIC without any hardware-specific commands. The question is, how is it most useful?
No, the question is, what is your C question? ;-)
That's the C question. Given that I've got a BASIC interpreter, what is the
most useful interface to the rest of the C program that calls it?
Malcolm <ma*****@55bank.freeserve.co.uk> scribbled the following: "Peter Pichler" <pi*****@pobox.sk> wrote in message No, the question is, what is your C question? ;-) That's the C question. Given that I've got a BASIC interpreter, what is the most useful interface to the rest of the C program that calls it?
Your BASIC interpreter is written in ANSI C, but is your program around
it also written in ANSI C? If not, then you can use a non-standard "pipe
stream" and pass it as an argument to your interpreting function. That
way you can send data between your outer program and your interpreter
efficiently.
--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"That's no raisin - it's an ALIEN!"
- Tourist in MTV's Oddities
On Sun, 04 Jan 2004 10:43:19 +0000, Joona I Palaste wrote: Malcolm <ma*****@55bank.freeserve.co.uk> scribbled the following: Given that I've got a BASIC interpreter, what is the most useful interface to the rest of the C program that calls it?
Your BASIC interpreter is written in ANSI C, but is your program around it also written in ANSI C? If not, then you can use a non-standard "pipe stream" and pass it as an argument to your interpreting function. That way you can send data between your outer program and your interpreter efficiently.
How about callback functions? Something like:
typedef int (*input_handler)(char**);
typedef int (*output_handler)(const char*);
typedef int (*error_handler)(int,int,char*); /* errno, line, text */
int basic(const char *script,
input_handler ih,
output_handler oh,
error_handler eh);
Giving the calling program the opportunity to define functions to deal
with input, output or errors. These programs may then write to file or
process the error or do whatever they feel like.
(And you can provide handler functions that writes to files if that's
what the user wants them to do.)
--
NPV
"the large print giveth, and the small print taketh away"
Tom Waits - Step right up
Nils Petter Vaskinn <no@spam.for.me.invalid> scribbled the following: On Sun, 04 Jan 2004 10:43:19 +0000, Joona I Palaste wrote: Malcolm <ma*****@55bank.freeserve.co.uk> scribbled the following: Given that I've got a BASIC interpreter, what is the most useful interface to the rest of the C program that calls it? Your BASIC interpreter is written in ANSI C, but is your program around it also written in ANSI C? If not, then you can use a non-standard "pipe stream" and pass it as an argument to your interpreting function. That way you can send data between your outer program and your interpreter efficiently.
How about callback functions? Something like:
typedef int (*input_handler)(char**); typedef int (*output_handler)(const char*); typedef int (*error_handler)(int,int,char*); /* errno, line, text */
int basic(const char *script, input_handler ih, output_handler oh, error_handler eh);
Giving the calling program the opportunity to define functions to deal with input, output or errors. These programs may then write to file or process the error or do whatever they feel like.
(And you can provide handler functions that writes to files if that's what the user wants them to do.)
I think this design is good. If this were Java, I'd design the BASIC
interpreter so that I/O is handled by calling interfaces, one called
Input, the other called Output. Implementors of the outside system
would have to implement these interfaces and pass the implementations
as parameters to the interpreter object.
--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"It's not survival of the fattest, it's survival of the fittest."
- Ludvig von Drake This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Howard Nease |
last post by:
Hello, everyone. I would appreciate any advice that someone could give me on
my future career path. Here is my situation:
I am a bright Junior in a very well-respected private high school, taking...
|
by: JotM |
last post by:
Hi all,
I am currently fooling around trying to produce a very basic webpage
that can be shown on both computer screens and Nokia series 60 GSM cell
phones featuring an XHTML browser. (XHTML-MP...
|
by: Mark Stokes |
last post by:
Hi there,
I wanted a bit of advice on a program (a prototype) that I am trying
to write that uses threads. I will outline what I am attempting to
do, and if anyone has any advice on the way I...
|
by: Brian |
last post by:
NOTE ALSO POSTED IN
microsoft.public.dotnet.framework.aspnet.buildingcontrols
I have solved most of my Server Control Collection property issues.
I wrote an HTML page that describes all of the...
|
by: john_20_28_2000 |
last post by:
Using asp.net, c#, mysql or SQL Server. I have a image uploading and
wanted it to be "secure." Each user has their own section to login and
upload images. Should I store the images in a database...
|
by: Alex Pavluck |
last post by:
Hello. I have always wanted to learn how to write programs as a hobby
and Visual Basic 2005 Express seems like the perfect platform. Can
someone who is more experience let me know if this is a...
|
by: BJMurphy |
last post by:
Hi All,
I am used to other SQL engines, and have a few basic questions--
1)If I wanted to conditionally drop a table, does SQL Server have a
way to natively do this? Many SQL implementations...
|
by: Simon Walsh |
last post by:
I'm an Electronics student in college and I'm currently working on a
project. I was given a circuit diagram for my project, from which I had to
design a printed circuit board to be sent off and...
|
by: Ark Khasin |
last post by:
I have a memory-mapped peripheral with a mapping like, say,
struct T {uint8_t read, write, status, forkicks;};
If I slap a volatile on an object of type struct T, does it guarantee
that all...
|
by: lllomh |
last post by:
Define the method first
this.state = {
buttonBackgroundColor: 'green',
isBlinking: false, // A new status is added to identify whether the button is blinking or not
}
autoStart=()=>{
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM)
The start time is equivalent to 19:00 (7PM) in Central...
|
by: Aliciasmith |
last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
|
by: tracyyun |
last post by:
Hello everyone,
I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
|
by: NeoPa |
last post by:
Hello everyone.
I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report).
I know it can be done by selecting :...
|
by: Teri B |
last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course.
0ne-to-many. One course many roles.
Then I created a report based on the Course form and...
|
by: nia12 |
last post by:
Hi there,
I am very new to Access so apologies if any of this is obvious/not clear.
I am creating a data collection tool for health care employees to complete. It consists of a number of...
|
by: NeoPa |
last post by:
Introduction
For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
|
by: GKJR |
last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...
| |