home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / misc / volume40 / bwbasic / part07 < prev    next >
Encoding:
Text File  |  1993-10-29  |  70.7 KB  |  2,754 lines

  1. Newsgroups: comp.sources.misc
  2. From: tcamp@delphi.com (Ted A. Campbell)
  3. Subject: v40i058:  bwbasic - Bywater BASIC interpreter version 2.10, Part07/15
  4. Message-ID: <1993Oct29.162613.3785@sparky.sterling.com>
  5. X-Md4-Signature: 76314a64ce85a269d8ba6f851d240f2a
  6. Sender: kent@sparky.sterling.com (Kent Landfield)
  7. Organization: Sterling Software
  8. Date: Fri, 29 Oct 1993 16:26:13 GMT
  9. Approved: kent@sparky.sterling.com
  10.  
  11. Submitted-by: tcamp@delphi.com (Ted A. Campbell)
  12. Posting-number: Volume 40, Issue 58
  13. Archive-name: bwbasic/part07
  14. Environment: UNIX, DOS
  15. Supersedes: bwbasic: Volume 33, Issue 37-47
  16.  
  17. #! /bin/sh
  18. # This is a shell archive.  Remove anything before this line, then feed it
  19. # into a shell via "sh file" or similar.  To overwrite existing files,
  20. # type "sh file -c".
  21. # Contents:  bwbasic-2.10/bwb_cmd.c bwbasic-2.10/bwb_mes.h
  22. # Wrapped by kent@sparky on Thu Oct 21 10:47:50 1993
  23. PATH=/bin:/usr/bin:/usr/ucb:/usr/local/bin:/usr/lbin ; export PATH
  24. echo If this archive is complete, you will see the following message:
  25. echo '          "shar: End of archive 7 (of 15)."'
  26. if test -f 'bwbasic-2.10/bwb_cmd.c' -a "${1}" != "-c" ; then 
  27.   echo shar: Will not clobber existing file \"'bwbasic-2.10/bwb_cmd.c'\"
  28. else
  29.   echo shar: Extracting \"'bwbasic-2.10/bwb_cmd.c'\" \(46688 characters\)
  30.   sed "s/^X//" >'bwbasic-2.10/bwb_cmd.c' <<'END_OF_FILE'
  31. X/***************************************************************
  32. X
  33. X        bwb_cmd.c       Miscellaneous Commands
  34. X                        for Bywater BASIC Interpreter
  35. X
  36. X                        Commands:       RUN
  37. X                                        LET
  38. X                                        LOAD
  39. X                                        MERGE
  40. X                                        CHAIN
  41. X                                        NEW
  42. X                                        RENUM
  43. X                                        SAVE
  44. X                                        LIST
  45. X                                        GOTO
  46. X                                        GOSUB
  47. X                                        RETURN
  48. X                                        ON
  49. X                                        STOP
  50. X                                        END
  51. X                                        SYSTEM
  52. X                                        TRON
  53. X                                        TROFF
  54. X                                        DELETE
  55. X                                        RANDOMIZE
  56. X                    ENVIRON
  57. X                                        CMDS            (*debugging)
  58. X
  59. X                        Copyright (c) 1993, Ted A. Campbell
  60. X                        Bywater Software
  61. X
  62. X                        email: tcamp@delphi.com
  63. X
  64. X        Copyright and Permissions Information:
  65. X
  66. X        All U.S. and international rights are claimed by the author,
  67. X        Ted A. Campbell.
  68. X
  69. X    This software is released under the terms of the GNU General
  70. X    Public License (GPL), which is distributed with this software
  71. X    in the file "COPYING".  The GPL specifies the terms under
  72. X    which users may copy and use the software in this distribution.
  73. X
  74. X    A separate license is available for commercial distribution,
  75. X    for information on which you should contact the author.
  76. X
  77. X***************************************************************/
  78. X
  79. X#include <stdio.h>
  80. X#include <math.h>
  81. X#include <ctype.h>
  82. X
  83. X#include "bwbasic.h"
  84. X#include "bwb_mes.h"
  85. X
  86. X#if HAVE_SIGNAL
  87. X#include <signal.h>
  88. X#endif
  89. X
  90. Xchar err_gosubl[ MAXVARNAMESIZE + 1 ] = { '\0' }; /* line for error GOSUB */
  91. X
  92. X#if ANSI_C
  93. Xextern struct bwb_line *bwb_xnew( struct bwb_line *l );
  94. Xextern struct bwb_line *bwb_onerror( struct bwb_line *l );
  95. Xstruct bwb_line *bwb_donum( struct bwb_line *l );
  96. Xstruct bwb_line *bwb_dounnum( struct bwb_line *l );
  97. Xstatic int xl_line( FILE *file, struct bwb_line *l );
  98. X#else
  99. Xextern struct bwb_line *bwb_xnew();
  100. Xextern struct bwb_line *bwb_onerror();
  101. Xstruct bwb_line *bwb_donum();
  102. Xstruct bwb_line *bwb_dounnum();
  103. Xstatic int xl_line();
  104. X#endif
  105. X
  106. X/***************************************************************
  107. X
  108. X        FUNCTION:       bwb_null()
  109. X
  110. X    DESCRIPTION:    This is a null command function body, and
  111. X            can be used as the basis for developing
  112. X            new BASIC commands.
  113. X
  114. X***************************************************************/
  115. X
  116. X#if ANSI_C
  117. Xstruct bwb_line *
  118. Xbwb_null( struct bwb_line *l )
  119. X#else
  120. Xstruct bwb_line *
  121. Xbwb_null( l )
  122. X   struct bwb_line *l;
  123. X#endif
  124. X   {
  125. X
  126. X#if INTENSIVE_DEBUG
  127. X   sprintf( bwb_ebuf, "in bwb_null(): NULL command" );
  128. X   bwb_debug( bwb_ebuf );
  129. X#endif
  130. X
  131. X#if MULTISEG_LINES
  132. X   adv_eos( l->buffer, &( l->position ));
  133. X#endif
  134. X
  135. X   return bwb_zline( l );
  136. X   }
  137. X
  138. X/***************************************************************
  139. X
  140. X    FUNCTION:       bwb_rem()
  141. X
  142. X    DESCRIPTION:    This C function implements the BASIC rem
  143. X            (REMark) command, ignoring the remainder
  144. X            of the line.
  145. X
  146. X***************************************************************/
  147. X
  148. X#if ANSI_C
  149. Xstruct bwb_line *
  150. Xbwb_rem( struct bwb_line *l )
  151. X#else
  152. Xstruct bwb_line *
  153. Xbwb_rem( l )
  154. X   struct bwb_line *l;
  155. X#endif
  156. X   {
  157. X
  158. X#if INTENSIVE_DEBUG
  159. X   sprintf( bwb_ebuf, "in bwb_rem(): REM command" );
  160. X   bwb_debug( bwb_ebuf );
  161. X#endif
  162. X
  163. X   /* do not use bwb_zline() here; blank out remainder of line */
  164. X
  165. X   l->next->position = 0;
  166. X   return l->next;
  167. X
  168. X   }
  169. X
  170. X/***************************************************************
  171. X
  172. X        FUNCTION:       bwb_let()
  173. X
  174. X    DESCRIPTION:    This C function implements the BASIC
  175. X            LET assignment command, even if LET
  176. X            is implied and not explicit.
  177. X
  178. X    SYNTAX:        LET variable = expression
  179. X
  180. X***************************************************************/
  181. X
  182. X#if ANSI_C
  183. Xstruct bwb_line *
  184. Xbwb_let( struct bwb_line *l )
  185. X#else
  186. Xstruct bwb_line *
  187. Xbwb_let( l )
  188. X   struct bwb_line *l;
  189. X#endif
  190. X   {
  191. X
  192. X#if INTENSIVE_DEBUG
  193. X   sprintf( bwb_ebuf, "in bwb_let(): pos <%d> line <%s>",
  194. X      l->position, l->buffer );
  195. X   bwb_debug( bwb_ebuf );
  196. X#endif
  197. X
  198. X   /* Call the expression interpreter to evaluate the assignment */
  199. X
  200. X   bwb_exp( l->buffer, TRUE, &( l->position ) );
  201. X
  202. X
  203. X   return bwb_zline( l );
  204. X
  205. X   }
  206. X
  207. X/***************************************************************
  208. X
  209. X        FUNCTION:       bwb_go
  210. X
  211. X        DESCRIPTION:    This C function implements the BASIC
  212. X            GO command, branching appropriately to
  213. X            GOTO or GOSUB.
  214. X
  215. X***************************************************************/
  216. X
  217. X#if ANSI_C
  218. Xstruct bwb_line *
  219. Xbwb_go( struct bwb_line *l )
  220. X#else
  221. Xstruct bwb_line *
  222. Xbwb_go( l )
  223. X   struct bwb_line *l;
  224. X#endif
  225. X   {
  226. X   char tbuf[ MAXSTRINGSIZE + 1 ];
  227. X
  228. X   adv_element( l->buffer, &( l->position ), tbuf );
  229. X   bwb_strtoupper( tbuf );
  230. X
  231. X   if ( strcmp( tbuf, CMD_XSUB ) == 0 )
  232. X      {
  233. X      return bwb_gosub( l );
  234. X      }
  235. X
  236. X   if ( strcmp( tbuf, CMD_XTO ) == 0 )
  237. X      {
  238. X      return bwb_goto( l );
  239. X      }
  240. X
  241. X#if PROG_ERRORS
  242. X   sprintf( bwb_ebuf, "in bwb_go(): Nonsense following GO" );
  243. X   bwb_error( bwb_ebuf );
  244. X#else
  245. X   bwb_error( err_syntax );
  246. X#endif
  247. X
  248. X   return bwb_zline( l );
  249. X
  250. X   }
  251. X
  252. X/***************************************************************
  253. X
  254. X        FUNCTION:       bwb_goto
  255. X
  256. X        DESCRIPTION:    This C function implements the BASIC
  257. X            GOTO command.
  258. X
  259. X       SYNTAX:        GOTO line | label
  260. X
  261. X***************************************************************/
  262. X
  263. X#if ANSI_C
  264. Xstruct bwb_line *
  265. Xbwb_goto( struct bwb_line *l )
  266. X#else
  267. Xstruct bwb_line *
  268. Xbwb_goto( l )
  269. X   struct bwb_line *l;
  270. X#endif
  271. X   {
  272. X   struct bwb_line *x;
  273. X   char tbuf[ MAXSTRINGSIZE + 1 ];
  274. X
  275. X#if INTENSIVE_DEBUG
  276. X   sprintf( bwb_ebuf, "in bwb_goto(): entered function" );
  277. X   bwb_debug( bwb_ebuf );
  278. X#endif
  279. X
  280. X   /* Check for argument */
  281. X
  282. X   adv_ws( l->buffer, &( l->position ) );
  283. X   switch( l->buffer[ l->position ] )
  284. X      {
  285. X      case '\0':
  286. X      case '\n':
  287. X      case '\r':
  288. X      case ':':
  289. X         bwb_error( err_noln );
  290. X
  291. X         return bwb_zline( l );
  292. X      default:
  293. X         break;
  294. X      }
  295. X
  296. X   adv_element( l->buffer, &( l->position ), tbuf );
  297. X
  298. X#if INTENSIVE_DEBUG
  299. X   sprintf( bwb_ebuf, "in bwb_goto(): buffer has <%s>", tbuf );
  300. X   bwb_debug( bwb_ebuf );
  301. X#endif
  302. X
  303. X   /* check for target label */
  304. X
  305. X#if STRUCT_CMDS
  306. X
  307. X   if ( isalpha( tbuf[ 0 ] ))
  308. X      {
  309. X
  310. X#if INTENSIVE_DEBUG
  311. X      sprintf( bwb_ebuf, "in bwb_goto(): found LABEL, <%s>", tbuf );
  312. X      bwb_debug( bwb_ebuf );
  313. X#endif
  314. X
  315. X      x = find_label( tbuf );
  316. X      x->position = 0;
  317. X      return x;
  318. X      }
  319. X
  320. X   else
  321. X      {
  322. X      for ( x = &CURTASK bwb_start; x != &CURTASK bwb_end; x = x->next )
  323. X         {
  324. X         if ( x->number == atoi( tbuf ) )
  325. X            {
  326. X
  327. X            /* found the requested number */
  328. X
  329. X#if INTENSIVE_DEBUG
  330. X            sprintf( bwb_ebuf, "in bwb_goto(): returning line <%d>", x->number );
  331. X            bwb_debug( bwb_ebuf );
  332. X#endif
  333. X
  334. X            x->position = 0;
  335. X            return x;
  336. X            }
  337. X         }
  338. X      }
  339. X
  340. X#else
  341. X
  342. X   for ( x = &CURTASK bwb_start; x != &CURTASK bwb_end; x = x->next )
  343. X      {
  344. X      if ( x->number == atoi( tbuf ) )
  345. X         {
  346. X
  347. X         /* found the requested number */
  348. X
  349. X#if INTENSIVE_DEBUG
  350. X         sprintf( bwb_ebuf, "in bwb_goto(): returning line <%d>", x->number );
  351. X         bwb_debug( bwb_ebuf );
  352. X#endif
  353. X
  354. X         x->position = 0;
  355. X         return x;
  356. X         }
  357. X      }
  358. X
  359. X#endif
  360. X
  361. X   sprintf( bwb_ebuf, err_lnnotfound, atoi( tbuf ) );
  362. X   bwb_error( bwb_ebuf );
  363. X
  364. X   return bwb_zline( l );
  365. X   }
  366. X
  367. X/***************************************************************
  368. X
  369. X        FUNCTION:       bwb_gosub()
  370. X
  371. X    DESCRIPTION:    This function implements the BASIC GOSUB
  372. X            command.
  373. X
  374. X       SYNTAX:        GOSUB line | label
  375. X
  376. X***************************************************************/
  377. X
  378. X#if ANSI_C
  379. Xstruct bwb_line *
  380. Xbwb_gosub( struct bwb_line *l )
  381. X#else
  382. Xstruct bwb_line *
  383. Xbwb_gosub( l )
  384. X   struct bwb_line *l;
  385. X#endif
  386. X   {
  387. X   struct bwb_line *x;
  388. X   char atbuf[ MAXSTRINGSIZE + 1 ];
  389. X
  390. X   /* Check for argument */
  391. X
  392. X   adv_ws( l->buffer, &( l->position ) );
  393. X   switch( l->buffer[ l->position ] )
  394. X      {
  395. X      case '\0':
  396. X      case '\n':
  397. X      case '\r':
  398. X      case ':':
  399. X         sprintf( bwb_ebuf, err_noln );
  400. X         bwb_error( bwb_ebuf );
  401. X
  402. X         return bwb_zline( l );
  403. X      default:
  404. X         break;
  405. X      }
  406. X
  407. X   /* get the target line number in tbuf */
  408. X
  409. X   adv_element( l->buffer, &( l->position ), atbuf );
  410. X
  411. X#if MULTISEG_LINES
  412. X   adv_eos( l->buffer, &( l->position ));
  413. X#endif
  414. X
  415. X   /* check for a label rather than line number */
  416. X
  417. X#if STRUCT_CMDS
  418. X
  419. X   if ( isalpha( atbuf[ 0 ] ))
  420. X      {
  421. X      x = find_label( atbuf );
  422. X
  423. X#if MULTISEG_LINES
  424. X      CURTASK excs[ CURTASK exsc ].position = l->position;
  425. X#endif
  426. X
  427. X      bwb_incexec();
  428. X
  429. X      /* set the new position to x and return x */
  430. X
  431. X      x->cmdnum = -1;
  432. X      x->marked = FALSE;
  433. X      x->position = 0;
  434. X      bwb_setexec( x, 0, EXEC_GOSUB );
  435. X
  436. X      return x;
  437. X
  438. X      }
  439. X
  440. X#endif
  441. X
  442. X   for ( x = &CURTASK bwb_start; x != &CURTASK bwb_end; x = x->next )
  443. X      {
  444. X
  445. X      if ( x->number == atoi( atbuf ))
  446. X         {
  447. X
  448. X         /* this is the line we are looking for */
  449. X
  450. X#if MULTISEG_LINES
  451. X         CURTASK excs[ CURTASK exsc ].position = l->position;
  452. X#endif
  453. X
  454. X         /* increment the EXEC stack */
  455. X
  456. X         bwb_incexec();
  457. X
  458. X         /* set the new position to x and return x */
  459. X
  460. X         x->cmdnum = -1;
  461. X         x->marked = FALSE;
  462. X         x->position = 0;
  463. X         bwb_setexec( x, 0, EXEC_GOSUB );
  464. X
  465. X         return x;
  466. X         }
  467. X      }
  468. X
  469. X   /* the requested line was not found */
  470. X
  471. X   sprintf( bwb_ebuf, err_lnnotfound, atoi( atbuf ) );
  472. X   bwb_error( bwb_ebuf );
  473. X
  474. X   return bwb_zline( l );
  475. X
  476. X   }
  477. X
  478. X/***************************************************************
  479. X
  480. X        FUNCTION:       bwb_return()
  481. X
  482. X    DESCRIPTION:    This function implements the BASIC RETURN
  483. X            command.
  484. X
  485. X       SYNTAX:        RETURN
  486. X
  487. X***************************************************************/
  488. X
  489. X#if ANSI_C
  490. Xstruct bwb_line *
  491. Xbwb_return( struct bwb_line *l )
  492. X#else
  493. Xstruct bwb_line *
  494. Xbwb_return( l )
  495. X   struct bwb_line *l;
  496. X#endif
  497. X   {
  498. X
  499. X#if  INTENSIVE_DEBUG
  500. X   sprintf( bwb_ebuf, "in bwb_return() at line <%d> cmdnum <%d>",
  501. X      l->number, l->cmdnum );
  502. X   bwb_debug( bwb_ebuf );
  503. X#endif
  504. X
  505. X   /* see if old position was "GOSUB" */
  506. X
  507. X   if ( CURTASK excs[ CURTASK exsc ].code != EXEC_GOSUB )
  508. X      {
  509. X      bwb_error( err_retnogosub );
  510. X      }
  511. X
  512. X   /* decrement the EXEC stack counter */
  513. X
  514. X   bwb_decexec();
  515. X
  516. X   /* restore position and return old line */
  517. X
  518. X#if MULTISEG_LINES
  519. X   CURTASK excs[ CURTASK exsc ].line->position
  520. X      = CURTASK excs[ CURTASK exsc ].position;
  521. X   return CURTASK excs[ CURTASK exsc ].line;
  522. X#else
  523. X   CURTASK excs[ CURTASK exsc ].line->next->position = 0;
  524. X   return CURTASK excs[ CURTASK exsc ].line->next;
  525. X#endif
  526. X
  527. X   }
  528. X
  529. X/***************************************************************
  530. X
  531. X        FUNCTION:       bwb_on
  532. X
  533. X        DESCRIPTION:    This function implements the BASIC ON...
  534. X                        GOTO or ON...GOSUB statements.
  535. X
  536. X            It will also detect the ON ERROR... statement
  537. X            and pass execution to bwb_onerror().
  538. X
  539. X       SYNTAX:        ON variable GOTO|GOSUB line[,line,line,...]
  540. X
  541. X    LIMITATION:     As implemented here, the ON...GOSUB|GOTO
  542. X            command recognizes line numbers only
  543. X            (not labels).
  544. X
  545. X***************************************************************/
  546. X
  547. X#if ANSI_C
  548. Xstruct bwb_line *
  549. Xbwb_on( struct bwb_line *l )
  550. X#else
  551. Xstruct bwb_line *
  552. Xbwb_on( l )
  553. X   struct bwb_line *l;
  554. X#endif
  555. X   {
  556. X   struct bwb_line *oline, *x;
  557. X   char varname[ MAXVARNAMESIZE + 1 ];
  558. X   char tbuf[ MAXSTRINGSIZE + 1 ];
  559. X   static int p;
  560. X   struct exp_ese *rvar;
  561. X   int v;
  562. X   int loop;
  563. X   int num_lines;
  564. X   int command;
  565. X   int lines[ MAX_GOLINES ];
  566. X   char sbuf[ 7 ];
  567. X
  568. X   /* Check for argument */
  569. X
  570. X   adv_ws( l->buffer, &( l->position ) );
  571. X
  572. X   switch( l->buffer[ l->position ] )
  573. X      {
  574. X      case '\0':
  575. X      case '\n':
  576. X      case '\r':
  577. X      case ':':
  578. X         sprintf( bwb_ebuf, err_incomplete );
  579. X         bwb_error( bwb_ebuf );
  580. X
  581. X         return bwb_zline( l );
  582. X      default:
  583. X         break;
  584. X      }
  585. X
  586. X   /* get the variable name or numerical constant */
  587. X
  588. X   adv_element( l->buffer, &( l->position ), varname );
  589. X
  590. X   /* check for ON ERROR statement */
  591. X
  592. X#if COMMON_CMDS
  593. X   strncpy( sbuf, varname, 6 );
  594. X   bwb_strtoupper( sbuf );
  595. X   if ( strcmp( sbuf, CMD_XERROR ) == 0 )
  596. X      {
  597. X#if INTENSIVE_DEBUG
  598. X      sprintf( bwb_ebuf, "in bwb_on(): detected ON ERROR" );
  599. X      bwb_debug( bwb_ebuf );
  600. X#endif
  601. X      return bwb_onerror( l );
  602. X      }
  603. X#endif    /* COMMON_CMDS */
  604. X
  605. X   /* evaluate the variable name or constant */
  606. X
  607. X   p = 0;
  608. X   rvar = bwb_exp( varname, FALSE, &p );
  609. X   v = (int) exp_getnval( rvar );
  610. X
  611. X#if INTENSIVE_DEBUG
  612. X   sprintf( bwb_ebuf, "in bwb_on(): value is <%d>", v );
  613. X   bwb_debug( bwb_ebuf );
  614. X#endif
  615. X
  616. X   /* Get GOTO or GOSUB statements */
  617. X
  618. X   adv_element( l->buffer, &( l->position ), tbuf );
  619. X   bwb_strtoupper( tbuf );
  620. X   if ( strncmp( tbuf, CMD_GOTO, (size_t) strlen( CMD_GOTO ) ) == 0 )
  621. X      {
  622. X      command = getcmdnum( CMD_GOTO );
  623. X      }
  624. X   else if ( strncmp( tbuf, CMD_GOSUB, (size_t) strlen( CMD_GOSUB ) ) == 0 )
  625. X      {
  626. X      command = getcmdnum( CMD_GOSUB );
  627. X      }
  628. X   else
  629. X      {
  630. X      sprintf( bwb_ebuf, ERR_ONNOGOTO );
  631. X      bwb_error( bwb_ebuf );
  632. X
  633. X      return bwb_zline( l );
  634. X      }
  635. X
  636. X   num_lines = 0;
  637. X
  638. X   loop = TRUE;
  639. X   while( loop == TRUE )
  640. X      {
  641. X
  642. X      /* read a line number */
  643. X
  644. X      inp_adv( l->buffer, &( l->position ) );
  645. X      adv_element( l->buffer, &( l->position ), tbuf );
  646. X
  647. X      lines[ num_lines ] = atoi( tbuf );
  648. X
  649. X      ++num_lines;
  650. X
  651. X      if ( num_lines >= MAX_GOLINES )
  652. X         {
  653. X         loop = FALSE;
  654. X         }
  655. X
  656. X      /* check for end of line */
  657. X
  658. X      adv_ws( l->buffer, &( l->position ) );
  659. X      switch( l->buffer[ l->position ] )
  660. X         {
  661. X         case '\0':
  662. X         case '\n':
  663. X         case '\r':
  664. X         case ':':
  665. X            loop = FALSE;
  666. X            break;
  667. X         }
  668. X
  669. X      }
  670. X
  671. X   /* advance to end of segment */
  672. X
  673. X#if MULTISEG_LINES
  674. X   adv_eos( l->buffer, &( l->position ) );
  675. X#endif
  676. X
  677. X   /* Be sure value is in range */
  678. X
  679. X   if ( ( v < 1 ) || ( v > num_lines ))
  680. X      {
  681. X      sprintf( bwb_ebuf, err_valoorange );
  682. X      bwb_error( bwb_ebuf );
  683. X
  684. X      return bwb_zline( l );
  685. X      }
  686. X
  687. X   if ( command == getcmdnum( CMD_GOTO ))
  688. X      {
  689. X
  690. X#if INTENSIVE_DEBUG
  691. X      sprintf( bwb_ebuf, "in bwb_on(): executing ON...GOTO" );
  692. X      bwb_debug( bwb_ebuf );
  693. X#endif
  694. X
  695. X      oline = NULL;
  696. X      for ( x = &CURTASK bwb_start; x != &CURTASK bwb_end; x = x->next )
  697. X     {
  698. X     if ( x->number == lines[ v - 1 ] )
  699. X        {
  700. X
  701. X        /* found the requested number */
  702. X
  703. X#if INTENSIVE_DEBUG
  704. X        sprintf( bwb_ebuf, "in bwb_on(): returning line <%d>", x->number );
  705. X        bwb_debug( bwb_ebuf );
  706. X#endif
  707. X
  708. X        oline = x;
  709. X        }
  710. X     }
  711. X
  712. X      if ( oline == NULL )
  713. X     {
  714. X     bwb_error( err_lnnotfound );
  715. X     return bwb_zline( l );
  716. X     }
  717. X
  718. X      oline->position = 0;
  719. X      bwb_setexec( oline, 0, CURTASK excs[ CURTASK exsc ].code );
  720. X
  721. X      return oline;
  722. X
  723. X      }
  724. X
  725. X   else if ( command == getcmdnum( CMD_GOSUB ))
  726. X      {
  727. X
  728. X#if INTENSIVE_DEBUG
  729. X      sprintf( bwb_ebuf, "in bwb_on(): executing ON...GOSUB" );
  730. X      bwb_debug( bwb_ebuf );
  731. X#endif
  732. X
  733. X      /* save current stack level */
  734. X
  735. X      bwb_setexec( l, l->position, CURTASK excs[ CURTASK exsc ].code );
  736. X
  737. X      /* increment exec stack */
  738. X
  739. X      bwb_incexec();
  740. X
  741. X      /* get memory for line and buffer */
  742. X
  743. X      if ( ( oline = calloc( 1, sizeof( struct bwb_line ) ) ) == NULL )
  744. X     {
  745. X#if PROG_ERRORS
  746. X     bwb_error( "in bwb_on(): failed to find memory for oline" );
  747. X#else
  748. X     bwb_error( err_getmem );
  749. X#endif
  750. X     }
  751. X      if ( ( oline->buffer = calloc( 1, MAXSTRINGSIZE + 1 ) ) == NULL )
  752. X     {
  753. X#if PROG_ERRORS
  754. X     bwb_error( "in bwb_on(): failed to find memory for oline buffer" );
  755. X#else
  756. X     bwb_error( err_getmem );
  757. X#endif
  758. X     }
  759. X
  760. X      CURTASK excs[ CURTASK exsc ].while_line = oline;
  761. X
  762. X      sprintf( oline->buffer, "%s %d", CMD_GOSUB, lines[ v - 1 ] );
  763. X      oline->marked = FALSE;
  764. X      oline->position = 0;
  765. X      oline->next = l->next;
  766. X      bwb_setexec( oline, 0, EXEC_ON );
  767. X      return oline;
  768. X      }
  769. X
  770. X   else
  771. X      {
  772. X#if PROG_ERRORS
  773. X      sprintf( bwb_ebuf, "in bwb_on(): invalid value for command." );
  774. X      bwb_error( bwb_ebuf );
  775. X#else
  776. X      bwb_error( err_syntax );
  777. X#endif
  778. X
  779. X      return bwb_zline( l );
  780. X      }
  781. X
  782. X   }
  783. X
  784. X/***************************************************************
  785. X
  786. X        FUNCTION:       bwb_stop()
  787. X
  788. X    DESCRIPTION:    This C function implements the BASIC
  789. X            STOP command, interrupting program flow
  790. X            at a specific point.
  791. X
  792. X       SYNTAX:        STOP
  793. X
  794. X***************************************************************/
  795. X
  796. X#if ANSI_C
  797. Xstruct bwb_line *
  798. Xbwb_stop( struct bwb_line *l )
  799. X#else
  800. Xstruct bwb_line *
  801. Xbwb_stop( l )
  802. X   struct bwb_line *l;
  803. X#endif
  804. X   {
  805. X
  806. X#if HAVE_SIGNAL
  807. X#if HAVE_RAISE
  808. X   raise( SIGINT );
  809. X#else
  810. X   kill( getpid(), SIGINT );
  811. X#endif
  812. X#endif
  813. X
  814. X   return bwb_xend( l );
  815. X   }
  816. X
  817. X/***************************************************************
  818. X
  819. X        FUNCTION:       bwb_xend()
  820. X
  821. X    DESCRIPTION:    This C function implements the BASIC
  822. X            END command, checking for END SUB
  823. X            or END FUNCTION, else stopping program
  824. X            execution for a simple END command.
  825. X
  826. X***************************************************************/
  827. X
  828. X#if ANSI_C
  829. Xstruct bwb_line *
  830. Xbwb_xend( struct bwb_line *l )
  831. X#else
  832. Xstruct bwb_line *
  833. Xbwb_xend( l )
  834. X   struct bwb_line *l;
  835. X#endif
  836. X   {
  837. X#if STRUCT_CMDS
  838. X   char tbuf[ MAXSTRINGSIZE + 1 ];
  839. X#endif
  840. X
  841. X#if INTENSIVE_DEBUG
  842. X   sprintf( bwb_ebuf, "in bwb_xend(): entered funtion" );
  843. X   bwb_debug( bwb_ebuf );
  844. X#endif
  845. X
  846. X   /* Detect END SUB or END FUNCTION here */
  847. X
  848. X#if STRUCT_CMDS
  849. X   adv_element( l->buffer, &( l->position ), tbuf );
  850. X   bwb_strtoupper( tbuf );
  851. X
  852. X   if ( strcmp( tbuf, CMD_XSUB ) == 0 )
  853. X      {
  854. X      return bwb_endsub( l );
  855. X      }
  856. X
  857. X   if ( strcmp( tbuf, CMD_XFUNCTION ) == 0 )
  858. X      {
  859. X      return bwb_endfnc( l );
  860. X      }
  861. X
  862. X   if ( strcmp( tbuf, CMD_XIF ) == 0 )
  863. X      {
  864. X      return bwb_endif( l );
  865. X      }
  866. X
  867. X   if ( strcmp( tbuf, CMD_XSELECT ) == 0 )
  868. X      {
  869. X      return bwb_endselect( l );
  870. X      }
  871. X
  872. X#endif            /* STRUCT_CMDS */
  873. X
  874. X   /* else a simple END statement */
  875. X
  876. X   break_handler();
  877. X
  878. X   return &CURTASK bwb_end;
  879. X   }
  880. X
  881. X/***************************************************************
  882. X
  883. X        FUNCTION:       bwb_do()
  884. X
  885. X    DESCRIPTION:    This C function implements the BASIC DO
  886. X            command, also checking for the DO NUM
  887. X            and DO UNNUM commands for interactive
  888. X            programming environment.
  889. X
  890. X***************************************************************/
  891. X
  892. X#if ANSI_C
  893. Xstruct bwb_line *
  894. Xbwb_do( struct bwb_line *l )
  895. X#else
  896. Xstruct bwb_line *
  897. Xbwb_do( l )
  898. X   struct bwb_line *l;
  899. X#endif
  900. X   {
  901. X   char tbuf[ MAXSTRINGSIZE + 1 ];
  902. X
  903. X   adv_element( l->buffer, &( l->position ), tbuf );
  904. X   bwb_strtoupper( tbuf );
  905. X
  906. X   /* if there is no argument (with STRUCT_CMDS) then we have a
  907. X      DO-LOOP structure: pass on to bwb_doloop() in bwb_stc.c */
  908. X
  909. X#if STRUCT_CMDS
  910. X
  911. X   if ( strlen( tbuf ) == 0 )
  912. X      {
  913. X      return bwb_doloop( l );
  914. X      }
  915. X
  916. X   if ( strcmp( tbuf, CMD_WHILE ) == 0 )
  917. X      {
  918. X      return bwb_while( l );
  919. X      }
  920. X#endif
  921. X
  922. X#if INTERACTIVE
  923. X   if ( strcmp( tbuf, CMD_XNUM ) == 0 )
  924. X      {
  925. X      return bwb_donum( l );
  926. X      }
  927. X
  928. X   if ( strcmp( tbuf, CMD_XUNNUM ) == 0 )
  929. X      {
  930. X      return bwb_dounnum( l );
  931. X      }
  932. X#endif                /* INTERACTIVE */
  933. X
  934. X   /* if none of these occurred, then presume an error */
  935. X
  936. X   bwb_error( err_syntax );
  937. X   return bwb_zline( l );
  938. X   }
  939. X
  940. X/***************************************************************
  941. X
  942. X        FUNCTION:       bwb_run()
  943. X
  944. X        DESCRIPTION:    This C function implements the BASIC
  945. X            RUN command.
  946. X
  947. X            Even though RUN is not a core statement,
  948. X            the function bwb_run() is called from
  949. X            core, so it must be present for a minimal
  950. X            implementation.
  951. X
  952. X       SYNTAX:        RUN [line]|[file-name]
  953. X
  954. X***************************************************************/
  955. X
  956. X#if ANSI_C
  957. Xstruct bwb_line *
  958. Xbwb_run( struct bwb_line *l )
  959. X#else
  960. Xstruct bwb_line *
  961. Xbwb_run( l )
  962. X   struct bwb_line *l;
  963. X#endif
  964. X   {
  965. X   struct bwb_line *current, *x;
  966. X   int go_lnumber;                /* line number to go to */
  967. X   char tbuf[ MAXSTRINGSIZE + 1 ];
  968. X   struct exp_ese *e;
  969. X   FILE *input;
  970. X
  971. X#if INTENSIVE_DEBUG
  972. X   sprintf( bwb_ebuf, "in bwb_run(): entered function. buffer <%s> pos <%d>",
  973. X      l->buffer, l->position );
  974. X   bwb_debug( bwb_ebuf );
  975. X#endif
  976. X
  977. X   /* see if there is an element */
  978. X
  979. X   current = NULL;
  980. X   adv_ws( l->buffer, &( l->position ) );
  981. X#if INTENSIVE_DEBUG
  982. X   sprintf( bwb_ebuf, "in bwb_run(): check buffer <%s> pos <%d> char <0x%x>",
  983. X      l->buffer, l->position, l->buffer[ l->position ] );
  984. X   bwb_debug( bwb_ebuf );
  985. X#endif
  986. X   switch ( l->buffer[ l->position ] )
  987. X      {
  988. X      case '\0':
  989. X      case '\n':
  990. X      case '\r':
  991. X      case ':':
  992. X#if INTENSIVE_DEBUG
  993. X         sprintf( bwb_ebuf, "in bwb_run(): no argument; begin at start.next" );
  994. X         bwb_debug( bwb_ebuf );
  995. X#endif
  996. X         current = CURTASK bwb_start.next;
  997. X         e = NULL;
  998. X         break;
  999. X      default:
  1000. X         e = bwb_exp( l->buffer, FALSE, &( l->position ) );
  1001. X         break;
  1002. X      }
  1003. X
  1004. X   /* check its type: if it is a string, open the file and execute it */
  1005. X
  1006. X   if (( e != NULL ) && ( e->type == STRING ))
  1007. X      {
  1008. X      bwb_new( l );                /* clear memory */
  1009. X      str_btoc( tbuf, exp_getsval( e ) );    /* get string in tbuf */
  1010. X      if ( ( input = fopen( tbuf, "r" )) == NULL )    /* open file */
  1011. X         {
  1012. X         sprintf( bwb_ebuf, err_openfile, tbuf );
  1013. X         bwb_error( bwb_ebuf );
  1014. X         }
  1015. X      bwb_fload( input );        /* load program */
  1016. X      bwb_run( &CURTASK bwb_start );            /* and call bwb_run() recursively */
  1017. X      }
  1018. X
  1019. X   /* else if it is a line number, execute the program in memory
  1020. X      at that line number */
  1021. X
  1022. X   else
  1023. X      {
  1024. X
  1025. X      if ( current == NULL )
  1026. X         {
  1027. X
  1028. X         if ( e != NULL )
  1029. X            {
  1030. X            go_lnumber = (int) exp_getnval( e );
  1031. X            }
  1032. X
  1033. X#if INTENSIVE_DEBUG
  1034. X         sprintf( bwb_ebuf, "in bwb_run(): element detected <%s>, lnumber <%d>",
  1035. X            tbuf, go_lnumber );
  1036. X         bwb_debug( bwb_ebuf );
  1037. X#endif
  1038. X
  1039. X         for ( x = CURTASK bwb_start.next; x != &CURTASK bwb_end; x = x->next )
  1040. X            {
  1041. X            if ( x->number == go_lnumber )
  1042. X               {
  1043. X               current = x;
  1044. X               }
  1045. X            }
  1046. X         }
  1047. X
  1048. X      if ( current == NULL )
  1049. X         {
  1050. X         sprintf( bwb_ebuf, err_lnnotfound, go_lnumber );
  1051. X         bwb_error( bwb_ebuf );
  1052. X         return &CURTASK bwb_end;
  1053. X         }
  1054. X
  1055. X#if INTENSIVE_DEBUG
  1056. X      sprintf( bwb_ebuf, "in bwb_run(): ready to run starting at line %d",
  1057. X         current->number );
  1058. X      bwb_debug( bwb_ebuf );
  1059. X#endif
  1060. X
  1061. X      if ( CURTASK rescan == TRUE )
  1062. X         {
  1063. X         bwb_scan();
  1064. X         }
  1065. X
  1066. X      current->position = 0;
  1067. X      CURTASK exsc = 0;
  1068. X      bwb_setexec( current, 0, EXEC_NORM );
  1069. X
  1070. X      }
  1071. X
  1072. X#if INTENSIVE_DEBUG
  1073. X   sprintf( bwb_ebuf, "in bwb_run(): function complete." );
  1074. X   bwb_debug( bwb_ebuf );
  1075. X#endif
  1076. X
  1077. X   return current;
  1078. X
  1079. X   }
  1080. X
  1081. X/***************************************************************
  1082. X
  1083. X        FUNCTION:       bwb_new()
  1084. X
  1085. X        DESCRIPTION:    This C function implements the BASIC
  1086. X            NEW command.
  1087. X
  1088. X            Even though NEW is not a core statement,
  1089. X            the function bwb_run() is called from
  1090. X            core, so it must be present for a minimal
  1091. X            implementation.
  1092. X
  1093. X    SYNTAX:        NEW
  1094. X
  1095. X***************************************************************/
  1096. X
  1097. X#if ANSI_C
  1098. Xstruct bwb_line *
  1099. Xbwb_new( struct bwb_line *l )
  1100. X#else
  1101. Xstruct bwb_line *
  1102. Xbwb_new( l )
  1103. X   struct bwb_line *l;
  1104. X#endif
  1105. X   {
  1106. X
  1107. X   /* clear program in memory */
  1108. X
  1109. X   bwb_xnew( l );
  1110. X
  1111. X   /* clear all variables */
  1112. X
  1113. X   bwb_clear( l );
  1114. X
  1115. X
  1116. X   return bwb_zline( l );
  1117. X
  1118. X   }
  1119. X
  1120. X/* End of Core Functions Section */
  1121. X
  1122. X#if INTERACTIVE
  1123. X
  1124. X/***************************************************************
  1125. X
  1126. X        FUNCTION:       bwb_system()
  1127. X
  1128. X    DESCRIPTION:    This C function implements the BASIC
  1129. X            SYSTEM command, exiting to the operating
  1130. X            system (or calling program).  It is also
  1131. X            called by the QUIT command, a functional
  1132. X            equivalent for SYSTEM in Bywater BASIC.
  1133. X
  1134. X    SYNTAX:        SYSTEM
  1135. X            QUIT
  1136. X
  1137. X***************************************************************/
  1138. X
  1139. X#if ANSI_C
  1140. Xstruct bwb_line *
  1141. Xbwb_system( struct bwb_line *l )
  1142. X#else
  1143. Xstruct bwb_line *
  1144. Xbwb_system( l )
  1145. X   struct bwb_line *l;
  1146. X#endif
  1147. X   {
  1148. X   prn_xprintf( stdout, "\n" );
  1149. X
  1150. X#if INTENSIVE_DEBUG
  1151. X   bwb_debug( "in bwb_system(): ready to exit" );
  1152. X#endif
  1153. X
  1154. X   bwx_terminate();
  1155. X   return &CURTASK bwb_end;                 /* to make LINT happy */
  1156. X
  1157. X   }
  1158. X
  1159. X/***************************************************************
  1160. X
  1161. X        FUNCTION:       bwb_load()
  1162. X
  1163. X        DESCRIPTION:    This C function implements the BASIC
  1164. X            LOAD command.
  1165. X
  1166. X       SYNTAX:        LOAD file-name
  1167. X
  1168. X***************************************************************/
  1169. X
  1170. X#if ANSI_C
  1171. Xstruct bwb_line *
  1172. Xbwb_load( struct bwb_line *l )
  1173. X#else
  1174. Xstruct bwb_line *
  1175. Xbwb_load( l )
  1176. X   struct bwb_line *l;
  1177. X#endif
  1178. X   {
  1179. X
  1180. X   /* clear current contents */
  1181. X
  1182. X   bwb_new( l );
  1183. X
  1184. X   /* call xload function to load program in memory */
  1185. X
  1186. X   bwb_xload( l );
  1187. X
  1188. X   return bwb_zline( l );
  1189. X
  1190. X   }
  1191. X
  1192. X/***************************************************************
  1193. X
  1194. X        FUNCTION:       bwb_xload()
  1195. X
  1196. X        DESCRIPTION:    This C function loads a BASIC program
  1197. X            into memory.
  1198. X
  1199. X***************************************************************/
  1200. X
  1201. X#if ANSI_C
  1202. Xstruct bwb_line *
  1203. Xbwb_xload( struct bwb_line *l )
  1204. X#else
  1205. Xstruct bwb_line *
  1206. Xbwb_xload( l )
  1207. X   struct bwb_line *l;
  1208. X#endif
  1209. X   {
  1210. X   FILE *loadfile;
  1211. X
  1212. X   /* Get an argument for filename */
  1213. X
  1214. X   adv_ws( l->buffer, &( l->position ) );
  1215. X   switch( l->buffer[ l->position ] )
  1216. X      {
  1217. X      case '\0':
  1218. X      case '\n':
  1219. X      case '\r':
  1220. X      case ':':
  1221. X
  1222. X         return bwb_zline( l );
  1223. X      default:
  1224. X         break;
  1225. X      }
  1226. X
  1227. X   bwb_const( l->buffer, CURTASK progfile, &( l->position ) );
  1228. X   if ( ( loadfile = fopen( CURTASK progfile, "r" )) == NULL )
  1229. X      {
  1230. X      sprintf( bwb_ebuf, err_openfile, CURTASK progfile );
  1231. X      bwb_error( bwb_ebuf );
  1232. X
  1233. X      return bwb_zline( l );
  1234. X      }
  1235. X
  1236. X   bwb_fload( loadfile );
  1237. X
  1238. X
  1239. X   return bwb_zline( l );
  1240. X   }
  1241. X
  1242. X/***************************************************************
  1243. X
  1244. X        FUNCTION:       bwb_save()
  1245. X
  1246. X    DESCRIPTION:    This C function implements the BASIC
  1247. X            LOAD command.
  1248. X
  1249. X       SYNTAX:        SAVE file-name
  1250. X
  1251. X***************************************************************/
  1252. X
  1253. X#if ANSI_C
  1254. Xstruct bwb_line *
  1255. Xbwb_save( struct bwb_line *l )
  1256. X#else
  1257. Xstruct bwb_line *
  1258. Xbwb_save( l )
  1259. X   struct bwb_line *l;
  1260. X#endif
  1261. X   {
  1262. X   FILE *outfile;
  1263. X   static char filename[ MAXARGSIZE ];
  1264. X
  1265. X#if INTENSIVE_DEBUG
  1266. X   sprintf( bwb_ebuf, "in bwb_save(): entered function." );
  1267. X   bwb_debug( bwb_ebuf );
  1268. X#endif
  1269. X
  1270. X   /* Get an argument for filename */
  1271. X
  1272. X   adv_ws( l->buffer, &( l->position ) );
  1273. X   switch( l->buffer[ l->position ] )
  1274. X      {
  1275. X      case '\0':
  1276. X      case '\n':
  1277. X      case '\r':
  1278. X      case ':':
  1279. X         bwb_error( err_nofn );
  1280. X
  1281. X         return bwb_zline( l );
  1282. X      default:
  1283. X         break;
  1284. X      }
  1285. X
  1286. X   bwb_const( l->buffer, filename, &( l->position ) );
  1287. X   if ( ( outfile = fopen( filename, "w" )) == NULL )
  1288. X      {
  1289. X      sprintf( bwb_ebuf, err_openfile, filename );
  1290. X      bwb_error( bwb_ebuf );
  1291. X
  1292. X      return bwb_zline( l );
  1293. X      }
  1294. X
  1295. X   bwb_xlist( l, outfile );
  1296. X   fclose( outfile );
  1297. X
  1298. X
  1299. X   return bwb_zline( l );
  1300. X
  1301. X   }
  1302. X
  1303. X/***************************************************************
  1304. X
  1305. X        FUNCTION:       bwb_list()
  1306. X
  1307. X        DESCRIPTION:    This C function implements the BASIC
  1308. X            LIST command.
  1309. X
  1310. X       SYNTAX:        LIST line[-line]
  1311. X
  1312. X***************************************************************/
  1313. X
  1314. X#if ANSI_C
  1315. Xstruct bwb_line *
  1316. Xbwb_list( struct bwb_line *l )
  1317. X#else
  1318. Xstruct bwb_line *
  1319. Xbwb_list( l )
  1320. X   struct bwb_line *l;
  1321. X#endif
  1322. X   {
  1323. X   bwb_xlist( l, stdout );
  1324. X
  1325. X   return bwb_zline( l );
  1326. X   }
  1327. X
  1328. X/***************************************************************
  1329. X
  1330. X        FUNCTION:       bwb_xlist()
  1331. X
  1332. X        DESCRIPTION:    This C function lists the program in
  1333. X            memory to a specified output device.
  1334. X
  1335. X***************************************************************/
  1336. X
  1337. X#if ANSI_C
  1338. Xstruct bwb_line *
  1339. Xbwb_xlist( struct bwb_line *l, FILE *file )
  1340. X#else
  1341. Xstruct bwb_line *
  1342. Xbwb_xlist( l, file )
  1343. X   struct bwb_line *l;
  1344. X   FILE *file;
  1345. X#endif
  1346. X   {
  1347. X   struct bwb_line *start, *end, *current;
  1348. X   int s, e;
  1349. X   int f, r;
  1350. X
  1351. X   start = CURTASK bwb_start.next;
  1352. X   end = &CURTASK bwb_end;
  1353. X
  1354. X   r = bwb_numseq( &( l->buffer[ l->position ] ), &s, &e );
  1355. X
  1356. X   /* advance to the end of the segment */
  1357. X
  1358. X#if MULTISEG_LINES
  1359. X   adv_eos( l->buffer, &( l->position ));
  1360. X#endif
  1361. X
  1362. X   if (( r == FALSE ) || ( s == 0 ))
  1363. X      {
  1364. X      s = CURTASK bwb_start.next->number;
  1365. X      }
  1366. X
  1367. X   if ( e == 0 )
  1368. X      {
  1369. X      e = s;
  1370. X      }
  1371. X
  1372. X   if ( r == FALSE )
  1373. X      {
  1374. X      for ( current = CURTASK bwb_start.next; current != &CURTASK bwb_end; current = current->next )
  1375. X         {
  1376. X         if ( current->next == &CURTASK bwb_end )
  1377. X            {
  1378. X            e = current->number;
  1379. X            }
  1380. X         }
  1381. X      }
  1382. X
  1383. X#if INTENSIVE_DEBUG
  1384. X   sprintf( bwb_ebuf, "in bwb_xlist(): LBUFFER sequence is %d-%d", s, e );
  1385. X   bwb_debug( bwb_ebuf );
  1386. X#endif
  1387. X
  1388. X   /* abort if either number == (MAXLINENO + 1) which denotes CURTASK bwb_end */
  1389. X
  1390. X   if ( ( s == (MAXLINENO + 1)) || ( e == (MAXLINENO + 1 ) ) )
  1391. X      {
  1392. X
  1393. X      return bwb_zline( l );
  1394. X      }
  1395. X
  1396. X   /* Now try to find the actual lines in memory */
  1397. X
  1398. X   f = FALSE;
  1399. X
  1400. X   for ( current = CURTASK bwb_start.next; current != &CURTASK bwb_end; current = current->next )
  1401. X      {
  1402. X      if ( current != l )
  1403. X         {
  1404. X         if (( current->number == s ) && ( f == FALSE ))
  1405. X            {
  1406. X            f = TRUE;
  1407. X        start = current;
  1408. X
  1409. X#if INTENSIVE_DEBUG
  1410. X        sprintf( bwb_ebuf, "in bwb_xlist(): start line number is <%d>",
  1411. X               s );
  1412. X            bwb_debug( bwb_ebuf );
  1413. X#endif
  1414. X
  1415. X            }
  1416. X         }
  1417. X      }
  1418. X
  1419. X   /* check and see if a line number was found */
  1420. X
  1421. X   if ( f == FALSE )
  1422. X      {
  1423. X      sprintf( bwb_ebuf, err_lnnotfound, s );
  1424. X      bwb_error( bwb_ebuf );
  1425. X
  1426. X      return bwb_zline( l );
  1427. X      }
  1428. X
  1429. X   if ( e >= s )
  1430. X      {
  1431. X      for ( current = CURTASK bwb_start.next; current != &CURTASK bwb_end; current = current->next )
  1432. X         {
  1433. X         if ( current != l )
  1434. X            {
  1435. X            if ( current->number == e )
  1436. X               {
  1437. X#if INTENSIVE_DEBUG
  1438. X           sprintf( bwb_ebuf, "in bwb_xlist(): end line number is <%d>",
  1439. X                  current->next->number );
  1440. X               bwb_debug( bwb_ebuf );
  1441. X#endif
  1442. X
  1443. X               end = current->next;
  1444. X               }
  1445. X            }
  1446. X         }
  1447. X      }
  1448. X   else
  1449. X      {
  1450. X      end = start;
  1451. X      }
  1452. X
  1453. X#if INTENSIVE_DEBUG
  1454. X   sprintf( bwb_ebuf, "in bwb_xlist(): line sequence is <%d-%d>",
  1455. X      start->number, end->number );
  1456. X   bwb_debug( bwb_ebuf );
  1457. X#endif
  1458. X
  1459. X   /* previous should now be set to the line previous to the
  1460. X      first in the omission list */
  1461. X
  1462. X   /* now go through and list appropriate lines */
  1463. X
  1464. X   if ( start == end )
  1465. X      {
  1466. X#if INTENSIVE_DEBUG
  1467. X      sprintf( bwb_ebuf, "in bwb_xlist(): start == end" );
  1468. X      bwb_debug( bwb_ebuf );
  1469. X#endif
  1470. X      xl_line( file, start );
  1471. X      }
  1472. X   else
  1473. X      {
  1474. X      for ( current = start; current != end; current = current->next )
  1475. X         {
  1476. X         xl_line( file, current );
  1477. X         }
  1478. X      }
  1479. X
  1480. X   return bwb_zline( l );
  1481. X
  1482. X   }
  1483. X
  1484. X/***************************************************************
  1485. X
  1486. X    FUNCTION:       xl_line()
  1487. X
  1488. X    DESCRIPTION:    This function lists a single program
  1489. X            line to a specified device of file.
  1490. X            It is called by bwb_xlist();
  1491. X
  1492. X***************************************************************/
  1493. X
  1494. X#if ANSI_C
  1495. Xstatic int
  1496. Xxl_line( FILE *file, struct bwb_line *l )
  1497. X#else
  1498. Xstatic int
  1499. Xxl_line( file, l )
  1500. X   FILE *file;
  1501. X   struct bwb_line *l;
  1502. X#endif
  1503. X   {
  1504. X   char tbuf[ MAXSTRINGSIZE + 1 ];
  1505. X
  1506. X   if (( file == stdout ) || ( file == stderr ))
  1507. X      {
  1508. X
  1509. X      if ( l->xnum == TRUE )
  1510. X     {
  1511. X     sprintf( tbuf, "%7d: %s\n", l->number, l->buffer );
  1512. X     }
  1513. X      else
  1514. X     {
  1515. X     sprintf( tbuf, "       : %s\n", l->buffer );
  1516. X     }
  1517. X
  1518. X      prn_xprintf( file, tbuf );
  1519. X      }
  1520. X   else
  1521. X      {
  1522. X
  1523. X      if ( l->xnum == TRUE )
  1524. X     {
  1525. X     fprintf( file, "%d %s\n", l->number, l->buffer );
  1526. X     }
  1527. X      else
  1528. X     {
  1529. X     fprintf( file, "%s\n", l->buffer );
  1530. X     }
  1531. X
  1532. X      }
  1533. X
  1534. X   return TRUE;
  1535. X   }
  1536. X
  1537. X/***************************************************************
  1538. X
  1539. X        FUNCTION:       bwb_delete()
  1540. X
  1541. X    DESCRIPTION:    This C function implements the BASIC
  1542. X            DELETE command for interactive programming,
  1543. X            deleting a specified program line (or lines)
  1544. X            from memory.
  1545. X
  1546. X       SYNTAX:        DELETE line[-line]
  1547. X
  1548. X***************************************************************/
  1549. X
  1550. X#if ANSI_C
  1551. Xstruct bwb_line *
  1552. Xbwb_delete( struct bwb_line *l )
  1553. X#else
  1554. Xstruct bwb_line *
  1555. Xbwb_delete( l )
  1556. X   struct bwb_line *l;
  1557. X#endif
  1558. X   {
  1559. X   struct bwb_line *start, *end, *current, *previous, *p, *next;
  1560. X   static int s, e;
  1561. X   int f;
  1562. X
  1563. X   previous = &CURTASK bwb_start;
  1564. X   start = CURTASK bwb_start.next;
  1565. X   end = &CURTASK bwb_end;
  1566. X
  1567. X   bwb_numseq( &( l->buffer[ l->position ] ), &s, &e );
  1568. X
  1569. X#if INTENSIVE_DEBUG
  1570. X   sprintf( bwb_ebuf, "in bwb_delete(): LBUFFER sequence is %d-%d", s, e );
  1571. X   bwb_debug( bwb_ebuf );
  1572. X#endif
  1573. X
  1574. X   /* advance to the end of the segment */
  1575. X
  1576. X#if MULTISEG_LINES
  1577. X   adv_eos( l->buffer, &( l->position ));
  1578. X#endif
  1579. X
  1580. X   /* Now try to find the actual lines in memory */
  1581. X
  1582. X   previous = p = &CURTASK bwb_start;
  1583. X   f = FALSE;
  1584. X
  1585. X   for ( current = CURTASK bwb_start.next; current != &CURTASK bwb_end; current = current->next )
  1586. X      {
  1587. X      if ( current != l )
  1588. X         {
  1589. X         if (( current->xnum == TRUE ) && ( current->number == s ))
  1590. X            {
  1591. X            f = TRUE;
  1592. X            previous = p;
  1593. X            start = current;
  1594. X
  1595. X#if INTENSIVE_DEBUG
  1596. X            sprintf( bwb_ebuf, "in bwb_delete(): start line number is <%d>",
  1597. X               s );
  1598. X            bwb_debug( bwb_ebuf );
  1599. X#endif
  1600. X
  1601. X            }
  1602. X         }
  1603. X      p = current;
  1604. X      }
  1605. X
  1606. X   /* check and see if a line number was found */
  1607. X
  1608. X   if ( f == FALSE )
  1609. X      {
  1610. X      sprintf( bwb_ebuf, err_lnnotfound, s );
  1611. X      bwb_error( bwb_ebuf );
  1612. X
  1613. X      return bwb_zline( l );
  1614. X      }
  1615. X
  1616. X   if ( e > s )
  1617. X      {
  1618. X      for ( current = CURTASK bwb_start.next; current != &CURTASK bwb_end; current = current->next )
  1619. X         {
  1620. X         if ( current != l )
  1621. X            {
  1622. X            if (( current->xnum == TRUE) &&  ( current->number == e ))
  1623. X               {
  1624. X#if INTENSIVE_DEBUG
  1625. X           sprintf( bwb_ebuf, "in bwb_delete(): end line number is <%d>",
  1626. X          e );
  1627. X           bwb_debug( bwb_ebuf );
  1628. X#endif
  1629. X
  1630. X               end = current->next;
  1631. X               }
  1632. X            }
  1633. X         }
  1634. X      }
  1635. X   else
  1636. X      {
  1637. X      end = start->next;
  1638. X      }
  1639. X
  1640. X   /* previous should now be set to the line previous to the
  1641. X      first in the omission list */
  1642. X
  1643. X   /* now go through and delete appropriate lines */
  1644. X
  1645. X   current = start;
  1646. X   while (( current != end ) && ( current != &CURTASK bwb_end ))
  1647. X      {
  1648. X      next = current->next;
  1649. X
  1650. X#if INTENSIVE_DEBUG
  1651. X      sprintf( bwb_ebuf, "in bwb_delete(): deleting line %d",
  1652. X         current->number );
  1653. X      bwb_debug( bwb_ebuf );
  1654. X#endif
  1655. X
  1656. X      /* free line memory */
  1657. X
  1658. X      bwb_freeline( current );
  1659. X
  1660. X      /* recycle */
  1661. X
  1662. X      current = next;
  1663. X      }
  1664. X
  1665. X   /* reset link */
  1666. X
  1667. X   previous->next = current;
  1668. X
  1669. X
  1670. X   return bwb_zline( l );
  1671. X   }
  1672. X
  1673. X/***************************************************************
  1674. X
  1675. X        FUNCTION:       bwb_donum()
  1676. X
  1677. X    DESCRIPTION:    This function implements the BASIC DO
  1678. X            NUM command, numbering all program lines
  1679. X            in memory in increments of 10 beginning
  1680. X            at 10.
  1681. X
  1682. X    SYNTAX:        DO NUM
  1683. X
  1684. X***************************************************************/
  1685. X
  1686. X#if ANSI_C
  1687. Xstruct bwb_line *
  1688. Xbwb_donum( struct bwb_line *l )
  1689. X#else
  1690. Xstruct bwb_line *
  1691. Xbwb_donum( l )
  1692. X   struct bwb_line *l;
  1693. X#endif
  1694. X   {
  1695. X   struct bwb_line *current;
  1696. X   register int lnumber;
  1697. X
  1698. X   lnumber = 10;
  1699. X   for ( current = bwb_start.next; current != &bwb_end; current = current->next )
  1700. X      {
  1701. X      current->number = lnumber;
  1702. X      current->xnum = TRUE;
  1703. X
  1704. X      lnumber += 10;
  1705. X      if ( lnumber >= MAXLINENO )
  1706. X         {
  1707. X         return bwb_zline( l );
  1708. X         }
  1709. X      }
  1710. X
  1711. X   return bwb_zline( l );
  1712. X   }
  1713. X
  1714. X/***************************************************************
  1715. X
  1716. X        FUNCTION:       bwb_dounnum()
  1717. X
  1718. X    DESCRIPTION:    This function implements the BASIC DO
  1719. X            UNNUM command, removing all line numbers
  1720. X            from the program in memory.
  1721. X
  1722. X    SYNTAX:        DO UNNUM
  1723. X
  1724. X***************************************************************/
  1725. X
  1726. X#if ANSI_C
  1727. Xstruct bwb_line *
  1728. Xbwb_dounnum( struct bwb_line *l )
  1729. X#else
  1730. Xstruct bwb_line *
  1731. Xbwb_dounnum( l )
  1732. X   struct bwb_line *l;
  1733. X#endif
  1734. X   {
  1735. X   struct bwb_line *current;
  1736. X
  1737. X   for ( current = bwb_start.next; current != &bwb_end; current = current->next )
  1738. X      {
  1739. X      current->number = 0;
  1740. X      current->xnum = FALSE;
  1741. X      }
  1742. X
  1743. X   return bwb_zline( l );
  1744. X   }
  1745. X
  1746. X#endif                /* INTERACTIVE */
  1747. X
  1748. X#if COMMON_CMDS
  1749. X
  1750. X/***************************************************************
  1751. X
  1752. X        FUNCTION:       bwb_chain()
  1753. X
  1754. X        DESCRIPTION:    This C function implements the BASIC
  1755. X            CHAIN command.
  1756. X
  1757. X       SYNTAX:        CHAIN file-name
  1758. X
  1759. X***************************************************************/
  1760. X
  1761. X#if ANSI_C
  1762. Xstruct bwb_line *
  1763. Xbwb_chain( struct bwb_line *l )
  1764. X#else
  1765. Xstruct bwb_line *
  1766. Xbwb_chain( l )
  1767. X   struct bwb_line *l;
  1768. X#endif
  1769. X   {
  1770. X
  1771. X   /* deallocate all variables except common ones */
  1772. X
  1773. X   var_delcvars();
  1774. X
  1775. X   /* remove old program from memory */
  1776. X
  1777. X   bwb_xnew( l );
  1778. X
  1779. X   /* call xload function to load new program in memory */
  1780. X
  1781. X   bwb_xload( l );
  1782. X
  1783. X   /* reset all stack counters */
  1784. X
  1785. X   CURTASK exsc = -1;
  1786. X   CURTASK expsc = 0;
  1787. X   CURTASK xtxtsc = 0;
  1788. X
  1789. X   /* run the program */
  1790. X
  1791. X   return bwb_run( &CURTASK bwb_start  );
  1792. X
  1793. X   }
  1794. X
  1795. X/***************************************************************
  1796. X
  1797. X        FUNCTION:       bwb_merge()
  1798. X
  1799. X        DESCRIPTION:    This C function implements the BASIC
  1800. X            MERGE command, merging command lines from
  1801. X            a specified file into the program in memory
  1802. X            without deleting the lines already in memory.
  1803. X
  1804. X       SYNTAX:        MERGE file-name
  1805. X
  1806. X***************************************************************/
  1807. X
  1808. X#if ANSI_C
  1809. Xstruct bwb_line *
  1810. Xbwb_merge( struct bwb_line *l )
  1811. X#else
  1812. Xstruct bwb_line *
  1813. Xbwb_merge( l )
  1814. X   struct bwb_line *l;
  1815. X#endif
  1816. X   {
  1817. X
  1818. X   /* call xload function to merge program in memory */
  1819. X
  1820. X   bwb_xload( l );
  1821. X
  1822. X
  1823. X   return bwb_zline( l );
  1824. X
  1825. X   }
  1826. X
  1827. X/***************************************************************
  1828. X
  1829. X        FUNCTION:       bwb_onerror()
  1830. X
  1831. X        DESCRIPTION:    This C function implements the BASIC
  1832. X                ON ERROR GOSUB command.
  1833. X
  1834. X       SYNTAX:        ON ERROR GOSUB line | label
  1835. X
  1836. X***************************************************************/
  1837. X
  1838. X#if ANSI_C
  1839. Xstruct bwb_line *
  1840. Xbwb_onerror( struct bwb_line *l )
  1841. X#else
  1842. Xstruct bwb_line *
  1843. Xbwb_onerror( l )
  1844. X   struct bwb_line *l;
  1845. X#endif
  1846. X   {
  1847. X   char tbuf[ MAXSTRINGSIZE + 1 ];
  1848. X
  1849. X#if INTENSIVE_DEBUG
  1850. X   sprintf( bwb_ebuf, "in bwb_onerror(): entered function" );
  1851. X   bwb_debug( bwb_ebuf );
  1852. X#endif
  1853. X
  1854. X   /* get the GOSUB STATEMENT */
  1855. X
  1856. X   adv_element( l->buffer, &( l->position ), tbuf );
  1857. X
  1858. X   /* check for GOSUB statement */
  1859. X
  1860. X   bwb_strtoupper( tbuf );
  1861. X   if ( strcmp( tbuf, CMD_GOSUB ) != 0 )
  1862. X      {
  1863. X#if PROG_ERRORS
  1864. X      sprintf( bwb_ebuf, "in bwb_onerror(): GOSUB statement missing" );
  1865. X      bwb_error( bwb_ebuf );
  1866. X#else
  1867. X      bwb_error( err_syntax );
  1868. X#endif
  1869. X
  1870. X      return bwb_zline( l );
  1871. X      }
  1872. X
  1873. X   /* get the GOSUB line */
  1874. X
  1875. X   adv_element( l->buffer, &( l->position ), err_gosubl );
  1876. X
  1877. X   return bwb_zline( l );
  1878. X
  1879. X   }
  1880. X
  1881. X/***************************************************************
  1882. X
  1883. X        FUNCTION:       bwb_tron()
  1884. X
  1885. X    DESCRIPTION:    This function implements the BASIC TRON
  1886. X            command, turning the trace mechanism on.
  1887. X
  1888. X    SYNTAX:        TRON
  1889. X
  1890. X***************************************************************/
  1891. X
  1892. X#if ANSI_C
  1893. Xstruct bwb_line *
  1894. Xbwb_tron( struct bwb_line *l )
  1895. X#else
  1896. Xstruct bwb_line *
  1897. Xbwb_tron( l )
  1898. X   struct bwb_line *l;
  1899. X#endif
  1900. X   {
  1901. X   bwb_trace = TRUE;
  1902. X   prn_xprintf( stdout, "Trace is ON\n" );
  1903. X
  1904. X   return bwb_zline( l );
  1905. X   }
  1906. X
  1907. X/***************************************************************
  1908. X
  1909. X        FUNCTION:       bwb_troff()
  1910. X
  1911. X    DESCRIPTION:    This function implements the BASIC TROFF
  1912. X            command, turning the trace mechanism off.
  1913. X
  1914. X    SYNTAX:        TROFF
  1915. X
  1916. X***************************************************************/
  1917. X
  1918. X#if ANSI_C
  1919. Xstruct bwb_line *
  1920. Xbwb_troff( struct bwb_line *l )
  1921. X#else
  1922. Xstruct bwb_line *
  1923. Xbwb_troff( l )
  1924. X   struct bwb_line *l;
  1925. X#endif
  1926. X   {
  1927. X   bwb_trace = FALSE;
  1928. X   prn_xprintf( stdout, "Trace is OFF\n" );
  1929. X
  1930. X   return bwb_zline( l );
  1931. X   }
  1932. X
  1933. X#endif                /* COMMON_CMDS */
  1934. X
  1935. X/***************************************************************
  1936. X
  1937. X        FUNCTION:       bwb_randomize()
  1938. X
  1939. X    DESCRIPTION:    This function implements the BASIC
  1940. X            RANDOMIZE command, seeding the pseudo-
  1941. X            random number generator.
  1942. X
  1943. X    SYNTAX:        RANDOMIZE number
  1944. X
  1945. X***************************************************************/
  1946. X
  1947. X#if ANSI_C
  1948. Xstruct bwb_line *
  1949. Xbwb_randomize( struct bwb_line *l )
  1950. X#else
  1951. Xstruct bwb_line *
  1952. Xbwb_randomize( l )
  1953. X   struct bwb_line *l;
  1954. X#endif
  1955. X   {
  1956. X   register unsigned n;
  1957. X   struct exp_ese *e;
  1958. X
  1959. X   /* Check for argument */
  1960. X
  1961. X   adv_ws( l->buffer, &( l->position ) );
  1962. X   switch( l->buffer[ l->position ] )
  1963. X      {
  1964. X      case '\0':
  1965. X      case '\n':
  1966. X      case '\r':
  1967. X#if MULTISEG_LINES
  1968. X      case ':':
  1969. X#endif
  1970. X         n = (unsigned) 1;
  1971. X         break;
  1972. X      default:
  1973. X         n = (unsigned) 0;
  1974. X         break;
  1975. X      }
  1976. X
  1977. X   /* get the argument in tbuf */
  1978. X
  1979. X   if ( n == (unsigned) 0 )
  1980. X      {
  1981. X      e = bwb_exp( l->buffer, FALSE, &( l->position ) );
  1982. X      n = (unsigned) exp_getnval( e );
  1983. X      }
  1984. X
  1985. X#if INTENSIVE_DEBUG
  1986. X   sprintf( bwb_ebuf, "in bwb_randomize(): argument is <%d>", n );
  1987. X   bwb_debug( bwb_ebuf );
  1988. X#endif
  1989. X
  1990. X   srand( n );
  1991. X
  1992. X   return bwb_zline( l );
  1993. X   }
  1994. X
  1995. X
  1996. X/***************************************************************
  1997. X
  1998. X        FUNCTION:       bwb_xnew()
  1999. X
  2000. X        DESCRIPTION:    Clears the program in memory, but does not
  2001. X            deallocate all variables.
  2002. X
  2003. X***************************************************************/
  2004. X
  2005. X#if ANSI_C
  2006. Xstruct bwb_line *
  2007. Xbwb_xnew( struct bwb_line *l )
  2008. X#else
  2009. Xstruct bwb_line *
  2010. Xbwb_xnew( l )
  2011. X   struct bwb_line *l;
  2012. X#endif
  2013. X   {
  2014. X   struct bwb_line *current, *previous;
  2015. X   int wait;
  2016. X
  2017. X   wait = TRUE;
  2018. X   for ( current = CURTASK bwb_start.next; current != &CURTASK bwb_end; current = current->next )
  2019. X      {
  2020. X      if ( wait != TRUE )
  2021. X         {
  2022. X         free( previous );
  2023. X         }
  2024. X      wait = FALSE;
  2025. X      previous = current;
  2026. X      }
  2027. X
  2028. X   CURTASK bwb_start.next = &CURTASK bwb_end;
  2029. X
  2030. X   return bwb_zline( l );
  2031. X   }
  2032. X
  2033. X#if UNIX_CMDS
  2034. X
  2035. X/***************************************************************
  2036. X
  2037. X        FUNCTION:       bwb_environ()
  2038. X
  2039. X        DESCRIPTION:    This C function implements the BASIC
  2040. X            ENVIRON command, assigning a string
  2041. X            value to an environment variable.
  2042. X
  2043. X    SYNTAX:        ENVIRON variable-string$ = string$
  2044. X
  2045. X***************************************************************/
  2046. X
  2047. X#if ANSI_C
  2048. Xstruct bwb_line *
  2049. Xbwb_environ( struct bwb_line *l )
  2050. X#else
  2051. Xstruct bwb_line *
  2052. Xbwb_environ( l )
  2053. X   struct bwb_line *l;
  2054. X#endif
  2055. X   {
  2056. X   static char tbuf[ MAXSTRINGSIZE + 1 ];
  2057. X   char tmp[ MAXSTRINGSIZE + 1 ];
  2058. X   register int i;
  2059. X   int pos;
  2060. X   struct exp_ese *e;
  2061. X
  2062. X   /* find the equals sign */
  2063. X
  2064. X   for ( i = 0; ( l->buffer[ l->position ] != '=' ) && ( l->buffer[ l->position ] != '\0' ); ++i )
  2065. X      {
  2066. X      tbuf[ i ] = l->buffer[ l->position ];
  2067. X      tbuf[ i + 1 ] = '\0';
  2068. X      ++( l->position );
  2069. X      }
  2070. X
  2071. X#if INTENSIVE_DEBUG
  2072. X   sprintf( bwb_ebuf, "in bwb_environ(): variable string is <%s>", tbuf );
  2073. X   bwb_debug( bwb_ebuf );
  2074. X#endif
  2075. X
  2076. X   /* get the value string to be assigned */
  2077. X
  2078. X   pos = 0;
  2079. X   e = bwb_exp( tbuf, FALSE, &pos );
  2080. X   str_btoc( tbuf, exp_getsval( e ) );
  2081. X
  2082. X#if INTENSIVE_DEBUG
  2083. X   sprintf( bwb_ebuf, "in bwb_environ(): variable string resolves to <%s>", tbuf );
  2084. X   bwb_debug( bwb_ebuf );
  2085. X#endif
  2086. X
  2087. X   /* find the equals sign */
  2088. X
  2089. X   adv_ws( l->buffer, &( l->position ) );
  2090. X   if ( l->buffer[ l->position ] != '=' )
  2091. X      {
  2092. X#if PROG_ERRORS
  2093. X      sprintf( bwb_ebuf, "in bwb_environ(): failed to find equal sign" );
  2094. X      bwb_error( bwb_ebuf );
  2095. X#else
  2096. X      bwb_error( err_syntax );
  2097. X#endif
  2098. X
  2099. X      return bwb_zline( l );
  2100. X      }
  2101. X   ++( l->position );
  2102. X
  2103. X   /* get the value string to be assigned */
  2104. X
  2105. X   e = bwb_exp( l->buffer, FALSE, &( l->position ));
  2106. X   str_btoc( tmp, exp_getsval( e ) );
  2107. X
  2108. X#if INTENSIVE_DEBUG
  2109. X   sprintf( bwb_ebuf, "in bwb_environ(): value string resolves to <%s>", tmp );
  2110. X   bwb_debug( bwb_ebuf );
  2111. X#endif
  2112. X
  2113. X   /* construct string */
  2114. X
  2115. X   strcat( tbuf, "=" );
  2116. X   strcat( tbuf, tmp );
  2117. X
  2118. X#if INTENSIVE_DEBUG
  2119. X   sprintf( bwb_ebuf, "in bwb_environ(): assignment string is <%s>", tbuf );
  2120. X   bwb_debug( bwb_ebuf );
  2121. X#endif
  2122. X
  2123. X   /* now assign value to variable */
  2124. X
  2125. X   if ( putenv( tbuf ) == -1 )
  2126. X      {
  2127. X      bwb_error( err_opsys );
  2128. X
  2129. X      return bwb_zline( l );
  2130. X      }
  2131. X
  2132. X   /* return */
  2133. X
  2134. X
  2135. X   return bwb_zline( l );
  2136. X
  2137. X   }
  2138. X
  2139. X#endif                    /* UNIX_CMDS */
  2140. X
  2141. X/***************************************************************
  2142. X
  2143. X        FUNCTION:       bwb_cmds()
  2144. X
  2145. X    DESCRIPTION:    This function implements a CMD command,
  2146. X            which lists all commands implemented.
  2147. X            It is not part of a BASIC specification,
  2148. X            but is used for debugging bwBASIC.
  2149. X
  2150. X    SYNTAX:        CMDS
  2151. X
  2152. X***************************************************************/
  2153. X
  2154. X#if PERMANENT_DEBUG
  2155. X
  2156. X#if ANSI_C
  2157. Xstruct bwb_line *
  2158. Xbwb_cmds( struct bwb_line *l )
  2159. X#else
  2160. Xstruct bwb_line *
  2161. Xbwb_cmds( l )
  2162. X   struct bwb_line *l;
  2163. X#endif
  2164. X   {
  2165. X   register int n;
  2166. X   char tbuf[ MAXSTRINGSIZE + 1 ];
  2167. X
  2168. X   prn_xprintf( stdout, "BWBASIC COMMANDS AVAILABLE: \n" );
  2169. X
  2170. X   /* run through the command table and print comand names */
  2171. X
  2172. X   for ( n = 0; n < COMMANDS; ++n )
  2173. X      {
  2174. X      sprintf( tbuf, "%s \n", bwb_cmdtable[ n ].name );
  2175. X      prn_xprintf( stdout, tbuf );
  2176. X      }
  2177. X
  2178. X   return bwb_zline( l );
  2179. X   }
  2180. X#endif
  2181. X
  2182. X/***************************************************************
  2183. X
  2184. X    FUNCTION:       getcmdnum()
  2185. X
  2186. X    DESCRIPTION:    This function returns the number associated
  2187. X            with a specified command (cmdstr) in the
  2188. X            command table.
  2189. X
  2190. X***************************************************************/
  2191. X
  2192. X#if ANSI_C
  2193. Xint
  2194. Xgetcmdnum( char *cmdstr )
  2195. X#else
  2196. Xint
  2197. Xgetcmdnum( cmdstr )
  2198. X   char *cmdstr;
  2199. X#endif
  2200. X   {
  2201. X   register int c;
  2202. X
  2203. X   for ( c = 0; c < COMMANDS; ++c )
  2204. X      {
  2205. X      if ( strcmp( bwb_cmdtable[ c ].name, cmdstr ) == 0 )
  2206. X         {
  2207. X         return c;
  2208. X         }
  2209. X      }
  2210. X
  2211. X   return -1;
  2212. X
  2213. X   }
  2214. X
  2215. X/***************************************************************
  2216. X
  2217. X        FUNCTION:       bwb_zline()
  2218. X
  2219. X        DESCRIPTION:    This function is called at the exit from
  2220. X                Bywater BASIC command functions.  If
  2221. X                MULTISEG_LINES is TRUE, then it returns
  2222. X                a pointer to the current line; otherwise it
  2223. X                sets the position in the next line to zero
  2224. X                and returns a pointer to the next line.
  2225. X
  2226. X***************************************************************/
  2227. X
  2228. X#if ANSI_C
  2229. Xextern struct bwb_line *
  2230. Xbwb_zline( struct bwb_line *l )
  2231. X#else
  2232. Xstruct bwb_line *
  2233. Xbwb_zline( l )
  2234. X   struct bwb_line *l;
  2235. X#endif
  2236. X   {
  2237. X#if MULTISEG_LINES
  2238. X   /* l->marked = FALSE; */
  2239. X   return l;
  2240. X#else
  2241. X   l->next->position = 0;
  2242. X   return l->next;
  2243. X#endif
  2244. X   }
  2245. X
  2246. X
  2247. END_OF_FILE
  2248.   if test 46688 -ne `wc -c <'bwbasic-2.10/bwb_cmd.c'`; then
  2249.     echo shar: \"'bwbasic-2.10/bwb_cmd.c'\" unpacked with wrong size!
  2250.   fi
  2251.   # end of 'bwbasic-2.10/bwb_cmd.c'
  2252. fi
  2253. if test -f 'bwbasic-2.10/bwb_mes.h' -a "${1}" != "-c" ; then 
  2254.   echo shar: Will not clobber existing file \"'bwbasic-2.10/bwb_mes.h'\"
  2255. else
  2256.   echo shar: Extracting \"'bwbasic-2.10/bwb_mes.h'\" \(20585 characters\)
  2257.   sed "s/^X//" >'bwbasic-2.10/bwb_mes.h' <<'END_OF_FILE'
  2258. X/***************************************************************
  2259. X
  2260. X        bwb_mes.h       Header File for Natural-Language-Specific
  2261. X                        Text Messages for Bywater BASIC Interpreter
  2262. X
  2263. X                        Copyright (c) 1993, Ted A. Campbell
  2264. X                        Bywater Software
  2265. X
  2266. X                        email: tcamp@delphi.com
  2267. X
  2268. X        Copyright and Permissions Information:
  2269. X
  2270. X        All U.S. and international rights are claimed by the author,
  2271. X        Ted A. Campbell.
  2272. X
  2273. X    This software is released under the terms of the GNU General
  2274. X    Public License (GPL), which is distributed with this software
  2275. X    in the file "COPYING".  The GPL specifies the terms under
  2276. X    which users may copy and use the software in this distribution.
  2277. X
  2278. X    A separate license is available for commercial distribution,
  2279. X    for information on which you should contact the author.
  2280. X
  2281. X***************************************************************/
  2282. X
  2283. X
  2284. X#ifndef TRUE
  2285. X#define TRUE    1
  2286. X#define FALSE   0
  2287. X#endif
  2288. X
  2289. X/****************************************************************
  2290. X
  2291. X    The following Latin conventions are used:
  2292. X
  2293. X    LATIN            ENGLISH
  2294. X
  2295. X    acies datorum        array (of data)
  2296. X        crusta            shell
  2297. X    litteras        (character) string
  2298. X    memoria mutabilis    RAM
  2299. X    organum            device
  2300. X    ordo            line
  2301. X    praeceptum        command
  2302. X      praecepta          program (commands)
  2303. X      praecepta interna      operating system
  2304. X      praeceptellum          function
  2305. X    tabula            file
  2306. X
  2307. X****************************************************************/
  2308. X
  2309. X#if LATIN
  2310. X#define MES_SIGNON      "Interpres <Super Flumina> ad linguam BASIC, versionis"
  2311. X#define MES_COPYRIGHT   "Iure proprio scriptoris (c) 1993, Eduardi de Campobello"
  2312. X#define MES_LANGUAGE    "Cum nuntiis latinis ab ipso E. de C."
  2313. X#define PROMPT          "bwBASIC: "
  2314. X#define ERROR_HEADER    "ERRANT praecepta in ordine"
  2315. X#define ERRD_HEADER     "ERRANT praecepta"
  2316. X#define MATHERR_HEADER  "ERRANT praecepta"
  2317. X#define MES_BREAK       "Intermittuntur praecepta in ordine"
  2318. X#define ERR_OPENFILE    "Non patet tabula quod <%s> vocatur"
  2319. X#define ERR_GETMEM      "Deest memoria mutabilis"
  2320. X#define ERR_LINENO      "Non adicitur novus ordo praeceptorum"
  2321. X#define ERR_LNNOTFOUND  "Non invenitur ordo praeceptorum <%d>"
  2322. X#define ERR_LOADNOFN    "LOAD requirit nomen ad tabulam"
  2323. X#define ERR_NOLN        "Non invenitur ordo praeceptorum"
  2324. X#define ERR_NOFN        "Non invenitur nomen ad tabulam"
  2325. X#define ERR_RETNOGOSUB  "RETURN sine GOSUB"
  2326. X#define ERR_INCOMPLETE  "Praeceptum imcompletum"
  2327. X#define ERR_ONNOGOTO    "ON sine GOTO sive GOSUB"
  2328. X#define ERR_VALOORANGE  "Numerus in praeceptis excedit fines"
  2329. X#define ERR_SYNTAX      "Non sequunter praecepta"
  2330. X#define ERR_DEVNUM      "Numerus ad organum invalidum est"
  2331. X#define ERR_DEV         "Errat organum"
  2332. X#define ERR_OPSYS    "Errant praecepta interna"
  2333. X#define ERR_ARGSTR    "Praeceptum requirit litteras"
  2334. X#define ERR_DEFCHAR    "ad varium definiendum"
  2335. X#define ERR_MISMATCH    "Non congruunt typus"
  2336. X#define ERR_DIMNOTARRAY    "Praeceptum requirit nomen ad aciem datorum"
  2337. X#define ERR_OD        "Desunt data"
  2338. X#define ERR_OVERFLOW    "Data excedunt fines"
  2339. X#define ERR_NF        "NEXT sine FOR"
  2340. X#define ERR_UF        "Non definitur praeceptellum"
  2341. X#define ERR_DBZ        "Non licet divisio ab nihilo"
  2342. X#define ERR_REDIM    "Non licet varium iterum definiendum"
  2343. X#define ERR_OBDIM    "Debet OPTION BASE procedere DIM"
  2344. X#define ERR_UC        "Praeceptum incognitum est"
  2345. X#define ERR_NOPROGFILE    "Tabula praeceptorum non invenitur"
  2346. X#endif
  2347. X
  2348. X#if POL_ENGLISH
  2349. X#define MES_SIGNON      "Bywater BASIC Interpreter/Shell, version"
  2350. X#define MES_COPYRIGHT   "Copyright (c) 1993, Ted A. Campbell"
  2351. X#define MES_LANGUAGE    "Polite English messages courtesy of t.a.c."
  2352. X#define PROMPT          "How may we help you? "
  2353. X#define ERROR_HEADER    "Very sorry. There is a problem in line"
  2354. X#define ERRD_HEADER     "Very sorry. There is a problem"
  2355. X#define MATHERR_HEADER  "We have a small problem"
  2356. X#define MES_BREAK       "At your request, the program has been interrupted at line"
  2357. X#define ERR_OPENFILE    "I'm afraid we have failed \nto open file %s."
  2358. X#define ERR_GETMEM      "I'm afraid we have failed \nto find sufficient memory."
  2359. X#define ERR_LINENO      "I'm afraid we have failed \nto link line number."
  2360. X#define ERR_LNNOTFOUND  "I'm afraid that we \ncannot find line number %d."
  2361. X#define ERR_LOADNOFN    "Could you perhaps specify \nwhich file you wish to be loaded?"
  2362. X#define ERR_NOLN        "It would help greatly \nif there were a line number here."
  2363. X#define ERR_NOFN        "It would help greatly \nif there were a file name here."
  2364. X#define ERR_RETNOGOSUB  "Is it possible \nthat there is a RETURN without a GOSUB here?"
  2365. X#define ERR_INCOMPLETE  "I'm afraid that the statement\nappears to be incomplete."
  2366. X#define ERR_ONNOGOTO    "It appears that there is an ON \nwithout a corresponding GOTO or GOSUB statement."
  2367. X#define ERR_VALOORANGE  "A value given here \nseems to be out of range."
  2368. X#define ERR_SYNTAX      "Could it be \nthat there is a syntax error at this point?"
  2369. X#define ERR_DEVNUM      "The device or file \nnumber here does not seem to be correct."
  2370. X#define ERR_DEV         "There appears \nto have been an error addressing the file or device \nwhich you requested."
  2371. X#define ERR_OPSYS    "A most unfortunate error \nseems to have been generated by the computer's operating system."
  2372. X#define ERR_ARGSTR    "Could you perhaps \nsupply a string argument at this point?"
  2373. X#define ERR_DEFCHAR    "The variable definition \nat this point appears to have an improper argument."
  2374. X#define ERR_MISMATCH    "It would appear \nthat something in this statement is rather seriously mismatched."
  2375. X#define ERR_DIMNOTARRAY    "Could you perhaps \nsupply an array name for the argument at this point?"
  2376. X#define ERR_OD        "Oh dear, we seem to have no more data to read now."
  2377. X#define ERR_OVERFLOW    "Subhuman devices \ndo have their limits, and we're afraid that at this point \nthe limits of Bywater BASIC have been exceeded."
  2378. X#define ERR_NF        "There seems to be \na NEXT statement without a corresponding FOR statement. Could you check on it?"
  2379. X#define ERR_UF        "It would appear \nthat the function named at this point has not been defined."
  2380. X#define ERR_DBZ        "Unfortunately, \ndivision by zero can cause dreadful problems in a computer."
  2381. X#define ERR_REDIM    "We're very sorry \nto say that a variable such as this cannot be redimensioned."
  2382. X#define ERR_OBDIM    "It would be ever so helpful \nif the OPTION BASE statement were to be called prior to the DIM statement."
  2383. X#define ERR_UC        "I'm afraid that \nwe are unable to recognize the command you have given here."
  2384. X#define ERR_NOPROGFILE    "Very sorry, but \nwe simply must have a program file to interpret."
  2385. X#endif
  2386. X
  2387. X#if IMP_ENGLISH
  2388. X#define MES_SIGNON      "Bywater BASIC Interpreter/Shell, version"
  2389. X#define MES_COPYRIGHT   "Watch it: Copyright (c) 1993, Ted A. Campbell"
  2390. X#define MES_LANGUAGE    "Impolite English messages courtesy of Oscar the Grouch"
  2391. X#define PROMPT          "(*sigh) What now? "
  2392. X#define ERROR_HEADER    "YOU SCREWED UP at line"
  2393. X#define ERRD_HEADER     "YOU SCREWED UP"
  2394. X#define MATHERR_HEADER  "ANOTHER SCREWUP!"
  2395. X#define MES_BREAK       "Only a geek like you would interrupt this program at line"
  2396. X#define ERR_OPENFILE    "Ha ha! I can't open file %s. Too bad, sucker."
  2397. X#define ERR_GETMEM      "There isn't near enough memory \nfor this lunacy."
  2398. X#define ERR_LINENO      "You jerk: \nyou entered a non-existent line number."
  2399. X#define ERR_LNNOTFOUND  "You total idiot.  \nLine number %d isn't there. HA!"
  2400. X#define ERR_LOADNOFN    "Get out of here. \nNo way to load that file."
  2401. X#define ERR_NOLN        "Dumb bozo: you need to put \na LINE NUMBER here. Hint: Can you count?"
  2402. X#define ERR_NOFN        "Nerd of the year. \nYou forgot to enter a file name. \nWhy don't you learn BASIC and come back in a year?"
  2403. X#define ERR_RETNOGOSUB  "Oh come on, total amateur. \nYou've got a RETURN without a GOSUB"
  2404. X#define ERR_INCOMPLETE  "Dimwit. Why don't you \ncomplete the statement here for a change."
  2405. X#define ERR_ONNOGOTO    "You failed again: \nON without a GOTO or GOSUB."
  2406. X#define ERR_VALOORANGE  "Go home, beginner. \nThe value here is way out of range."
  2407. X#define ERR_SYNTAX      "Sure sign of a fourth-rate programmer: \nThis makes no sense at all."
  2408. X#define ERR_DEVNUM      "Way to go, space cadet. \nThe device (or file) number here is totally in orbit."
  2409. X#define ERR_DEV         "HO! The file or device \n you requested says: DROP DEAD."
  2410. X#define ERR_OPSYS    "You obviously don't know \nwhat this computer can or can't do."
  2411. X#define ERR_ARGSTR    "Do you have big ears? \n(Like Dumbo?) You obviously need a string argument at this point."
  2412. X#define ERR_DEFCHAR    "Amazing. Surely children \nknow how to form a corrent argument here."
  2413. X#define ERR_MISMATCH    "No way, turkey. \nThe statement here is TOTALLY mismatched."
  2414. X#define ERR_DIMNOTARRAY    "Incredible. Why don't you \nsuppy an ARRAY NAME where the prograqm calls for an ARRAY NAME? (Or just go home.)"
  2415. X#define ERR_OD        "Have you ever studied BASIC before? \nYou've run out of data."
  2416. X#define ERR_OVERFLOW    "Congratulations on writing a program \nthat totally exceeds all limits."
  2417. X#define ERR_NF        "Go back to kindergarten: \nYou have a NEXT statement FOR."
  2418. X#define ERR_UF        "Trash. Total trash. \nDefine your stupid functions before calling them."
  2419. X#define ERR_DBZ        "Obviously, you'll never be a programmer. \nYou've tried division by zero here."
  2420. X#define ERR_REDIM    "You just don't understand: \nyou cannot redimension this variable."
  2421. X#define ERR_OBDIM    "Dork. You called OPTION BASE after DIM. \nLeave me alone."
  2422. X#define ERR_UC        "What do you think this is? \nTry entering a BASIC command here."
  2423. X#define ERR_NOPROGFILE    "Idiot.  No way this will run without a program file."
  2424. X#endif
  2425. X
  2426. X#if STD_RUSSIAN
  2427. X#define MES_SIGNON      "iNTERPRETATOR Bywater BASIC, WERSIQ"
  2428. X#define MES_COPYRIGHT   "Copyright (c) 1993, Ted A. Campbell"
  2429. X#define MES_LANGUAGE    ""
  2430. X#define PROMPT          "gOTOWO"
  2431. X#define ERROR_HEADER    "o{ibka W STROKE"
  2432. X#define MATHERR_HEADER  "o{ibka"
  2433. X#define MES_BREAK       "pROGRAMMA PRERWANA W STROKE"
  2434. X#define ERR_OPENFILE    "nE MOGU OTKRYTX FAJL %s"
  2435. X#define ERR_GETMEM      "mALO PAMQTI"
  2436. X#define ERR_LINENO      "nEWERNYJ NOMER STROKI"
  2437. X#define ERR_LNNOTFOUND  "sTROKA %d NE NAJDENA"
  2438. X#define ERR_LOADNOFN    "LOAD: NE ZADANO IMQ FAJLA"
  2439. X#define ERR_NOLN        "oTSUTSTWUET NOMER STROKI"
  2440. X#define ERR_NOFN        "oTSUTSTWUET IMQ FAJLA"
  2441. X#define ERR_RETNOGOSUB  "RETURN BEZ GOSUB"
  2442. X#define ERR_INCOMPLETE  "nEWER[ENNYJ OPERATOR"
  2443. X#define ERR_ONNOGOTO    "ON BEZ GOTO ILI GOSUB"
  2444. X#define ERR_VALOORANGE  "zNA^ENIE WNE DIAPAZONA"
  2445. X#define ERR_SYNTAX      "sINTAKSI^ESKAQ O[IBKA"
  2446. X#define ERR_DEVNUM      "nEWERNYJ NOMER USTROJSTWA"
  2447. X#define ERR_DEV         "o[IBKA USTROJSTWA"
  2448. X#define ERR_OPSYS       "o[IBKA W KOMANDE OPERACIONNOJ SISTEMY"
  2449. X#define ERR_ARGSTR      "aRGUMENT DOLVEN BYTX STROKOJ"
  2450. X#define ERR_DEFCHAR     "nEWERNYJ ARGUMENT W OPREDELENII PEREMENNOJ"
  2451. X#define ERR_MISMATCH    "nESOOTWETSTWIE TIPOW"
  2452. X#define ERR_DIMNOTARRAY "aRGUMENT NE IMQ MASSIWA"
  2453. X#define ERR_OD          "nET DANNYH"
  2454. X#define ERR_OVERFLOW    "pEREPOLNENIE"
  2455. X#define ERR_NF          "NEXT BEZ FOR"
  2456. X#define ERR_UF          "nEOPREDELENNAQ FUNKCIQ"
  2457. X#define ERR_DBZ         "dELENIE NA NOLX"
  2458. X#define ERR_REDIM       "nELXZQ MENQTX RAZMERNOSTX PEREMENNOJ"
  2459. X#define ERR_OBDIM       "OPTION BASE DOLVNA BYTX WYZWANA DO DIM"
  2460. X#define ERR_UC          "nEWERNAQ KOMANDA"
  2461. X#define ERR_NOPROGFILE    "Program file not specified"
  2462. X#endif
  2463. X
  2464. X/* STD_GERMAN */
  2465. X
  2466. X#if STD_GERMAN
  2467. X#define MES_SIGNON      "Bywater BASIC Interpreter/Shell, version"
  2468. X#define MES_COPYRIGHT   "Copyright (c) 1993, Ted A. Campbell"
  2469. X#define MES_LANGUAGE    "Ausgegeben auf Deutsch von Joerg Rieger"
  2470. X#define PROMPT          "bwBASIC: "
  2471. X#define ERROR_HEADER    "Irrtum in Zeile"
  2472. X#define ERRD_HEADER     "IRRTUM"
  2473. X#define MATHERR_HEADER  "IRRTUM"
  2474. X#define MES_BREAK       "Programm unterbrochen in Zeile"
  2475. X#define ERR_OPENFILE    "Datei %s kann nict geoeffnet werden"
  2476. X#define ERR_GETMEM      "Speicher kann nicht gefunden werden"
  2477. X#define ERR_LINENO      "Zeilennummer kann nicht verbunden werden"
  2478. X#define ERR_LNNOTFOUND  "Zeilennummer %d nicht gefunden"
  2479. X#define ERR_LOADNOFN    "LOAD: Keine Dateiname angegeben"
  2480. X#define ERR_NOLN        "Keine Zeilennummer"
  2481. X#define ERR_NOFN        "Keine Dateiname"
  2482. X#define ERR_RETNOGOSUB  "RETURN ohne GOSUB"
  2483. X#define ERR_INCOMPLETE  "Angabe nicht vollstaendig"
  2484. X#define ERR_ONNOGOTO    "ON ohne GOTO oder GOSUB"
  2485. X#define ERR_VALOORANGE  "Wert is ausserhalb des Grenzbereits"
  2486. X#define ERR_SYNTAX      "Syntax-fehler"
  2487. X#define ERR_DEVNUM      "Ungueltige Geraetnummer"
  2488. X#define ERR_DEV         "Geraet irrtum"
  2489. X#define ERR_OPSYS       "Irrtum in Anwenden des System-Befehls"
  2490. X#define ERR_ARGSTR      "Das Argument muss geradlinig sein"
  2491. X#define ERR_DEFCHAR     "Falsches Argument fuer eine Variable Definition"
  2492. X#define ERR_MISMATCH    "Type verwechselt"
  2493. X#define ERR_DIMNOTARRAY "Das Argument ist kein Feldname"
  2494. X#define ERR_OD          "Keine Daten mehr vorhanden"
  2495. X#define ERR_OVERFLOW    "Ueberflutung"
  2496. X#define ERR_NF          "NEXT ohne FOR"
  2497. X#define ERR_UF          "Funktion nicht definiert"
  2498. X#define ERR_DBZ         "Teile durch Null"
  2499. X#define ERR_REDIM       "Die Variable kann nicht neu dimensioniert werdern"
  2500. X#define ERR_OBDIM       "OPTION BASE muss vor DIM aufgerufen werden"
  2501. X#define ERR_UC          "Befehl unbekannt"
  2502. X#define ERR_NOPROGFILE  "Programm Datei nicht angegeben"
  2503. X#endif
  2504. X
  2505. X/* ESPERANTO */
  2506. X
  2507. X#if ESPERANTO
  2508. X#define MES_SIGNON      "Bywater BASIC Tradukilo/SXelo, vario"
  2509. X#define MES_COPYRIGHT   "Kopirajtita (c) 1993, Ted A. Campbell"
  2510. X#define MES_LANGUAGE    "Esperanta traduko farigxi per Ricxjo Muelisto."
  2511. X#define PROMPT          "bwBASIC: "
  2512. X#define ERROR_HEADER    "ERARO en vico"
  2513. X#define ERRD_HEADER     "ERARO"
  2514. X#define MATHERR_HEADER  "ERARO"
  2515. X#define MES_BREAK       "Programo interrompita cxe vico"
  2516. X#define ERR_OPENFILE    "Malsukcesis malfermi dosieron %s"
  2517. X#define ERR_GETMEM      "Malsukcesis trovi memorajxo"
  2518. X#define ERR_LINENO      "Malsukcesis ligi vicnumero"
  2519. X#define ERR_LNNOTFOUND  "Vicnumero %d ne trovita"
  2520. X#define ERR_LOADNOFN    "LOAD: dosiernomo ne specifita"
  2521. X#define ERR_NOLN        "Ne estas vicnumero"
  2522. X#define ERR_NOFN        "Ne estas dosiernomo"
  2523. X#define ERR_RETNOGOSUB  "RETURN sen GOSUB"
  2524. X#define ERR_INCOMPLETE  "Necompleta deklaro"
  2525. X#define ERR_ONNOGOTO    "ON sen GOTO aux GOSUB"
  2526. X#define ERR_VALOORANGE  "Valorajxo estas eksteretenda"
  2527. X#define ERR_SYNTAX      "Sintakseraro"
  2528. X#define ERR_DEVNUM      "Nevalida aparatnumero"
  2529. X#define ERR_DEV         "Aparateraro"
  2530. X#define ERR_OPSYS       "Eraro en funkcisistema ordono"
  2531. X#define ERR_ARGSTR      "Argumento devas esti serio"
  2532. X#define ERR_DEFCHAR     "Erara argumento por varianto difinajxo"
  2533. X#define ERR_MISMATCH    "Tipa misparo"
  2534. X#define ERR_DIMNOTARRAY "Argumento ne estas kolektonomo"
  2535. X#define ERR_OD          "Ne havas pli da informoj"
  2536. X#define ERR_OVERFLOW    "Ektroajxo"
  2537. X#define ERR_NF          "NEXT sen FOR"
  2538. X#define ERR_UF          "Nedifininta funkcio"
  2539. X#define ERR_DBZ         "Dividu per nulo"
  2540. X#define ERR_REDIM       "Varianto ne eble esti redimensigxinta"
  2541. X#define ERR_OBDIM       "OPTION BASE devas uzigxi antaux ol DIM"
  2542. X#define ERR_UC          "Nekonata ordono"
  2543. X#define ERR_NOPROGFILE  "Programa dosiero ne specifita"
  2544. X#endif
  2545. X
  2546. X/* Standard English is taken as a default: if MES_SIGNON is not defined by
  2547. X   this time (i.e., by some other language definition), then
  2548. X   the following standard English definitions are utilized. */
  2549. X
  2550. X#ifndef MES_SIGNON
  2551. X#define MES_SIGNON      "Bywater BASIC Interpreter/Shell, version"
  2552. X#define MES_COPYRIGHT   "Copyright (c) 1993, Ted A. Campbell"
  2553. X#define MES_LANGUAGE    " "
  2554. X#define PROMPT          "bwBASIC: "
  2555. X#define ERROR_HEADER    "ERROR in line"
  2556. X#define ERRD_HEADER     "ERROR"
  2557. X#define MATHERR_HEADER  "ERROR"
  2558. X#define MES_BREAK       "Program interrupted at line"
  2559. X#define ERR_OPENFILE    "Failed to open file %s"
  2560. X#define ERR_GETMEM      "Failed to find memory"
  2561. X#define ERR_LINENO      "Failed to link line number"
  2562. X#define ERR_LNNOTFOUND  "Line number %d not found"
  2563. X#define ERR_LOADNOFN    "LOAD: no filename specified"
  2564. X#define ERR_NOLN        "No line number"
  2565. X#define ERR_NOFN        "No file name"
  2566. X#define ERR_RETNOGOSUB  "RETURN without GOSUB"
  2567. X#define ERR_INCOMPLETE  "Incomplete statement"
  2568. X#define ERR_ONNOGOTO    "ON without GOTO or GOSUB"
  2569. X#define ERR_VALOORANGE  "Value is out of range"
  2570. X#define ERR_SYNTAX      "Syntax error"
  2571. X#define ERR_DEVNUM      "Invalid device number"
  2572. X#define ERR_DEV         "Device error"
  2573. X#define ERR_OPSYS       "Error in operating system command"
  2574. X#define ERR_ARGSTR      "Argument must be a string"
  2575. X#define ERR_DEFCHAR     "Incorrect argument for variable definition"
  2576. X#define ERR_MISMATCH    "Type mismatch"
  2577. X#define ERR_DIMNOTARRAY "Argument is not an array name"
  2578. X#define ERR_OD          "Out of data"
  2579. X#define ERR_OVERFLOW    "Overflow"
  2580. X#define ERR_NF          "NEXT without FOR"
  2581. X#define ERR_UF          "Undefined function"
  2582. X#define ERR_DBZ         "Divide by zero"
  2583. X#define ERR_REDIM       "Variable cannot be redimensioned"
  2584. X#define ERR_OBDIM       "OPTION BASE must be called prior to DIM"
  2585. X#define ERR_UC          "Unknown command"
  2586. X#define ERR_NOPROGFILE  "Program file not specified"
  2587. X#endif
  2588. X
  2589. X/****************************************************************
  2590. X
  2591. X    BASIC Command Name Definitions
  2592. X
  2593. X    The following definitions of command names are given in
  2594. X    order to allow users to redefine BASIC command names.
  2595. X    No alternatives are supplied.
  2596. X
  2597. X****************************************************************/
  2598. X
  2599. X#ifndef CMD_SYSTEM
  2600. X#define CMD_SYSTEM    "SYSTEM"
  2601. X#define CMD_QUIT    "QUIT"
  2602. X#define CMD_REM        "REM"
  2603. X#define CMD_LET        "LET"
  2604. X#define CMD_PRINT    "PRINT"
  2605. X#define CMD_INPUT    "INPUT"
  2606. X#define CMD_GO          "GO"
  2607. X#define CMD_GOTO        "GOTO"
  2608. X#define CMD_GOSUB    "GOSUB"
  2609. X#define CMD_RETURN    "RETURN"
  2610. X#define CMD_ON        "ON"
  2611. X#define CMD_IF        "IF"
  2612. X#define CMD_WHILE    "WHILE"
  2613. X#define CMD_WEND    "WEND"
  2614. X#define CMD_WRITE    "WRITE"
  2615. X#define CMD_END        "END"
  2616. X#define CMD_FOR        "FOR"
  2617. X#define CMD_NEXT    "NEXT"
  2618. X#define CMD_STOP    "STOP"
  2619. X#define CMD_DATA    "DATA"
  2620. X#define CMD_READ    "READ"
  2621. X#define CMD_RESTORE    "RESTORE"
  2622. X#define CMD_DIM        "DIM"
  2623. X#define CMD_OPTION    "OPTION"
  2624. X#define CMD_OPEN    "OPEN"
  2625. X#define CMD_CLOSE    "CLOSE"
  2626. X#define CMD_GET        "GET"
  2627. X#define CMD_PUT        "PUT"
  2628. X#define CMD_LSET    "LSET"
  2629. X#define CMD_RSET    "RSET"
  2630. X#define CMD_FIELD    "FIELD"
  2631. X#define CMD_LINE    "LINE"
  2632. X#define CMD_DEF        "DEF"
  2633. X#define CMD_VARS    "VARS"
  2634. X#define CMD_CMDS    "CMDS"
  2635. X#define CMD_FNCS    "FNCS"
  2636. X#define CMD_CHDIR    "CHDIR"
  2637. X#define CMD_MKDIR    "MKDIR"
  2638. X#define CMD_RMDIR    "RMDIR"
  2639. X#define CMD_KILL    "KILL"
  2640. X#define CMD_ENVIRON    "ENVIRON"
  2641. X#define CMD_LIST    "LIST"
  2642. X#define CMD_LOAD    "LOAD"
  2643. X#define CMD_RUN        "RUN"
  2644. X#define CMD_SAVE    "SAVE"
  2645. X#define CMD_DELETE    "DELETE"
  2646. X#define CMD_NEW        "NEW"
  2647. X#define CMD_DEFDBL    "DEFDBL"
  2648. X#define CMD_DEFINT    "DEFINT"
  2649. X#define CMD_DEFSNG    "DEFSNG"
  2650. X#define CMD_DEFSTR    "DEFSTR"
  2651. X#define CMD_CALL    "CALL"
  2652. X#define CMD_SUB        "SUB"
  2653. X#define CMD_FUNCTION    "FUNCTION"
  2654. X#define CMD_LABEL    "lAbEl"            /* not really used: set to an unlikely combination */
  2655. X#define CMD_ELSE    "ELSE"
  2656. X#define CMD_ELSEIF    "ELSEIF"
  2657. X#define CMD_SELECT    "SELECT"
  2658. X#define CMD_CASE    "CASE"
  2659. X#define CMD_MERGE    "MERGE"
  2660. X#define CMD_CHAIN    "CHAIN"
  2661. X#define CMD_COMMON    "COMMON"
  2662. X#define CMD_ERROR    "ERROR"
  2663. X#define CMD_WIDTH    "WIDTH"
  2664. X#define CMD_TRON    "TRON"
  2665. X#define CMD_TROFF    "TROFF"
  2666. X#define CMD_RANDOMIZE    "RANDOMIZE"
  2667. X#define CMD_FILES    "FILES"
  2668. X#define CMD_EDIT    "EDIT"
  2669. X#define CMD_ERASE    "ERASE"
  2670. X#define CMD_SWAP    "SWAP"
  2671. X#define CMD_NAME    "NAME"
  2672. X#define CMD_CLEAR    "CLEAR"
  2673. X#define CMD_THEN    "THEN"
  2674. X#define CMD_TO        "TO"
  2675. X#define CMD_STEP    "STEP"
  2676. X#define CMD_DO      "DO"
  2677. X#define CMD_LOCATE  "LOCATE"
  2678. X#define CMD_CLS     "CLS"
  2679. X#define CMD_COLOR   "COLOR"
  2680. X#define CMD_LOOP    "LOOP"
  2681. X#define CMD_EXIT    "EXIT"
  2682. X#define CMD_XUSING      "USING"
  2683. X#define CMD_XFOR        "FOR"
  2684. X#define CMD_XDO        "DO"
  2685. X#define CMD_XUNTIL    "UNTIL"
  2686. X#define CMD_XNUM    "NUM"
  2687. X#define CMD_XUNNUM    "UNNUM"
  2688. X#define CMD_XSUB    "SUB"
  2689. X#define CMD_XTO        "TO"
  2690. X#define CMD_XERROR    "ERROR"
  2691. X#define CMD_XSUB    "SUB"
  2692. X#define CMD_XFUNCTION    "FUNCTION"
  2693. X#define CMD_XIF        "IF"
  2694. X#define CMD_XSELECT    "SELECT"
  2695. X#endif
  2696. X
  2697. X/****************************************************************
  2698. X
  2699. X    External Definitions for Error Messages
  2700. X
  2701. X****************************************************************/
  2702. X
  2703. Xextern char err_openfile[];
  2704. Xextern char err_getmem[];
  2705. Xextern char err_noln[];
  2706. Xextern char err_nofn[];
  2707. Xextern char err_lnnotfound[];
  2708. Xextern char err_incomplete[];
  2709. Xextern char err_valoorange[];
  2710. Xextern char err_syntax[];
  2711. Xextern char err_devnum[];
  2712. Xextern char err_dev[];
  2713. Xextern char err_opsys[];
  2714. Xextern char err_argstr[];
  2715. Xextern char err_defchar[];
  2716. Xextern char err_mismatch[];
  2717. Xextern char err_dimnotarray[];
  2718. Xextern char err_retnogosub[];
  2719. Xextern char err_od[];
  2720. Xextern char err_overflow[];
  2721. Xextern char err_nf[];
  2722. Xextern char err_uf[];
  2723. Xextern char err_dbz[];
  2724. Xextern char err_redim[];
  2725. Xextern char err_obdim[];
  2726. Xextern char err_uc[];
  2727. Xextern char err_noprogfile[];
  2728. X
  2729. X
  2730. X
  2731. END_OF_FILE
  2732.   if test 20585 -ne `wc -c <'bwbasic-2.10/bwb_mes.h'`; then
  2733.     echo shar: \"'bwbasic-2.10/bwb_mes.h'\" unpacked with wrong size!
  2734.   fi
  2735.   # end of 'bwbasic-2.10/bwb_mes.h'
  2736. fi
  2737. echo shar: End of archive 7 \(of 15\).
  2738. cp /dev/null ark7isdone
  2739. MISSING=""
  2740. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ; do
  2741.     if test ! -f ark${I}isdone ; then
  2742.     MISSING="${MISSING} ${I}"
  2743.     fi
  2744. done
  2745. if test "${MISSING}" = "" ; then
  2746.     echo You have unpacked all 15 archives.
  2747.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  2748. else
  2749.     echo You still must unpack the following archives:
  2750.     echo "        " ${MISSING}
  2751. fi
  2752. exit 0
  2753. exit 0 # Just in case...
  2754.