Files
gw-basic-2026/include/gwbasic.h
Eremey Valetov c2d73e9c24 Phase 3: file I/O, PRINT USING, SAVE/LOAD, MID$ assignment, graphics stubs
Add OPEN/CLOSE with both modern (OPEN "f" FOR OUTPUT AS #n) and compact
(OPEN "O",#n,"f") syntaxes. PRINT#, WRITE#, INPUT#, LINE INPUT# for
sequential file access. EOF() now returns real file status with peek-ahead.
LOC/LOF return approximate values.

PRINT USING with numeric (#, ., +, -, $$, **, ^^^^, comma grouping) and
string (!, &, \ \) format specifiers. Shared by PRINT USING and PRINT# USING.

SAVE (ASCII), LOAD (with ,R auto-run), and MERGE for program persistence.

MID$ assignment (MID$(var$, start [,len]) = expr) for in-place string
modification. Works with both scalar variables and array elements.

Graphics stubs for SCREEN, PSET, PRESET, LINE, CIRCLE, DRAW, PAINT,
VIEW, WINDOW, PALETTE - parse and discard arguments so graphics-heavy
programs don't crash.

SYSTEM and NEW/CLEAR now close all open files. Version bumped to 0.3.0.
22 tests pass (16 existing + 6 new).
2026-02-10 11:53:28 -05:00

73 lines
1.7 KiB
C

#ifndef GWBASIC_H
#define GWBASIC_H
#include "types.h"
#include "tokens.h"
#include "error.h"
#include "hal.h"
#include "interp.h"
#include "eval.h"
#include "gw_math.h"
#include "strings.h"
#define GW_VERSION "0.3.0"
#define GW_BANNER "GW-BASIC " GW_VERSION
/* Tokenizer */
int gw_crunch(const char *text, uint8_t *out, int outsize);
void gw_list_line(uint8_t *tokens, int len, char *out, int outsize);
/* PRINT statement */
void gw_stmt_print(void);
void gw_print_value(gw_value_t *v);
void gw_print_newline(void);
/* Variables (vars.c) */
gw_valtype_t gw_parse_varname(char name_out[2]);
var_entry_t *gw_var_find_or_create(const char name[2], gw_valtype_t type);
void gw_var_assign(var_entry_t *var, gw_value_t *val);
void gw_vars_clear(void);
void gw_stmt_deftype(gw_valtype_t type);
void gw_stmt_swap(void);
/* Arrays (arrays.c) */
void gw_stmt_dim(void);
gw_value_t *gw_array_element(const char name[2], gw_valtype_t type);
void gw_stmt_erase(void);
void gw_stmt_option(void);
void gw_arrays_clear(void);
/* Input (input.c) */
void gw_stmt_input(void);
void gw_stmt_line_input(void);
/* DEF FN evaluation (interp.c) */
gw_value_t gw_eval_fn_call(void);
/* File I/O (fileio.c) */
file_entry_t *gw_file_get(int num);
void gw_file_close_all(void);
void gw_stmt_open(void);
void gw_stmt_close(void);
void gw_stmt_print_file(void);
void gw_stmt_write_file(void);
void gw_stmt_input_file(void);
void gw_stmt_line_input_file(void);
int gw_file_eof(int num);
/* Program I/O (program_io.c) */
void gw_stmt_save(void);
void gw_stmt_load(void);
void gw_stmt_merge(void);
/* PRINT USING (print_using.c) */
void gw_print_using(FILE *fp);
/* MID$ assignment (interp.c) */
void gw_stmt_mid_assign(void);
/* Error recovery for run loop */
extern jmp_buf gw_run_jmp;
#endif