ChipMaster's bwBASIC This also includes history going back to v2.10. *WARN* some binary files might have been corrupted by CRLF.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

1444 lines
55 KiB

  1. /***************************************************************
  2. bwbasic.h Header File
  3. for Bywater BASIC Interpreter
  4. Copyright (c) 1993, Ted A. Campbell
  5. Bywater Software
  6. email: tcamp@delphi.com
  7. Copyright and Permissions Information:
  8. All U.S. and international rights are claimed by the author,
  9. Ted A. Campbell.
  10. This software is released under the terms of the GNU General
  11. Public License (GPL), which is distributed with this software
  12. in the file "COPYING". The GPL specifies the terms under
  13. which users may copy and use the software in this distribution.
  14. A separate license is available for commercial distribution,
  15. for information on which you should contact the author.
  16. ***************************************************************/
  17. /*---------------------------------------------------------------*/
  18. /* NOTE: Modifications marked "JBV" were made by Jon B. Volkoff, */
  19. /* 11/1995 (eidetics@cerf.net). */
  20. /*---------------------------------------------------------------*/
  21. #ifndef TRUE
  22. #define TRUE -1
  23. #define FALSE 0
  24. #endif
  25. /***************************************************************
  26. bwbasic.h Part I: Definitions
  27. ***************************************************************/
  28. /* Version number */
  29. #define VERSION "2.20" /* Current version number */
  30. /***************************************************************
  31. bwbasic.h: Part I-A: Define Major Hardware Implementation
  32. Gone is the simplicity of earlier versions.
  33. You must specify one and only one of the
  34. following hardware implementations as TRUE.
  35. IMP_TTY is the default implementation.
  36. It is the most minimal, but the most
  37. universal hardware implementation.
  38. If you pick IMP_TTY then check the settings
  39. in bwx_tty.h for your system.
  40. ***************************************************************/
  41. #define IMP_TTY TRUE /* simple TTY-style interface using stdio */
  42. #define IMP_IQC FALSE /* IBM PC, Microsoft QuickC Compiler */
  43. #define ALLOW_RENUM TRUE /* Added by JBV */
  44. #if IMP_TTY
  45. #include "bwx_tty.h"
  46. #endif
  47. #if IMP_IQC
  48. #include "bwx_iqc.h"
  49. #endif
  50. /***************************************************************
  51. bwbasic.h: Part I-B: Define Compiler Implementation
  52. You also need to give some information about
  53. your C compiler. If your compiler is ANSI-
  54. compatible, don't worry about these. But
  55. if your compiler is "stock," you might
  56. want to indicate which of the following
  57. sets of features it has or dosn't have.
  58. ***************************************************************/
  59. #ifdef MSDOS
  60. #define HAVE_RAISE TRUE
  61. #define HAVE_STRING TRUE
  62. #define HAVE_STDLIB TRUE
  63. #endif
  64. #ifdef __STDC__
  65. #define HAVE_SIGNAL TRUE
  66. #else
  67. #define HAVE_SIGNAL TRUE /* Compiler supports signal() */
  68. #endif
  69. #ifdef __STDC__
  70. #define HAVE_LONGJUMP TRUE
  71. #else
  72. #define HAVE_LONGJUMP TRUE /* Compiler supports setjmp() and longjmp() */
  73. #endif
  74. /* configure sets this */
  75. #ifndef HAVE_RAISE
  76. #define HAVE_RAISE FALSE /* Compiler supports raise() */
  77. #endif
  78. /* configure sets this */
  79. #ifndef HAVE_STRING
  80. #define HAVE_STRING FALSE /* Compiler has <string.h> header */
  81. #endif
  82. /* configure sets this */
  83. #ifndef HAVE_STDLIB
  84. #define HAVE_STDLIB FALSE /* Compiler has <stdlib.h> header */
  85. #endif
  86. /* configure sets this (section added by JBV) */
  87. #ifndef HAVE_UNISTD
  88. #define HAVE_UNISTD FALSE /* Compiler has <unistd.h> header */
  89. #endif
  90. #ifdef __STDC__
  91. #define HAVE_SYSTYPES TRUE
  92. #else
  93. #define HAVE_SYSTYPES TRUE /* Compiler has <sys/types.h> header */
  94. #endif
  95. #ifdef __STDC__
  96. #define HAVE_SYSSTAT TRUE
  97. #else
  98. #define HAVE_SYSSTAT TRUE /* Compiler has <sys/stat.h> header */
  99. #endif
  100. /***************************************************************
  101. bwbasic.h: Part I-C: Define Program Configuration
  102. You must specify one and only one of the
  103. following progrm configurations as TRUE.
  104. If you specify CFG_CUSTOM, then you will
  105. need to fill out the custom section below.
  106. ***************************************************************/
  107. #define CFG_ANSIMINIMAL FALSE /* Conforms to ANSI Minimal BASIC standard X3.60-1978 */
  108. #define CFG_COMMON FALSE /* Small implementation with commands and functions common to GWBASIC (tm) and ANSI full BASIC */
  109. #define CFG_MSTYPE FALSE /* Configuration similar to Microsoft line-oriented BASICs */
  110. #define CFG_ANSIFULL FALSE /* Conforms to ANSI Full BASIC standard X3.113-1987 */
  111. #define CFG_CUSTOM TRUE /* Custom Configuration specified below */
  112. /***************************************************************
  113. bwbasic.h: Part I-D: Define Custom Program Configuration
  114. If you specified CFG_CUSTOM above, then
  115. you will need to fill out this section.
  116. ***************************************************************/
  117. #if CFG_CUSTOM
  118. #define COMMAND_SHELL TRUE /* allow command shell processing */
  119. #define PROFILE TRUE /* interpret profile at beginning */
  120. #define NUMBER_DOUBLE TRUE /* define BASIC number as double: default is float*/
  121. #define MULTISEG_LINES TRUE /* allow multi-segment lines delimited by ':' */
  122. #define PARACT FALSE /* Implement PARallen ACTion (Multi-tasking) interpreter */
  123. #define INTERACTIVE TRUE /* interactive programming environment and related commands */
  124. #define COMMON_CMDS TRUE /* commands common to ANSI full BASIC and GWBASIC */
  125. #if UNIX_CMDS
  126. #define UNIX_CMDS TRUE /* implement Unix-style directory commands */
  127. #endif
  128. #define STRUCT_CMDS TRUE /* commands for structured programming required by full ANSI BASIC */
  129. #define MS_CMDS TRUE /* commands specific to Microsoft GWBASIC (tm) */
  130. #define MS_FUNCS TRUE /* Microsoft-specific functions and commands */
  131. #define COMMON_FUNCS TRUE /* functions common to GWBASIC and ANSI full BASIC */
  132. #define ANSI_FUNCS TRUE /* functions required by ANSI full BASIC */
  133. #endif /* end of CFG_CUSTOM */
  134. /***************************************************************
  135. bwbasic.h: Part I-E: Define Natural Language for Messages
  136. One and only one of the following must be
  137. defined as TRUE. Note that the language
  138. definitions themselves are in file bwb_mes.h.
  139. If none is specified, then ENGLISH will be
  140. taken as the default.
  141. ***************************************************************/
  142. #define STD_ENGLISH TRUE /* standard English */
  143. #define POL_ENGLISH FALSE /* polite English messages */
  144. #define IMP_ENGLISH FALSE /* impolite English messages */
  145. #define LATIN FALSE /* Latin language messages */
  146. #define STD_RUSSIAN FALSE /* Russian language messages */
  147. #define STD_GERMAN FALSE /* German language messages */
  148. #define ESPERANTO FALSE /* Esperanto messages */
  149. /***************************************************************
  150. bwbasic.h: Part I-F: Define Debugging Options
  151. You can specify debugging options here.
  152. Defining DEBUG true provides some useful commands:
  153. CMDS, VARS, FNCS
  154. ***************************************************************/
  155. #define DEBUG FALSE /* current debugging */
  156. #define PROG_ERRORS FALSE /* identify serious programming errors */
  157. /* and print extensive error messages */
  158. /* This will override messages defined in */
  159. /* bwb_mes.h, and almost all messages will be in English */
  160. #define CHECK_RECURSION FALSE /* check for recursion violation in expression parser */
  161. #define INTENSIVE_DEBUG FALSE /* old debugging; might be useful later */
  162. #define REDIRECT_STDERR FALSE /* Redirect stderr to file ERRFILE */
  163. #define TEST_BSTRING FALSE /* test bstring integrity */
  164. #ifdef __STDC__
  165. #define ANSI_C TRUE /* FALSE to test and debug non-ANSI-C version
  166. with ANSI C compiler (watch out) */
  167. #endif
  168. /***************************************************************
  169. bwbasic.h: This ends the section of definitions that
  170. users of bwBASIC will normally need to
  171. specify. The following are internally defined.
  172. Note that you may need to set up the default
  173. FILES command and the default editor below.
  174. See Part I-G
  175. ***************************************************************/
  176. #if CFG_ANSIMINIMAL
  177. #define COMMAND_SHELL FALSE /* allow command shell processing */
  178. #define PROFILE FALSE /* interpret profile at beginning */
  179. #define NUMBER_DOUBLE FALSE /* define BASIC number as double: default is float*/
  180. #define MULTISEG_LINES FALSE /* allow multi-segment lines delimited by ':' */
  181. #define PARACT FALSE /* Implement PARallen ACTion (Multi-tasking) interpreter */
  182. #define INTERACTIVE TRUE /* interactive programming environment and related commands */
  183. #define COMMON_CMDS FALSE /* commands common to ANSI full BASIC and GWBASIC */
  184. #if UNIX_CMDS
  185. #define UNIX_CMDS FALSE /* implement Unix-style directory commands */
  186. #endif
  187. #define STRUCT_CMDS FALSE /* commands for structured programming required by full ANSI BASIC */
  188. #define MS_CMDS FALSE /* commands specific to Microsoft GWBASIC (tm) */
  189. #define MS_FUNCS FALSE /* Microsoft-specific functions and commands */
  190. #define COMMON_FUNCS FALSE /* functions common to GWBASIC and ANSI full BASIC */
  191. #define ANSI_FUNCS FALSE /* functions required by ANSI full BASIC */
  192. #endif /* end of CFG_ANSIMINIMAL */
  193. #if CFG_COMMON
  194. #define COMMAND_SHELL FALSE /* allow command shell processing */
  195. #define PROFILE FALSE /* interpret profile at beginning */
  196. #define NUMBER_DOUBLE FALSE /* define BASIC number as double: default is float*/
  197. #define MULTISEG_LINES FALSE /* allow multi-segment lines delimited by ':' */
  198. #define PARACT FALSE /* Implement PARallen ACTion (Multi-tasking) interpreter */
  199. #define INTERACTIVE TRUE /* interactive programming environment and related commands */
  200. #define COMMON_CMDS TRUE /* commands common to ANSI full BASIC and GWBASIC */
  201. #if UNIX_CMDS
  202. #define UNIX_CMDS FALSE /* implement Unix-style directory commands */
  203. #endif
  204. #define STRUCT_CMDS FALSE /* commands for structured programming required by full ANSI BASIC */
  205. #define MS_CMDS FALSE /* commands specific to Microsoft GWBASIC (tm) */
  206. #define MS_FUNCS FALSE /* Microsoft-specific functions and commands */
  207. #define COMMON_FUNCS TRUE /* functions common to GWBASIC and ANSI full BASIC */
  208. #define ANSI_FUNCS FALSE /* functions required by ANSI full BASIC */
  209. #endif /* end of CFG_COMMON */
  210. #if CFG_ANSIFULL
  211. #define COMMAND_SHELL TRUE /* allow command shell processing */
  212. #define PROFILE TRUE /* interpret profile at beginning */
  213. #define NUMBER_DOUBLE FALSE /* define BASIC number as double: default is float*/
  214. #define MULTISEG_LINES FALSE /* allow multi-segment lines delimited by ':' */
  215. #define PARACT TRUE /* Implement PARallen ACTion (Multi-tasking) interpreter */
  216. #define INTERACTIVE TRUE /* interactive programming environment and related commands */
  217. #define COMMON_CMDS TRUE /* commands common to ANSI full BASIC and GWBASIC */
  218. #if UNIX_CMDS
  219. #define UNIX_CMDS FALSE /* implement Unix-style directory commands */
  220. #endif
  221. #define STRUCT_CMDS TRUE /* commands for structured programming required by full ANSI BASIC */
  222. #define MS_CMDS FALSE /* commands specific to Microsoft GWBASIC (tm) */
  223. #define MS_FUNCS FALSE /* Microsoft-specific functions and commands */
  224. #define COMMON_FUNCS TRUE /* functions common to GWBASIC and ANSI full BASIC */
  225. #define ANSI_FUNCS TRUE /* functions required by ANSI full BASIC */
  226. #endif /* end of CFG_ANSIFULL */
  227. #if CFG_MSTYPE
  228. #define COMMAND_SHELL FALSE /* allow command shell processing */
  229. #define PROFILE FALSE /* interpret profile at beginning */
  230. #define NUMBER_DOUBLE FALSE /* define BASIC number as double: default is float*/
  231. #define MULTISEG_LINES TRUE /* allow multi-segment lines delimited by ':' */
  232. #define PARACT FALSE /* Implement PARallen ACTion (Multi-tasking) interpreter */
  233. #define INTERACTIVE TRUE /* interactive programming environment and related commands */
  234. #define COMMON_CMDS TRUE /* commands common to ANSI full BASIC and GWBASIC */
  235. #define STRUCT_CMDS FALSE /* commands for structured programming required by full ANSI BASIC */
  236. #define MS_CMDS TRUE /* commands specific to Microsoft GWBASIC (tm) */
  237. #define MS_FUNCS TRUE /* Microsoft-specific functions and commands */
  238. #define COMMON_FUNCS TRUE /* functions common to GWBASIC and ANSI full BASIC */
  239. #define ANSI_FUNCS FALSE /* functions required by ANSI full BASIC */
  240. #endif /* end of CFG_MSTYPE */
  241. /* inclusions and definitions necessary if C compiler is not ANSI compliant */
  242. #if HAVE_STRING
  243. #include <string.h>
  244. #else
  245. #include <strings.h>
  246. #endif
  247. #if HAVE_STDLIB
  248. #include <stdlib.h>
  249. #endif
  250. /* Section added by JBV */
  251. #if HAVE_UNISTD
  252. #include <unistd.h>
  253. #endif
  254. #if HAVE_SYSTYPES
  255. #include <sys/types.h>
  256. #endif
  257. #if HAVE_STDLIB /* if neither ANSI */
  258. #else
  259. #if HAVE_SYSTYPES /* nor SYSTYPES */
  260. #else
  261. #define size_t unsigned int /* then define these */
  262. #define time_t long
  263. #endif
  264. #endif
  265. /* define number of commands */
  266. #define CMDS_CORE 22 /* number of core commands defined */
  267. #if UNIX_CMDS
  268. #define CMDS_DIR 5
  269. #else
  270. #define CMDS_DIR 0
  271. #endif
  272. #if COMMON_CMDS
  273. #define CMDS_COMMON 25 /* Was 24 (JBV) */
  274. #else
  275. #define CMDS_COMMON 0
  276. #endif
  277. #if STRUCT_CMDS
  278. #define CMDS_STC 10
  279. #else
  280. #define CMDS_STC 0
  281. #endif
  282. #if INTERACTIVE
  283. #define CMDS_INT 8
  284. #else
  285. #define CMDS_INT 0
  286. #endif
  287. #if MS_CMDS
  288. #define CMDS_MS 5+IMP_CMDCLS+IMP_CMDLOC+IMP_CMDCOLOR
  289. #else
  290. #define CMDS_MS 0
  291. #endif
  292. #if DEBUG
  293. #define CMDS_DEBUG 3 /* number of debugging cmds */
  294. #else
  295. #define CMDS_DEBUG 0 /* no debugging cmds */
  296. #endif
  297. #define COMMANDS (CMDS_CORE+CMDS_DEBUG+CMDS_DIR+CMDS_COMMON+CMDS_INT+CMDS_MS+CMDS_STC)
  298. /* define number of functions */
  299. #define FUNCS_BASE 12 /* number of basic functions */
  300. #ifdef INTENSIVE_DEBUG
  301. #define FUNCS_DEBUG 1 /* number of debugging functions */
  302. #else
  303. #define FUNCS_DEBUG 0 /* number of debugging functions */
  304. #endif
  305. #if MS_FUNCS
  306. #define FUNCS_MS (25+IMP_FNCINKEY)
  307. #else
  308. #define FUNCS_MS 0
  309. #endif
  310. #if COMMON_FUNCS
  311. #define FUNCS_COMMON 7
  312. #else
  313. #define FUNCS_COMMON 0
  314. #endif
  315. #if ANSI_FUNCS
  316. #define FUNCS_ANSI 0
  317. #else
  318. #define FUNCS_ANSI 0
  319. #endif
  320. #define FUNCTIONS (FUNCS_BASE+FUNCS_DEBUG+FUNCS_MS+FUNCS_COMMON+FUNCS_ANSI)
  321. /* Check for inconsistencies */
  322. #if MULTISEG_LINES & STRUCT_CMDS
  323. /* ERROR: MULTISEG_LINES and STRUCT_CMDS cannot be defined together! */
  324. #endif
  325. /***************************************************************
  326. bwbasic.h: Part I-G: Define User Defaults
  327. Defining your default editor and files commands
  328. is a good idea. You must supply the file name
  329. for the editor to use. These defaults can be
  330. changed from inside the program or in your profile
  331. program by setting the appropriate variables
  332. shown below.
  333. ***************************************************************/
  334. #define DEF_EDITOR "vi" /* default editor */
  335. #define DEF_FILES "ls -Fx" /* default "files" command */
  336. #define DEF_COLORS 256 /* default # of colors */
  337. #define DEFVNAME_EDITOR "BWB.EDITOR$" /* default variable name for EDITOR */
  338. #define DEFVNAME_PROMPT "BWB.PROMPT$" /* default variable name for PROMPT */
  339. #define DEFVNAME_FILES "BWB.FILES$" /* default variable name for FILES */
  340. #define DEFVNAME_COLORS "BWB.COLORS" /* default variable name for COLORS */
  341. #define DEFVNAME_IMPL "BWB.IMPLEMENTATION$" /* default variable name for IMPLEMENTATION */
  342. #define ERRFILE "err.out" /* Filename for redirected error messages */
  343. #define PROFILENAME "profile.bas" /* Filename for profile execution */
  344. #define TASKS 4 /* number of tasks available */
  345. #define MAXARGSIZE 128 /* maximum size of argument */
  346. #define MAXREADLINESIZE 256 /* size of read_line buffer */
  347. #define MAXCMDNAMESIZE 64 /* maximum size for command name */
  348. #define MAXLINENO 32766 /* maximum line number */
  349. #define MAXVARNAMESIZE 40 /* maximum size for variable name */
  350. #define MAXFILENAMESIZE 40 /* maximum size for file name */
  351. #define MAXSTRINGSIZE 255 /* maximum string length */
  352. #define EXECLEVELS 64 /* EXEC stack levels */
  353. #define MAX_GOLINES 12 /* Maximum # of lines for ON...GOTO statements */
  354. #define MAX_FARGS 6 /* maximum # arguments to function */
  355. #define MAX_DIMS 64 /* maximum # of dimensions */
  356. #define ESTACKSIZE 64 /* elements in expression stack */
  357. #define XTXTSTACKSIZE 16 /* elements in eXecute TeXT stack */
  358. #define N_OPERATORS 25 /* number of operators defined */
  359. #define N_ERRORS 25 /* number of errors defined */
  360. #define MAX_PRECEDENCE 20 /* highest (last) level of precedence */
  361. #define MININTSIZE -32767 /* minimum integer size */
  362. #define MAXINTSIZE 32767 /* maximum integer size */
  363. #define DEF_SUBSCRIPT 11 /* default subscript */
  364. #define DEF_DEVICES 16 /* default number of devices available */
  365. #define DEF_WIDTH 128 /* default width for devices */
  366. #define PRN_TAB 0x02 /* send TAB followed by col number to output device */
  367. #define COMPRESS_FUNCS TRUE
  368. /* Derivative definitions */
  369. #if MULTISEG_LINES
  370. #define MARK_LINES FALSE
  371. #else
  372. #define MARK_LINES TRUE
  373. #endif
  374. #if PARACT
  375. #define CURTASK bwb_tasks[ bwb_curtask ]->
  376. #define LOCALTASK bwb_tasks[ task ]->
  377. #else
  378. #define CURTASK
  379. #define LOCALTASK
  380. #endif
  381. #if DEBUG
  382. #define PERMANENT_DEBUG TRUE
  383. #else
  384. #define PERMANENT_DEBUG FALSE
  385. #endif
  386. #if HAVE_STDLIB
  387. #else
  388. extern char *calloc();
  389. #ifndef NULL
  390. #define NULL 0L
  391. #endif
  392. #endif
  393. /* typedef for BASIC number */
  394. #if NUMBER_DOUBLE
  395. typedef double bnumber;
  396. #else
  397. typedef float bnumber;
  398. #endif
  399. /* define variable types based on last character */
  400. #define STRING '$'
  401. /* define mathematical operations */
  402. #define MULTIPLY '*'
  403. #define DIVIDE '/'
  404. #define ADD '+'
  405. #define SUBTRACT '-'
  406. #define ARGUMENT 'A'
  407. /* Operations defined */
  408. #define OP_ERROR -255 /* operation error (break out) */
  409. #define OP_NULL 0 /* null: operation not defined yet */
  410. #define NUMBER 1 /* number held as internal variable in uvar */
  411. #define CONST_STRING 2 /* string constant */
  412. #define CONST_NUMERICAL 3 /* numerical constant */
  413. #define FUNCTION 4 /* function header */
  414. #define VARIABLE 5 /* external variable pointed to by xvar */
  415. #define PARENTHESIS 6 /* begin parenthetical expression */
  416. #define OP_ADD 7 /* addition sign '+' */
  417. #define OP_SUBTRACT 8 /* subtraction sign '-' */
  418. #define OP_MULTIPLY 9 /* multiplication sign '*' */
  419. #define OP_DIVIDE 10 /* division sign '/' */
  420. #define OP_MODULUS 11 /* modulus "MOD" */
  421. #define OP_EXPONENT 12 /* exponentiation '^' */
  422. #define OP_INTDIVISION 13 /* integer division sign '\' */
  423. #define OP_NEGATION 14 /* negation '-' ??? */
  424. #define OP_STRJOIN 15 /* string join ';' */
  425. #define OP_STRTAB 16 /* string tab ',' */
  426. #define OP_EQUALS 17 /* either logical equal operator */
  427. #define OP_ASSIGN 18 /* assignment operator */
  428. #define OP_NOTEQUAL 20 /* inequality */
  429. #define OP_LESSTHAN 21 /* less than */
  430. #define OP_GREATERTHAN 22 /* greater than */
  431. #define OP_LTEQ 23 /* less than or equal to */
  432. #define OP_GTEQ 24 /* greater than or equal to */
  433. #define OP_NOT 25 /* negation */
  434. #define OP_AND 26 /* conjunction */
  435. #define OP_OR 27 /* disjunction */
  436. #define OP_XOR 28 /* exclusive or */
  437. #define OP_IMPLIES 29 /* implication */
  438. #define OP_EQUIV 30 /* equivalence */
  439. #define OP_TERMINATE 31 /* terminate expression parsing */
  440. #define OP_USERFNC 32 /* user-defined function */
  441. /* Device input/output modes */
  442. #define DEVMODE_AVAILABLE -1
  443. #define DEVMODE_CLOSED 0
  444. #define DEVMODE_OUTPUT 1
  445. #define DEVMODE_INPUT 2
  446. #define DEVMODE_APPEND 3
  447. #define DEVMODE_RANDOM 4
  448. /* codes for EXEC stack and for function-sub-label lookup table */
  449. #define EXEC_NORM 0
  450. #define EXEC_GOSUB 1
  451. #define EXEC_WHILE 2
  452. #define EXEC_FOR 3
  453. #define EXEC_FUNCTION 4
  454. #define EXEC_CALLSUB 5
  455. #define EXEC_IFTRUE 6
  456. #define EXEC_IFFALSE 7
  457. #define EXEC_MAIN 8
  458. #define EXEC_SELTRUE 9
  459. #define EXEC_SELFALSE 10
  460. #define EXEC_LABEL 11
  461. #define EXEC_DO 12
  462. #define EXEC_ON 13
  463. /***************************************************************
  464. bwbasic.h Part II: Structures
  465. ***************************************************************/
  466. /* Typdef structure for strings under Bywater BASIC */
  467. typedef struct bstr
  468. {
  469. unsigned char length; /* length of string */
  470. char *sbuffer; /* pointer to string buffer */
  471. int rab; /* is it a random-access buffer? */
  472. #if TEST_BSTRING
  473. char name[ MAXVARNAMESIZE + 1 ]; /* name for test purposes */
  474. #endif
  475. } bstring;
  476. /* Structure used for all variables under Bywater BASIC */
  477. struct bwb_variable
  478. {
  479. char name[ MAXVARNAMESIZE + 1 ]; /* name */
  480. int type; /* type, i.e., STRING or NUMBER */
  481. #if OLDWAY
  482. void *array; /* pointer to array memory */
  483. #endif
  484. bnumber *memnum; /* memory for number */
  485. bstring *memstr; /* memory for string */
  486. size_t array_units; /* total number of units of memory */
  487. int *array_sizes; /* pointer to array of <dimensions>
  488. integers, with sizes of each
  489. dimension */
  490. int *array_pos; /* current position in array */
  491. int dimensions; /* number of dimensions,
  492. 0 = not an array */
  493. struct bwb_variable *next; /* next variable in chain */
  494. int common; /* should this variable be common to chained programs? */
  495. int preset; /* preset variable: CLEAR should not alter */
  496. };
  497. /* Structure to represent program lines under Bywater BASIC */
  498. struct bwb_line
  499. {
  500. struct bwb_line *next; /* pointer to next line in chain */
  501. int number; /* line number */
  502. char xnum; /* is there actually a line number? */
  503. char *buffer; /* buffer to hold the line */
  504. int position; /* current position in line */
  505. int lnpos; /* line number position in buffer */
  506. int lnum; /* line number read from buffer */
  507. int cmdpos; /* command position in buffer */
  508. int cmdnum; /* number of command in command table
  509. read from buffer */
  510. int startpos; /* start of rest of line read from buffer */
  511. int marked; /* has line been checked yet? */
  512. };
  513. /* Structure used for all predefined functions under Bywater BASIC */
  514. struct bwb_function
  515. {
  516. char name[ MAXVARNAMESIZE + 1 ]; /* name */
  517. int type; /* type, i.e., STRING or NUMBER */
  518. int arguments; /* number of args passed */
  519. #if ANSI_C
  520. struct bwb_variable * (*vector) ( int argc, struct bwb_variable *argv, int unique_id ); /* vector to function to call */
  521. #else
  522. struct bwb_variable * (*vector) (); /* vector to function to call */
  523. #endif
  524. struct bwb_function *next; /* next function in chain */
  525. int id; /* id to identify multiple functions */
  526. };
  527. /* Structure to represent all command statements under Bywater BASIC */
  528. struct bwb_command
  529. {
  530. char name[ MAXCMDNAMESIZE + 1 ];
  531. #if ANSI_C
  532. struct bwb_line * (*vector) (struct bwb_line *);
  533. #else
  534. struct bwb_line * (*vector) ();
  535. #endif
  536. };
  537. /* Structure to define device stack for Bywater BASIC */
  538. struct dev_element
  539. {
  540. int mode; /* DEVMODE_ item */
  541. int width; /* width for output control */
  542. int col; /* current column */
  543. int reclen; /* record length for random access */
  544. int next_record; /* next record to read/write */
  545. int loc; /* location in file */
  546. int lof; /* length of file in bytes (JBV) */
  547. char filename[ MAXFILENAMESIZE + 1 ];/* filename */
  548. FILE *cfp; /* C file pointer for this device */
  549. char *buffer; /* pointer to character buffer for random access */
  550. };
  551. /* Structure to define expression stack elements under Bywater BASIC */
  552. struct exp_ese
  553. {
  554. int operation; /* operation at this level */
  555. char type; /* type of operation at this level:
  556. STRING or NUMBER */
  557. bstring sval; /* string */
  558. bnumber nval; /* number */
  559. char string[ MAXSTRINGSIZE + 1 ]; /* string for writing */
  560. struct bwb_variable *xvar; /* pointer to external variable */
  561. struct bwb_function *function; /* pointer to function structure */
  562. int array_pos[ MAX_DIMS ]; /* array for variable positions */
  563. int pos_adv; /* position advanced in string */
  564. int rec_pos; /* position marker for recursive calls */
  565. };
  566. /* structure for FUNCTION-SUB loopup table element */
  567. struct fslte
  568. {
  569. char *name;
  570. struct bwb_line *line;
  571. int code;
  572. int startpos; /* starting position in line */
  573. struct fslte *next;
  574. struct bwb_variable *local_variable;
  575. };
  576. /* Structure to define EXEC stack elements */
  577. struct exse
  578. {
  579. struct bwb_line *line; /* line for execution */
  580. int code; /* code to note special operations */
  581. int position; /* position in line for restore */
  582. struct bwb_variable *local_variable; /* local variable chain and current FOR counter */
  583. struct bwb_variable *calling_variable[ MAX_FARGS ];
  584. int n_cvs; /* number of calling variables */
  585. int for_step; /* STEP value for FOR */
  586. int for_target; /* target value for FOR */
  587. struct bwb_line *while_line; /* return line for current WHILE */
  588. struct bwb_line *wend_line; /* breakout line for current WHILE (or FOR-NEXT) */
  589. struct exp_ese expression; /* expression for evaluation by SELECT CASE */
  590. #if MULTISEG_LINES
  591. struct bwb_line *for_line; /* top line for FOR-NEXT loop, multisegmented */
  592. int for_position; /* position in top line for FOR-NEXT loop, multisegmented */
  593. #endif
  594. };
  595. struct xtxtsl
  596. {
  597. int position;
  598. struct bwb_line l;
  599. };
  600. /* Structure to define bwBASIC task: UNDER CONSTRUCTION */
  601. #if PARACT
  602. struct bwb_task
  603. {
  604. char progfile[ MAXARGSIZE ]; /* program file */
  605. int rescan; /* program needs to be rescanned */
  606. int number; /* current line number */
  607. struct bwb_line *bwb_l; /* current line pointer */
  608. struct bwb_line bwb_start; /* starting line marker */
  609. struct bwb_line bwb_end; /* ending line marker */
  610. struct bwb_line *data_line; /* current line to read data */
  611. int data_pos; /* position in data_line */
  612. struct bwb_variable var_start; /* variable list start marker */
  613. struct bwb_variable var_end; /* variable list end marker */
  614. struct bwb_function fnc_start; /* function list start marker */
  615. struct bwb_function fnc_end; /* function list end marker */
  616. struct fslte fslt_start; /* function-sub-label lookup table start marker */
  617. struct fslte fslt_end; /* function-sub-label lookup table end marker */
  618. int exsc; /* EXEC stack counter */
  619. int expsc; /* expression stack counter */
  620. int xtxtsc; /* eXecute TeXT stack counter */
  621. struct exse excs[ EXECLEVELS ]; /* EXEC stack */
  622. struct exp_ese exps[ ESTACKSIZE ]; /* Expression stack */
  623. struct xtxtsl xtxts[ XTXTSTACKSIZE ];/* Execute Text stack */
  624. };
  625. extern struct bwb_task *bwb_tasks[ TASKS ]; /* table of task pointers */
  626. #else /* not multi-tasking */
  627. extern char progfile[ MAXARGSIZE ]; /* program file */
  628. extern int rescan; /* program needs to be rescanned */
  629. extern int number; /* current line number */
  630. extern struct bwb_line *bwb_l; /* current line pointer */
  631. extern struct bwb_line bwb_start; /* starting line marker */
  632. extern struct bwb_line bwb_end; /* ending line marker */
  633. extern struct bwb_line *data_line; /* current line to read data */
  634. extern int data_pos; /* position in data_line */
  635. extern struct bwb_variable var_start; /* variable list start marker */
  636. extern struct bwb_variable var_end; /* variable list end marker */
  637. extern struct bwb_function fnc_start; /* function list start marker */
  638. extern struct bwb_function fnc_end; /* function list end marker */
  639. extern struct fslte fslt_start; /* function-sub-label lookup table start marker */
  640. extern struct fslte fslt_end; /* function-sub-label lookup table end marker */
  641. extern int exsc; /* EXEC stack counter */
  642. extern int expsc; /* expression stack counter */
  643. extern int xtxtsc; /* eXecute TeXT stack counter */
  644. extern struct exse *excs; /* EXEC stack */
  645. extern struct exp_ese *exps; /* Expression stack */
  646. extern struct xtxtsl *xtxts; /* Execute Text stack */
  647. #endif
  648. extern int bwb_curtask; /* current task */
  649. extern struct bwb_variable *ed; /* EDITOR$ variable */
  650. extern struct bwb_variable *fi; /* FILES$ variable */
  651. extern struct bwb_variable *pr; /* PROMPT$ variable */
  652. extern struct bwb_variable *im; /* IMPLEMENTATION$ variable */
  653. extern struct bwb_variable *co; /* COLORS variable */
  654. /***************************************************************
  655. bwbasic.h Part III: Global Data
  656. ***************************************************************/
  657. extern char *bwb_ebuf;
  658. extern int bwb_trace;
  659. extern int dim_base; /* set by OPTION BASE */
  660. extern struct bwb_command bwb_cmdtable[ COMMANDS ];
  661. extern FILE *errfdevice; /* output device for error messages */
  662. extern int err_line; /* line in which error occurred */
  663. extern int err_number; /* number of last error */
  664. extern char err_gosubl[ MAXVARNAMESIZE + 1 ]; /* line for error GOSUB */
  665. extern char *err_table[ N_ERRORS ]; /* table of error messages */
  666. extern int prn_col;
  667. extern struct bwb_function bwb_prefuncs[ FUNCTIONS ]; /* table of predefined functions */
  668. #if COMMON_CMDS
  669. extern struct dev_element *dev_table; /* table of devices */
  670. #endif
  671. /* Operator Structure and Table */
  672. struct bwb_op
  673. {
  674. char symbol[ 8 ]; /* BASIC symbol for the operator */
  675. int operation; /* internal code for the operator */
  676. int precedence; /* level of precedence, 0 = highest */
  677. };
  678. extern struct bwb_op exp_ops[ N_OPERATORS ]; /* the table itself, filled in in bwb_tbl.c */
  679. /***************************************************************
  680. bwbasic.h Part IV: Function Prototypes
  681. ***************************************************************/
  682. #if ANSI_C
  683. extern void *CALLOC(size_t nelem, size_t elsize, char *str); /* JBV */
  684. extern void FREE(void *ptr, char *str); /* JBV */
  685. extern void bwb_init( int argc, char **argv );
  686. extern int bwb_fload( FILE *file );
  687. extern int bwb_ladd( char *buffer, int replace );
  688. extern int bwb_findcmd( int argc, int a, struct bwb_line *l );
  689. extern struct bwb_line *bwb_xtxtline( char *buffer );
  690. extern void bwb_mainloop( void );
  691. extern void bwb_execline( void );
  692. extern int bwb_gets( char *buffer );
  693. extern int bwb_error( char *message );
  694. extern void break_handler( void );
  695. extern void break_mes( int x );
  696. extern struct bwb_line *bwb_null( struct bwb_line *l );
  697. extern struct bwb_line *bwb_rem( struct bwb_line *l );
  698. extern struct bwb_line *bwb_lerror( struct bwb_line *l );
  699. extern struct bwb_line *bwb_run( struct bwb_line *l );
  700. extern struct bwb_line *bwb_let( struct bwb_line *l );
  701. extern struct bwb_line *bwb_load( struct bwb_line *l );
  702. extern struct bwb_line *bwb_merge( struct bwb_line *l );
  703. extern struct bwb_line *bwb_chain( struct bwb_line *l );
  704. extern struct bwb_line *bwb_common( struct bwb_line *l );
  705. extern struct bwb_line *bwb_xload( struct bwb_line *l );
  706. extern struct bwb_line *bwb_new( struct bwb_line *l );
  707. extern struct bwb_line *bwb_save( struct bwb_line *l );
  708. extern struct bwb_line *bwb_list( struct bwb_line *l );
  709. extern struct bwb_line *bwb_xlist( struct bwb_line *l, FILE *file );
  710. extern struct bwb_line *bwb_go( struct bwb_line *l );
  711. extern struct bwb_line *bwb_goto( struct bwb_line *l );
  712. extern struct bwb_line *bwb_gosub( struct bwb_line *l );
  713. extern struct bwb_line *bwb_return( struct bwb_line *l );
  714. extern struct bwb_line *bwb_xend( struct bwb_line *l );
  715. extern struct bwb_line *bwb_system( struct bwb_line *l );
  716. extern struct bwb_line *bwb_tron( struct bwb_line *l );
  717. extern struct bwb_line *bwb_troff( struct bwb_line *l );
  718. extern struct bwb_line *bwb_randomize( struct bwb_line *l );
  719. extern struct bwb_line *bwb_stop( struct bwb_line *l );
  720. extern struct bwb_line *bwb_data( struct bwb_line *l );
  721. extern struct bwb_line *bwb_read( struct bwb_line *l );
  722. extern struct bwb_line *bwb_restore( struct bwb_line *l );
  723. extern struct bwb_line *bwb_delete( struct bwb_line *l );
  724. extern struct bwb_line *bwb_if( struct bwb_line *l );
  725. extern struct bwb_line *bwb_else( struct bwb_line *l );
  726. extern struct bwb_line *bwb_elseif( struct bwb_line *l );
  727. extern struct bwb_line *bwb_select( struct bwb_line *l );
  728. extern struct bwb_line *bwb_case( struct bwb_line *l );
  729. extern struct bwb_line *bwb_endselect( struct bwb_line *l );
  730. extern struct bwb_line *bwb_endif( struct bwb_line *l );
  731. extern struct bwb_line *bwb_while( struct bwb_line *l );
  732. extern struct bwb_line *bwb_wend( struct bwb_line *l );
  733. extern struct bwb_line *bwb_for( struct bwb_line *l );
  734. extern struct bwb_line *bwb_next( struct bwb_line *l );
  735. extern struct bwb_line *bwb_dim( struct bwb_line *l );
  736. extern struct bwb_line *bwb_option( struct bwb_line *l );
  737. extern struct bwb_line *bwb_open( struct bwb_line *l );
  738. extern struct bwb_line *bwb_close( struct bwb_line *l );
  739. extern struct bwb_line *bwb_get( struct bwb_line *l );
  740. extern struct bwb_line *bwb_put( struct bwb_line *l );
  741. extern struct bwb_line *bwb_rmdir( struct bwb_line *l );
  742. extern struct bwb_line *bwb_chdir( struct bwb_line *l );
  743. extern struct bwb_line *bwb_mkdir( struct bwb_line *l );
  744. extern struct bwb_line *bwb_kill( struct bwb_line *l );
  745. extern struct bwb_line *bwb_name( struct bwb_line *l );
  746. extern struct bwb_line *bwb_rset( struct bwb_line *l );
  747. extern struct bwb_line *bwb_lset( struct bwb_line *l );
  748. extern struct bwb_line *bwb_field( struct bwb_line *l );
  749. extern struct bwb_line *bwb_on( struct bwb_line *l );
  750. extern struct bwb_line *bwb_line( struct bwb_line *l );
  751. extern struct bwb_line *bwb_ddbl( struct bwb_line *l );
  752. extern struct bwb_line *bwb_dint( struct bwb_line *l );
  753. extern struct bwb_line *bwb_dsng( struct bwb_line *l );
  754. extern struct bwb_line *bwb_dstr( struct bwb_line *l );
  755. extern struct bwb_line *bwb_mid( struct bwb_line *l );
  756. extern struct bwb_line *bwb_clear( struct bwb_line *l );
  757. extern struct bwb_line *bwb_erase( struct bwb_line *l );
  758. extern struct bwb_line *bwb_swap( struct bwb_line *l );
  759. extern struct bwb_line *bwb_environ( struct bwb_line *l );
  760. extern struct bwb_line *bwb_width( struct bwb_line *l );
  761. extern struct bwb_line *bwb_write( struct bwb_line *l );
  762. extern struct bwb_line *bwb_edit( struct bwb_line *l );
  763. extern struct bwb_line *bwb_files( struct bwb_line *l );
  764. extern struct bwb_line *bwb_do( struct bwb_line *l );
  765. extern struct bwb_line *bwb_doloop( struct bwb_line *l );
  766. extern struct bwb_line *bwb_cls( struct bwb_line *l );
  767. extern struct bwb_line *bwb_locate( struct bwb_line *l );
  768. extern struct bwb_line *bwb_color( struct bwb_line *l );
  769. extern struct bwb_line *bwb_do( struct bwb_line *l );
  770. extern struct bwb_line *bwb_loop( struct bwb_line *l );
  771. extern struct bwb_line *bwb_exit( struct bwb_line *l );
  772. extern struct bwb_line *bwb_exitfor( struct bwb_line *l );
  773. extern struct bwb_line *bwb_exitdo( struct bwb_line *l );
  774. extern struct bwb_line *bwb_zline( struct bwb_line *l );
  775. extern void bwb_incexec( void );
  776. extern void bwb_decexec( void );
  777. extern int bwb_setexec( struct bwb_line *l, int position, int code );
  778. extern int bwb_getcnd( char *lb, char *lhs, char *rhs, char *op, int *n );
  779. extern int bwb_getlhs( char *lb, char *lhs, int *n );
  780. extern int bwb_getop( char *lb, char *op, int *n );
  781. extern int bwb_getrhs( char *lb, char *rhs, int *n );
  782. extern int bwb_evalcnd( char *lhs, char *rhs, char *op );
  783. extern int bwb_isstr( char *b );
  784. extern int eval_int( int l, int r, char *op );
  785. extern int eval_sng( float l, float r, char *op );
  786. extern int eval_dbl( double l, double r, char *op );
  787. extern struct exp_ese *bwb_exp( char *expression, int assignment, int *position );
  788. extern int exp_getvfname( char *source, char *destination );
  789. extern int exp_operation( int entry_level );
  790. extern int inc_esc( void );
  791. extern int dec_esc( void );
  792. extern int fnc_init( int task );
  793. extern struct bwb_function *fnc_find( char *buffer );
  794. extern struct bwb_line *bwb_def( struct bwb_line *l );
  795. extern int bwb_getargs( char *buffer );
  796. extern int bwb_stripcr( char *s );
  797. extern int bwb_numseq( char *buffer, int *start, int *end );
  798. extern int bwb_freeline( struct bwb_line *l );
  799. extern struct bwb_line *bwb_print( struct bwb_line *l );
  800. extern int bwb_xprint( struct bwb_line *l, FILE *f );
  801. extern int bwb_eltype( char *l_buffer, int p );
  802. extern int var_init( int task );
  803. extern int fslt_init( int task );
  804. extern int var_delcvars( void );
  805. extern struct bwb_variable *var_new( char *name );
  806. extern struct bwb_variable *var_islocal( char *buffer );
  807. extern int bwb_strel( char *lb, char *sb, int *n );
  808. extern struct bwb_variable *bwb_numel( char *lb, int *n );
  809. extern int bwb_const( char *lb, char *sb, int *n );
  810. extern int bwb_getvarname( char *lb, char *sb, int *n );
  811. extern struct bwb_variable *var_find( char *buffer );
  812. extern int bwb_isvar( char *buffer );
  813. extern struct bwb_line *bwb_input( struct bwb_line *l );
  814. extern int inp_adv( char *b, int *c );
  815. extern int var_make( struct bwb_variable *v, int type );
  816. extern bstring *var_getsval( struct bwb_variable *nvar );
  817. extern bstring *var_findsval( struct bwb_variable *v, int *pp );
  818. extern bstring *exp_getsval( struct exp_ese *e );
  819. extern int dim_getparams( char *buffer, int *pos, int *n_params, int **pp );
  820. extern int adv_element( char *buffer, int *pos, char *element );
  821. extern int adv_ws( char *buffer, int *pos );
  822. #if MULTISEG_LINES
  823. extern int adv_eos( char *buffer, int *pos );
  824. #endif
  825. extern int line_start( char *buffer, int *pos, int *lnpos, int *lnum,
  826. int *cmdpos, int *cmdnum, int *startpos );
  827. extern int is_cmd( char *buffer, int *cmdnum );
  828. extern int is_let( char *buffer, int *cmdnum );
  829. extern int is_eol( char *buffer, int *position );
  830. extern int is_numconst( char *buffer );
  831. extern int is_label( char *buffer );
  832. extern struct bwb_line * find_label( char *buffer );
  833. extern struct bwb_line *find_loop( struct bwb_line *l );
  834. extern int int_qmdstr( char *buffer_a, char *buffer_b );
  835. extern struct bwb_line * cnd_xpline( struct bwb_line *l, char *buffer );
  836. extern int scan_element( char *buffer, int *pos, char *element );
  837. extern int prn_precision( struct bwb_variable *v );
  838. extern int * prn_getcol( FILE *f );
  839. extern int prn_getwidth( FILE *f );
  840. extern int prn_xprintf( FILE *f, char *buffer );
  841. extern int prn_xxprintf( FILE *f, char *buffer ); /* JBV */
  842. extern int bwb_strtoupper( char *buffer );
  843. extern int getcmdnum( char *cmdstr );
  844. extern int str_btoc( char *buffer, bstring *s );
  845. extern int str_btob( bstring *d, bstring *s );
  846. extern int str_ctob( bstring *s, char *buffer );
  847. extern int str_cmp( bstring *s, bstring *t );
  848. extern char * str_cat( bstring *s, bstring *t );
  849. extern int exp_findop( char *expression );
  850. extern int exp_isop( char *expression );
  851. extern int exp_isfn( char *expression );
  852. extern int exp_isufn( char *expression );
  853. extern int exp_isnc( char *expression );
  854. extern int exp_isvn( char *expression );
  855. extern int exp_iscmd( char *expression );
  856. extern int exp_paren( char *expression );
  857. extern int exp_strconst( char *expression );
  858. extern int exp_numconst( char *expression );
  859. extern int exp_function( char *expression );
  860. extern int exp_ufnc( char *expression );
  861. extern int exp_variable( char *expression );
  862. extern int exp_validarg( char *expression );
  863. extern int ln_asbuf( struct bwb_line *l, char *s );
  864. extern int xputc( FILE *f, char c );
  865. extern int bwx_signon( void );
  866. extern int bwx_message( char *m );
  867. extern int bwx_putc( char c );
  868. extern int bwx_errmes( char *m );
  869. extern int bwx_input( char *prompt, char *buffer );
  870. extern void bwx_terminate( void );
  871. #if COMMAND_SHELL
  872. extern int bwx_shell( struct bwb_line *l );
  873. #endif
  874. int bwb_scan( void );
  875. struct bwb_line *bwb_call( struct bwb_line *l );
  876. struct bwb_line *bwb_sub( struct bwb_line *l );
  877. struct bwb_line *bwb_endsub( struct bwb_line *l );
  878. struct bwb_line *bwb_endfnc( struct bwb_line *l );
  879. struct bwb_line *bwb_function( struct bwb_line *l );
  880. extern bnumber var_getnval( struct bwb_variable *nvar );
  881. extern bnumber *var_findnval( struct bwb_variable *v, int *pp );
  882. extern bnumber exp_getnval( struct exp_ese *e );
  883. extern bnumber *exp_findnval( struct exp_ese *e );
  884. #if PARACT
  885. extern int bwb_newtask( int task_requested );
  886. #endif
  887. #if INTERACTIVE
  888. extern int bwb_interact( void );
  889. #endif
  890. #if DEBUG
  891. extern int bwb_debug( char *message );
  892. extern struct bwb_line *bwb_cmds( struct bwb_line *l );
  893. extern struct bwb_line *bwb_vars( struct bwb_line *l );
  894. extern struct bwb_line *bwb_fncs( struct bwb_line *l );
  895. #endif
  896. #ifdef ALLOW_RENUM
  897. extern struct bwb_line *bwb_renum( struct bwb_line *l );
  898. #endif
  899. #if UNIX_CMDS
  900. #if !HAVE_UNISTD /* Not needed if one has <unistd.h> (JBV) */
  901. extern int rmdir( char *path );
  902. extern int chdir( char *path );
  903. #endif
  904. #if !HAVE_SYSSTAT /* Not needed if one has <sys/stat.h> (JBV) */
  905. #if MKDIR_ONE_ARG
  906. extern int mkdir( char *path );
  907. #else
  908. extern int mkdir( char *path, unsigned short permissions );
  909. #endif /* JBV */
  910. #endif
  911. #endif
  912. /* declarations of function commands */
  913. extern struct bwb_variable *fnc_null( int argc, struct bwb_variable *argv, int unique_id );
  914. #if COMPRESS_FUNCS
  915. extern struct bwb_variable *fnc_core( int argc, struct bwb_variable *argv, int unique_id );
  916. #else
  917. extern struct bwb_variable *fnc_abs( int argc, struct bwb_variable *argv, int unique_id );
  918. extern struct bwb_variable *fnc_atn( int argc, struct bwb_variable *argv, int unique_id );
  919. extern struct bwb_variable *fnc_cos( int argc, struct bwb_variable *argv, int unique_id );
  920. extern struct bwb_variable *fnc_log( int argc, struct bwb_variable *argv, int unique_id );
  921. extern struct bwb_variable *fnc_sin( int argc, struct bwb_variable *argv, int unique_id );
  922. extern struct bwb_variable *fnc_sqr( int argc, struct bwb_variable *argv, int unique_id );
  923. extern struct bwb_variable *fnc_sgn( int argc, struct bwb_variable *argv, int unique_id );
  924. extern struct bwb_variable *fnc_int( int argc, struct bwb_variable *argv, int unique_id );
  925. extern struct bwb_variable *fnc_rnd( int argc, struct bwb_variable *argv, int unique_id );
  926. extern struct bwb_variable *fnc_exp( int argc, struct bwb_variable *argv, int unique_id );
  927. extern struct bwb_variable *fnc_tan( int argc, struct bwb_variable *argv, int unique_id );
  928. #endif
  929. extern struct bwb_variable *fnc_tab( int argc, struct bwb_variable *argv, int unique_id );
  930. extern struct bwb_variable *fnc_date( int argc, struct bwb_variable *argv, int unique_id );
  931. extern struct bwb_variable *fnc_time( int argc, struct bwb_variable *argv, int unique_id );
  932. extern struct bwb_variable *fnc_chr( int argc, struct bwb_variable *argv, int unique_id );
  933. extern struct bwb_variable *fnc_mid( int argc, struct bwb_variable *argv, int unique_id );
  934. extern struct bwb_variable *fnc_left( int argc, struct bwb_variable *argv, int unique_id );
  935. extern struct bwb_variable *fnc_right( int argc, struct bwb_variable *argv, int unique_id );
  936. extern struct bwb_variable *fnc_timer( int argc, struct bwb_variable *argv, int unique_id );
  937. extern struct bwb_variable *fnc_val( int argc, struct bwb_variable *argv, int unique_id );
  938. extern struct bwb_variable *fnc_len( int argc, struct bwb_variable *argv, int unique_id );
  939. extern struct bwb_variable *fnc_hex( int argc, struct bwb_variable *argv, int unique_id );
  940. extern struct bwb_variable *fnc_oct( int argc, struct bwb_variable *argv, int unique_id );
  941. extern struct bwb_variable *fnc_cint( int argc, struct bwb_variable *argv, int unique_id );
  942. extern struct bwb_variable *fnc_asc( int argc, struct bwb_variable *argv, int unique_id );
  943. extern struct bwb_variable *fnc_mkd( int argc, struct bwb_variable *argv, int unique_id );
  944. extern struct bwb_variable *fnc_mki( int argc, struct bwb_variable *argv, int unique_id );
  945. extern struct bwb_variable *fnc_mks( int argc, struct bwb_variable *argv, int unique_id );
  946. extern struct bwb_variable *fnc_cvi( int argc, struct bwb_variable *argv, int unique_id );
  947. extern struct bwb_variable *fnc_cvd( int argc, struct bwb_variable *argv, int unique_id );
  948. extern struct bwb_variable *fnc_cvs( int argc, struct bwb_variable *argv, int unique_id );
  949. extern struct bwb_variable *fnc_string( int argc, struct bwb_variable *argv, int unique_id );
  950. extern struct bwb_variable * fnc_spc( int argc, struct bwb_variable *argv, int unique_id );
  951. extern struct bwb_variable * fnc_space( int argc, struct bwb_variable *argv, int unique_id );
  952. extern struct bwb_variable * fnc_environ( int argc, struct bwb_variable *argv, int unique_id );
  953. extern struct bwb_variable * fnc_pos( int argc, struct bwb_variable *argv, int unique_id );
  954. extern struct bwb_variable * fnc_err( int argc, struct bwb_variable *argv, int unique_id );
  955. extern struct bwb_variable * fnc_erl( int argc, struct bwb_variable *argv, int unique_id );
  956. extern struct bwb_variable * fnc_loc( int argc, struct bwb_variable *argv, int unique_id );
  957. extern struct bwb_variable * fnc_lof( int argc, struct bwb_variable *argv, int unique_id );
  958. extern struct bwb_variable * fnc_eof( int argc, struct bwb_variable *argv, int unique_id );
  959. extern struct bwb_variable * fnc_csng( int argc, struct bwb_variable *argv, int unique_id );
  960. extern struct bwb_variable * fnc_instr( int argc, struct bwb_variable *argv, int unique_id );
  961. extern struct bwb_variable * fnc_str( int argc, struct bwb_variable *argv, int unique_id );
  962. extern struct bwb_variable * fnc_inkey( int argc, struct bwb_variable *argv, int unique_id );
  963. extern bnumber trnc_int( bnumber x );
  964. extern int fnc_checkargs( int argc, struct bwb_variable *argv,
  965. int min, int max );
  966. extern int ufsc; /* user function stack counter */
  967. #if DEBUG
  968. extern struct bwb_variable *fnc_test( int argc, struct bwb_variable *argv, int unique_id );
  969. #endif
  970. #else /* ANSI_C */
  971. extern void *CALLOC(); /* JBV */
  972. extern void FREE(); /* JBV */
  973. extern void bwb_init();
  974. extern int bwb_fload();
  975. extern int bwb_ladd();
  976. extern int bwb_findcmd();
  977. extern struct bwb_line *bwb_xtxtline();
  978. extern void bwb_mainloop();
  979. extern void bwb_execline();
  980. extern int bwb_gets();
  981. extern int bwb_error();
  982. extern void break_handler();
  983. extern void break_mes();
  984. extern struct bwb_line *bwb_null();
  985. extern struct bwb_line *bwb_rem();
  986. extern struct bwb_line *bwb_lerror();
  987. extern struct bwb_line *bwb_run();
  988. extern struct bwb_line *bwb_let();
  989. extern struct bwb_line *bwb_load();
  990. extern struct bwb_line *bwb_merge();
  991. extern struct bwb_line *bwb_chain();
  992. extern struct bwb_line *bwb_common();
  993. extern struct bwb_line *bwb_xload();
  994. extern struct bwb_line *bwb_new();
  995. extern struct bwb_line *bwb_save();
  996. extern struct bwb_line *bwb_list();
  997. extern struct bwb_line *bwb_xlist();
  998. extern struct bwb_line *bwb_go();
  999. extern struct bwb_line *bwb_goto();
  1000. extern struct bwb_line *bwb_gosub();
  1001. extern struct bwb_line *bwb_return();
  1002. extern struct bwb_line *bwb_xend();
  1003. extern struct bwb_line *bwb_system();
  1004. extern struct bwb_line *bwb_tron();
  1005. extern struct bwb_line *bwb_troff();
  1006. extern struct bwb_line *bwb_randomize();
  1007. extern struct bwb_line *bwb_stop();
  1008. extern struct bwb_line *bwb_data();
  1009. extern struct bwb_line *bwb_read();
  1010. extern struct bwb_line *bwb_restore();
  1011. extern struct bwb_line *bwb_delete();
  1012. extern struct bwb_line *bwb_if();
  1013. extern struct bwb_line *bwb_else();
  1014. extern struct bwb_line *bwb_elseif();
  1015. extern struct bwb_line *bwb_select();
  1016. extern struct bwb_line *bwb_case();
  1017. extern struct bwb_line *bwb_endselect();
  1018. extern struct bwb_line *bwb_endif();
  1019. extern struct bwb_line *bwb_while();
  1020. extern struct bwb_line *bwb_wend();
  1021. extern struct bwb_line *bwb_for();
  1022. extern struct bwb_line *bwb_next();
  1023. extern struct bwb_line *bwb_dim();
  1024. extern struct bwb_line *bwb_option();
  1025. extern struct bwb_line *bwb_open();
  1026. extern struct bwb_line *bwb_close();
  1027. extern struct bwb_line *bwb_get();
  1028. extern struct bwb_line *bwb_put();
  1029. extern struct bwb_line *bwb_rmdir();
  1030. extern struct bwb_line *bwb_chdir();
  1031. extern struct bwb_line *bwb_mkdir();
  1032. extern struct bwb_line *bwb_kill();
  1033. extern struct bwb_line *bwb_name();
  1034. extern struct bwb_line *bwb_rset();
  1035. extern struct bwb_line *bwb_lset();
  1036. extern struct bwb_line *bwb_field();
  1037. extern struct bwb_line *bwb_on();
  1038. extern struct bwb_line *bwb_line();
  1039. extern struct bwb_line *bwb_ddbl();
  1040. extern struct bwb_line *bwb_dint();
  1041. extern struct bwb_line *bwb_dsng();
  1042. extern struct bwb_line *bwb_dstr();
  1043. extern struct bwb_line *bwb_mid();
  1044. extern struct bwb_line *bwb_clear();
  1045. extern struct bwb_line *bwb_erase();
  1046. extern struct bwb_line *bwb_swap();
  1047. extern struct bwb_line *bwb_environ();
  1048. extern struct bwb_line *bwb_width();
  1049. extern struct bwb_line *bwb_write();
  1050. extern struct bwb_line *bwb_edit();
  1051. extern struct bwb_line *bwb_files();
  1052. extern struct bwb_line *bwb_do();
  1053. extern struct bwb_line *bwb_doloop();
  1054. extern struct bwb_line *bwb_cls();
  1055. extern struct bwb_line *bwb_locate();
  1056. extern struct bwb_line *bwb_color();
  1057. extern struct bwb_line *bwb_do();
  1058. extern struct bwb_line *bwb_loop();
  1059. extern struct bwb_line *bwb_exit();
  1060. extern struct bwb_line *bwb_exitfor();
  1061. extern struct bwb_line *bwb_exitdo();
  1062. extern struct bwb_line *bwb_zline();
  1063. extern void bwb_incexec();
  1064. extern void bwb_decexec();
  1065. extern int bwb_setexec();
  1066. extern int bwb_getcnd();
  1067. extern int bwb_getlhs();
  1068. extern int bwb_getop();
  1069. extern int bwb_getrhs();
  1070. extern int bwb_evalcnd();
  1071. extern int bwb_isstr();
  1072. extern int eval_int();
  1073. extern int eval_sng();
  1074. extern int eval_dbl();
  1075. extern struct exp_ese *bwb_exp();
  1076. extern int exp_getvfname();
  1077. extern int exp_operation();
  1078. extern int inc_esc();
  1079. extern int dec_esc();
  1080. extern int fnc_init();
  1081. extern struct bwb_function *fnc_find();
  1082. extern struct bwb_line *bwb_def();
  1083. extern int bwb_getargs();
  1084. extern int bwb_stripcr();
  1085. extern int bwb_numseq();
  1086. extern int bwb_freeline();
  1087. extern struct bwb_line *bwb_print();
  1088. extern int bwb_xprint();
  1089. extern int bwb_eltype();
  1090. extern int var_init();
  1091. extern int fslt_init();
  1092. extern int var_delcvars();
  1093. extern struct bwb_variable *var_new();
  1094. extern struct bwb_variable *var_islocal();
  1095. extern int bwb_strel();
  1096. extern struct bwb_variable *bwb_numel();
  1097. extern int bwb_const();
  1098. extern int bwb_getvarname();
  1099. extern struct bwb_variable *var_find();
  1100. extern int bwb_isvar();
  1101. extern struct bwb_line *bwb_input();
  1102. extern int inp_adv();
  1103. extern int var_make();
  1104. extern bstring *var_getsval();
  1105. extern bstring *var_findsval();
  1106. extern bstring *exp_getsval();
  1107. extern int dim_getparams();
  1108. extern int adv_element();
  1109. extern int adv_ws();
  1110. #if MULTISEG_LINES
  1111. extern int adv_eos();
  1112. #endif
  1113. extern int line_start();
  1114. extern int is_cmd();
  1115. extern int is_let();
  1116. extern int is_eol();
  1117. extern int is_numconst();
  1118. extern int is_label();
  1119. extern struct bwb_line * find_label();
  1120. extern struct bwb_line *find_loop();
  1121. extern int int_qmdstr();
  1122. extern struct bwb_line * cnd_xpline();
  1123. extern int scan_element();
  1124. extern int prn_precision();
  1125. extern int * prn_getcol();
  1126. extern int prn_getwidth();
  1127. extern int prn_xprintf();
  1128. extern int prn_xxprintf(); /* JBV */
  1129. extern int bwb_strtoupper();
  1130. extern int getcmdnum();
  1131. extern int str_btoc();
  1132. extern int str_btob();
  1133. extern int str_ctob();
  1134. extern int str_cmp();
  1135. extern char * str_cat();
  1136. extern int exp_findop();
  1137. extern int exp_isop();
  1138. extern int exp_isfn();
  1139. extern int exp_isufn();
  1140. extern int exp_isnc();
  1141. extern int exp_isvn();
  1142. extern int exp_iscmd();
  1143. extern int exp_paren();
  1144. extern int exp_strconst();
  1145. extern int exp_numconst();
  1146. extern int exp_function();
  1147. extern int exp_ufnc();
  1148. extern int exp_variable();
  1149. extern int exp_validarg();
  1150. extern int ln_asbuf();
  1151. extern int xputc();
  1152. extern int bwx_signon();
  1153. extern int bwx_message();
  1154. extern int bwx_putc();
  1155. extern int bwx_errmes();
  1156. extern int bwx_input();
  1157. extern void bwx_terminate();
  1158. #if COMMAND_SHELL
  1159. extern int bwx_shell();
  1160. #endif
  1161. int bwb_scan();
  1162. struct bwb_line *bwb_call();
  1163. struct bwb_line *bwb_sub();
  1164. struct bwb_line *bwb_endsub();
  1165. struct bwb_line *bwb_endfnc();
  1166. struct bwb_line *bwb_function();
  1167. extern bnumber var_getnval();
  1168. extern bnumber *var_findnval();
  1169. extern bnumber exp_getnval();
  1170. extern bnumber *exp_findnval();
  1171. #if PARACT
  1172. extern int bwb_newtask();
  1173. #endif
  1174. #if INTERACTIVE
  1175. extern int bwb_interact();
  1176. #endif
  1177. #if DEBUG
  1178. extern int bwb_debug();
  1179. extern struct bwb_line *bwb_cmds();
  1180. extern struct bwb_line *bwb_vars();
  1181. extern struct bwb_line *bwb_fncs();
  1182. #endif
  1183. #ifdef ALLOW_RENUM
  1184. extern struct bwb_line *bwb_renum();
  1185. #endif
  1186. #if UNIX_CMDS
  1187. extern int rmdir();
  1188. extern int chdir();
  1189. #if MKDIR_ONE_ARG
  1190. extern int mkdir();
  1191. #else
  1192. extern int mkdir();
  1193. #endif
  1194. #endif
  1195. /* declarations of function commands */
  1196. extern struct bwb_variable *fnc_null();
  1197. #if COMPRESS_FUNCS
  1198. extern struct bwb_variable *fnc_core();
  1199. #else
  1200. extern struct bwb_variable *fnc_abs();
  1201. extern struct bwb_variable *fnc_atn();
  1202. extern struct bwb_variable *fnc_cos();
  1203. extern struct bwb_variable *fnc_log();
  1204. extern struct bwb_variable *fnc_sin();
  1205. extern struct bwb_variable *fnc_sqr();
  1206. extern struct bwb_variable *fnc_sgn();
  1207. extern struct bwb_variable *fnc_int();
  1208. extern struct bwb_variable *fnc_rnd();
  1209. extern struct bwb_variable *fnc_exp();
  1210. extern struct bwb_variable *fnc_tan();
  1211. #endif
  1212. extern struct bwb_variable *fnc_tab();
  1213. extern struct bwb_variable *fnc_date();
  1214. extern struct bwb_variable *fnc_time();
  1215. extern struct bwb_variable *fnc_chr();
  1216. extern struct bwb_variable *fnc_mid();
  1217. extern struct bwb_variable *fnc_left();
  1218. extern struct bwb_variable *fnc_right();
  1219. extern struct bwb_variable *fnc_timer();
  1220. extern struct bwb_variable *fnc_val();
  1221. extern struct bwb_variable *fnc_len();
  1222. extern struct bwb_variable *fnc_hex();
  1223. extern struct bwb_variable *fnc_oct();
  1224. extern struct bwb_variable *fnc_cint();
  1225. extern struct bwb_variable *fnc_asc();
  1226. extern struct bwb_variable *fnc_mkd();
  1227. extern struct bwb_variable *fnc_mki();
  1228. extern struct bwb_variable *fnc_mks();
  1229. extern struct bwb_variable *fnc_cvi();
  1230. extern struct bwb_variable *fnc_cvd();
  1231. extern struct bwb_variable *fnc_cvs();
  1232. extern struct bwb_variable *fnc_string();
  1233. extern struct bwb_variable * fnc_spc();
  1234. extern struct bwb_variable * fnc_space();
  1235. extern struct bwb_variable * fnc_environ();
  1236. extern struct bwb_variable * fnc_pos();
  1237. extern struct bwb_variable * fnc_err();
  1238. extern struct bwb_variable * fnc_erl();
  1239. extern struct bwb_variable * fnc_loc();
  1240. extern struct bwb_variable * fnc_lof();
  1241. extern struct bwb_variable * fnc_eof();
  1242. extern struct bwb_variable * fnc_csng();
  1243. extern struct bwb_variable * fnc_instr();
  1244. extern struct bwb_variable * fnc_str();
  1245. extern struct bwb_variable * fnc_inkey();
  1246. extern bnumber trnc_int();
  1247. extern int fnc_checkargs();
  1248. extern int ufsc; /* user function stack counter */
  1249. #if DEBUG
  1250. extern struct bwb_variable *fnc_test();
  1251. #endif
  1252. #endif /* ANSI_C */
  1253. #if COMPRESS_FUNCS
  1254. #define F_ABS 1
  1255. #define F_ATN 2
  1256. #define F_COS 3
  1257. #define F_EXP 4
  1258. #define F_INT 5
  1259. #define F_LOG 6
  1260. #define F_RND 7
  1261. #define F_SGN 8
  1262. #define F_SIN 9
  1263. #define F_SQR 10
  1264. #define F_TAN 11
  1265. #endif