Phase 4: CHAIN, RUN "file", random-access I/O, MBF conversions
Add CHAIN statement for loading and running chained programs with optional ALL flag to preserve variables. Extend RUN to accept a filename string argument. Implement random-access file I/O with FIELD, LSET, RSET, PUT#, GET# and the MBF conversion functions CVI/CVS/CVD/MKI$/MKS$/MKD$. Add COMMON statement (parse and skip). Five new test programs covering all new features (27 total).
This commit is contained in:
+20
-1
@@ -10,7 +10,7 @@
|
||||
#include "gw_math.h"
|
||||
#include "strings.h"
|
||||
|
||||
#define GW_VERSION "0.3.0"
|
||||
#define GW_VERSION "0.4.0"
|
||||
#define GW_BANNER "GW-BASIC " GW_VERSION
|
||||
|
||||
/* Tokenizer */
|
||||
@@ -59,6 +59,7 @@ int gw_file_eof(int num);
|
||||
void gw_stmt_save(void);
|
||||
void gw_stmt_load(void);
|
||||
void gw_stmt_merge(void);
|
||||
void gw_stmt_load_internal(const char *filename, bool clear);
|
||||
|
||||
/* PRINT USING (print_using.c) */
|
||||
void gw_print_using(FILE *fp);
|
||||
@@ -66,6 +67,24 @@ void gw_print_using(FILE *fp);
|
||||
/* MID$ assignment (interp.c) */
|
||||
void gw_stmt_mid_assign(void);
|
||||
|
||||
/* Random-access file I/O (fileio.c) */
|
||||
void gw_stmt_field(void);
|
||||
void gw_stmt_lset(void);
|
||||
void gw_stmt_rset(void);
|
||||
void gw_stmt_put(void);
|
||||
void gw_stmt_get(void);
|
||||
|
||||
/* MBF conversion functions (fileio.c) */
|
||||
gw_value_t gw_fn_cvi(gw_value_t *s);
|
||||
gw_value_t gw_fn_cvs(gw_value_t *s);
|
||||
gw_value_t gw_fn_cvd(gw_value_t *s);
|
||||
gw_value_t gw_fn_mki(int16_t n);
|
||||
gw_value_t gw_fn_mks(float f);
|
||||
gw_value_t gw_fn_mkd(double d);
|
||||
|
||||
/* CHAIN (interp.c) */
|
||||
void gw_stmt_chain(void);
|
||||
|
||||
/* Error recovery for run loop */
|
||||
extern jmp_buf gw_run_jmp;
|
||||
|
||||
|
||||
+10
-1
@@ -90,9 +90,18 @@ typedef struct {
|
||||
/* File entry for OPEN/CLOSE file table */
|
||||
typedef struct {
|
||||
FILE *fp;
|
||||
int mode; /* 0=closed, 'I'=input, 'O'=output, 'A'=append */
|
||||
int mode; /* 0=closed, 'I'=input, 'O'=output, 'A'=append, 'R'=random */
|
||||
int file_num;
|
||||
bool eof_flag;
|
||||
int record_len; /* record length for random access (default 128) */
|
||||
uint8_t *field_buf; /* FIELD buffer (malloc'd, record_len bytes) */
|
||||
int field_count; /* number of FIELDed variables */
|
||||
struct field_var {
|
||||
char name[2];
|
||||
gw_valtype_t type;
|
||||
int offset;
|
||||
int width;
|
||||
} fields[32];
|
||||
} file_entry_t;
|
||||
|
||||
/* MBF (Microsoft Binary Format) types for file compatibility */
|
||||
|
||||
Reference in New Issue
Block a user