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.
 
 
 
 
 
 

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