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

  1. Newsgroups: comp.sources.misc
  2. From: tcamp@delphi.com (Ted A. Campbell)
  3. Subject: v40i060:  bwbasic - Bywater BASIC interpreter version 2.10, Part09/15
  4. Message-ID: <1993Oct29.162659.3937@sparky.sterling.com>
  5. X-Md4-Signature: 569590ae8237f5f1bec39a8ca3e4e6eb
  6. Sender: kent@sparky.sterling.com (Kent Landfield)
  7. Organization: Sterling Software
  8. Date: Fri, 29 Oct 1993 16:26:59 GMT
  9. Approved: kent@sparky.sterling.com
  10.  
  11. Submitted-by: tcamp@delphi.com (Ted A. Campbell)
  12. Posting-number: Volume 40, Issue 60
  13. Archive-name: bwbasic/part09
  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/Makefile.in bwbasic-2.10/bwb_fnc.c
  22. #   bwbasic-2.10/bwb_par.c bwbasic-2.10/bwb_str.c
  23. #   bwbasic-2.10/bwbasic.mak bwbasic-2.10/bwbtest/index.txt
  24. #   bwbasic-2.10/bwx_iqc.h bwbasic-2.10/bwx_tty.h
  25. #   bwbasic-2.10/makefile.qcl
  26. # Wrapped by kent@sparky on Thu Oct 21 10:47:50 1993
  27. PATH=/bin:/usr/bin:/usr/ucb:/usr/local/bin:/usr/lbin ; export PATH
  28. echo If this archive is complete, you will see the following message:
  29. echo '          "shar: End of archive 9 (of 15)."'
  30. if test -f 'bwbasic-2.10/Makefile.in' -a "${1}" != "-c" ; then 
  31.   echo shar: Will not clobber existing file \"'bwbasic-2.10/Makefile.in'\"
  32. else
  33.   echo shar: Extracting \"'bwbasic-2.10/Makefile.in'\" \(2521 characters\)
  34.   sed "s/^X//" >'bwbasic-2.10/Makefile.in' <<'END_OF_FILE'
  35. X#               Unix Makefile for Bywater BASIC Interpreter
  36. X
  37. Xsrcdir = @srcdir@
  38. XVPATH = @srcdir@
  39. X
  40. XCC = @CC@
  41. X
  42. XINSTALL = @INSTALL@
  43. XINSTALL_PROGRAM = @INSTALL_PROGRAM@
  44. XINSTALL_DATA = @INSTALL_DATA@
  45. X
  46. XDEFS = @DEFS@
  47. X
  48. XCFLAGS = -O
  49. XLDFLAGS = -s
  50. X
  51. Xprefix = /usr/local
  52. Xexec_prefix = $(prefix)
  53. Xbindir = $(exec_prefix)/bin
  54. X
  55. XSHELL = /bin/sh
  56. X
  57. XCFILES=         bwbasic.c bwb_int.c bwb_tbl.c bwb_cmd.c bwb_prn.c\
  58. X                bwb_exp.c bwb_var.c bwb_inp.c bwb_fnc.c bwb_cnd.c\
  59. X                bwb_ops.c bwb_dio.c bwb_str.c bwb_elx.c bwb_mth.c\
  60. X        bwb_stc.c bwb_par.c bwx_tty.c
  61. X
  62. XOFILES=         bwbasic.o bwb_int.o bwb_tbl.o bwb_cmd.o bwb_prn.o\
  63. X                bwb_exp.o bwb_var.o bwb_inp.o bwb_fnc.o bwb_cnd.o\
  64. X                bwb_ops.o bwb_dio.o bwb_str.o bwb_elx.o bwb_mth.o\
  65. X        bwb_stc.o bwb_par.o bwx_tty.o
  66. XHFILES=         bwbasic.h bwb_mes.h bwx_tty.h
  67. XMISCFILES=    COPYING INSTALL Makefile.in README bwbasic.doc\
  68. X        bwbasic.mak configure.in configure makefile.qcl\
  69. X        bwb_tcc.c bwx_iqc.c bwx_iqc.h
  70. X
  71. XTESTFILES=    \
  72. X    abs.bas          assign.bas    callfunc.bas  callsub.bas    chain1.bas\
  73. X    chain2.bas    dataread.bas  deffn.bas      dim.bas    doloop.bas\
  74. X    dowhile.bas   elseif.bas    end.bas      err.bas    fncallfn.bas\
  75. X    fornext.bas   function.bas  gosub.bas      gotolabl.bas    ifline.bas\
  76. X    index.txt     input.bas        lof.bas      loopuntl.bas    main.bas\
  77. X    mlifthen.bas  on.bas        onerr.bas      onerrlbl.bas    ongosub.bas\
  78. X    opentest.bas  option.bas    putget.bas      random.bas    selcase.bas\
  79. X    snglfunc.bas  stop.bas        term.bas      whilwend.bas    width.bas\
  80. X    writeinp.bas  pascaltr.bas
  81. X
  82. XDISTFILES=    $(CFILES) $(HFILES) $(MISCFILES)
  83. X
  84. Xall: bwbasic
  85. X
  86. Xbwbasic:    $(OFILES)
  87. X        $(CC) $(OFILES) -lm -o $@ $(LDFLAGS)
  88. X
  89. X$(OFILES):      $(HFILES)
  90. X
  91. X.c.o:
  92. X    $(CC) -c $(CPPFLAGS) -I$(srcdir) $(DEFS) $(CFLAGS) $<
  93. X
  94. Xinstall: all
  95. X    $(INSTALL_PROGRAM) bwbasic $(bindir)/bwbasic
  96. X
  97. Xuninstall:
  98. X    rm -f $(bindir)/bwbasic
  99. X
  100. XMakefile: Makefile.in config.status
  101. X    $(SHELL) config.status
  102. Xconfig.status: configure
  103. X    $(SHELL) config.status --recheck
  104. Xconfigure: configure.in
  105. X    cd $(srcdir); autoconf
  106. X
  107. XTAGS:    $(CFILES)
  108. X    etags $(CFILES)
  109. X
  110. Xclean:
  111. X    rm -f *.o bwbasic core
  112. X
  113. Xmostlyclean: clean
  114. X
  115. Xdistclean: clean
  116. X    rm -f Makefile config.status
  117. X
  118. Xrealclean: distclean
  119. X    rm -f TAGS
  120. X
  121. Xdist: $(DISTFILES)
  122. X    echo bwbasic-2.10 > .fname
  123. X    rm -rf `cat .fname`
  124. X    mkdir `cat .fname`
  125. X    ln $(DISTFILES) `cat .fname`
  126. X    mkdir `cat .fname`/bwbtest
  127. X    cd bwbtest; ln $(TESTFILES) ../`cat ../.fname`/bwbtest
  128. X    tar czhf `cat .fname`.tar.gz `cat .fname`
  129. X    rm -rf `cat .fname` .fname
  130. X
  131. X# Prevent GNU make v3 from overflowing arg limit on SysV.
  132. X.NOEXPORT:
  133. END_OF_FILE
  134.   if test 2521 -ne `wc -c <'bwbasic-2.10/Makefile.in'`; then
  135.     echo shar: \"'bwbasic-2.10/Makefile.in'\" unpacked with wrong size!
  136.   fi
  137.   # end of 'bwbasic-2.10/Makefile.in'
  138. fi
  139. if test -f 'bwbasic-2.10/bwb_fnc.c' -a "${1}" != "-c" ; then 
  140.   echo shar: Will not clobber existing file \"'bwbasic-2.10/bwb_fnc.c'\"
  141. else
  142.   echo shar: Extracting \"'bwbasic-2.10/bwb_fnc.c'\" \(43270 characters\)
  143.   sed "s/^X//" >'bwbasic-2.10/bwb_fnc.c' <<'END_OF_FILE'
  144. X/****************************************************************
  145. X
  146. X        bwb_fnc.c       Interpretation Routines
  147. X            for Predefined Functions
  148. X                        for Bywater BASIC Interpreter
  149. X
  150. X                        Copyright (c) 1993, Ted A. Campbell
  151. X                        Bywater Software
  152. X
  153. X                        email: tcamp@delphi.com
  154. X
  155. X        Copyright and Permissions Information:
  156. X
  157. X        All U.S. and international rights are claimed by the author,
  158. X        Ted A. Campbell.
  159. X
  160. X    This software is released under the terms of the GNU General
  161. X    Public License (GPL), which is distributed with this software
  162. X    in the file "COPYING".  The GPL specifies the terms under
  163. X    which users may copy and use the software in this distribution.
  164. X
  165. X    A separate license is available for commercial distribution,
  166. X    for information on which you should contact the author.
  167. X
  168. X****************************************************************/
  169. X
  170. X#define FSTACKSIZE      32
  171. X
  172. X#include <stdio.h>
  173. X#include <ctype.h>
  174. X#include <math.h>
  175. X#include <time.h>
  176. X
  177. X#include "bwbasic.h"
  178. X#include "bwb_mes.h"
  179. X
  180. X#if UNIX_CMDS
  181. X#include <sys/stat.h>
  182. X#endif
  183. X
  184. X#ifndef RAND_MAX            /* added in v1.11 */
  185. X#define RAND_MAX    32767
  186. X#endif
  187. X
  188. Xstatic time_t t;
  189. Xstatic struct tm *lt;
  190. X
  191. X/***************************************************************
  192. X
  193. X        FUNCTION:       fnc_init()
  194. X
  195. X        DESCRIPTION:    This command initializes the function
  196. X                        linked list, placing all predefined functions
  197. X                        in the list.
  198. X
  199. X***************************************************************/
  200. X
  201. X#if ANSI_C
  202. Xint
  203. Xfnc_init( int task )
  204. X#else
  205. Xint
  206. Xfnc_init( task )
  207. X   int task;
  208. X#endif
  209. X   {
  210. X   register int n;
  211. X   struct bwb_function *f;
  212. X
  213. X   strcpy( LOCALTASK fnc_start.name, "FNC_START" );
  214. X   LOCALTASK fnc_start.type = 'X';
  215. X   LOCALTASK fnc_start.vector = fnc_null;
  216. X   strcpy( LOCALTASK fnc_end.name, "FNC_END" );
  217. X   LOCALTASK fnc_end.type = 'x';
  218. X   LOCALTASK fnc_end.vector = fnc_null;
  219. X   LOCALTASK fnc_end.next = &LOCALTASK fnc_end;
  220. X
  221. X   f = &LOCALTASK fnc_start;
  222. X
  223. X   /* now go through each of the preestablished functions and set up
  224. X      links between them; from this point the program address the functions
  225. X      only as a linked list (not as an array) */
  226. X
  227. X   for ( n = 0; n < FUNCTIONS; ++n )
  228. X      {
  229. X      f->next = &( bwb_prefuncs[ n ] );
  230. X      f = f->next;
  231. X      }
  232. X
  233. X   /* link the last pointer to the end; this completes the list */
  234. X
  235. X   f->next = &LOCALTASK fnc_end;
  236. X
  237. X   return TRUE;
  238. X   }
  239. X
  240. X/***************************************************************
  241. X
  242. X        FUNCTION:       fnc_find()
  243. X
  244. X        DESCRIPTION:    This C function attempts to locate
  245. X                        a BASIC function with the specified name.
  246. X                        If successful, it returns a pointer to
  247. X                        the C structure for the BASIC function,
  248. X                        if not successful, it returns NULL.
  249. X
  250. X***************************************************************/
  251. X
  252. X#if ANSI_C
  253. Xstruct bwb_function *
  254. Xfnc_find( char *buffer )
  255. X#else
  256. Xstruct bwb_function *
  257. Xfnc_find( buffer )
  258. X   char *buffer;
  259. X#endif
  260. X   {
  261. X   struct bwb_function * f;
  262. X   register int n;
  263. X   static char *tbuf;
  264. X   static int init = FALSE;
  265. X
  266. X   if ( strlen( buffer ) == 0 )
  267. X      {
  268. X      return NULL;
  269. X      }
  270. X
  271. X   /* get memory for temporary buffer if necessary */
  272. X
  273. X   if ( init == FALSE )
  274. X      {
  275. X      init = TRUE;
  276. X      if ( ( tbuf = calloc( MAXSTRINGSIZE + 1, sizeof( char ) )) == NULL )
  277. X         {
  278. X#if PROG_ERRORS
  279. X     bwb_error( "in fnc_find(): failed to find memory for tbuf" );
  280. X#else
  281. X     bwb_error( err_getmem );
  282. X#endif
  283. X     }
  284. X      }
  285. X
  286. X#if INTENSIVE_DEBUG
  287. X   sprintf( bwb_ebuf, "in fnc_find(): called for <%s> ", buffer );
  288. X   bwb_debug( bwb_ebuf );
  289. X#endif
  290. X
  291. X   strcpy( tbuf, buffer );
  292. X   bwb_strtoupper( tbuf );
  293. X
  294. X   for ( f = CURTASK fnc_start.next; f != &CURTASK fnc_end; f = f->next )
  295. X      {
  296. X      if ( strcmp( f->name, tbuf ) == 0 )
  297. X         {
  298. X#if INTENSIVE_DEBUG
  299. X     sprintf( bwb_ebuf, "in fnc_find(): found <%s> ", f->name );
  300. X     bwb_debug( bwb_ebuf );
  301. X#endif
  302. X         return f;
  303. X         }
  304. X      }
  305. X
  306. X   /* search has failed: return NULL */
  307. X
  308. X   return NULL;
  309. X
  310. X   }
  311. X
  312. X/***************************************************************
  313. X
  314. X        FUNCTION:       fnc_null()
  315. X
  316. X        DESCRIPTION:    This is a null function that can be used
  317. X                        to fill in a required function-structure
  318. X                        pointer when needed.
  319. X
  320. X***************************************************************/
  321. X
  322. X#if ANSI_C
  323. Xstruct bwb_variable *
  324. Xfnc_null( int argc, struct bwb_variable *argv, int unique_id )
  325. X#else
  326. Xstruct bwb_variable *
  327. Xfnc_null( argc, argv, unique_id )
  328. X   int argc;
  329. X   struct bwb_variable *argv;
  330. X   int unique_id;
  331. X#endif
  332. X   {
  333. X   static struct bwb_variable nvar;
  334. X   static int init = FALSE;
  335. X
  336. X   /* initialize the variable if necessary */
  337. X
  338. X   if ( init == FALSE )
  339. X      {
  340. X      init = TRUE;
  341. X      var_make( &nvar, NUMBER );
  342. X      }
  343. X
  344. X   return &nvar;
  345. X   }
  346. X
  347. X/***************************************************************
  348. X
  349. X        FUNCTION:       fnc_tab()
  350. X
  351. X    DESCRIPTION:    This C function implements the BASIC TAB()
  352. X            function, adding tab spaces to a specified
  353. X            column.
  354. X
  355. X            TAB is a core function, i.e., required
  356. X            for ANSI Minimal BASIC.
  357. X
  358. X    SYNTAX:        TAB( number )
  359. X
  360. X***************************************************************/
  361. X
  362. X#if ANSI_C
  363. Xstruct bwb_variable *
  364. Xfnc_tab( int argc, struct bwb_variable *argv, int unique_id )
  365. X#else
  366. Xstruct bwb_variable *
  367. Xfnc_tab( argc, argv, unique_id )
  368. X   int argc;
  369. X   struct bwb_variable *argv;
  370. X   int unique_id;
  371. X#endif
  372. X   {
  373. X   static struct bwb_variable nvar;
  374. X   static int init = FALSE;
  375. X   static char t_string[ 4 ];
  376. X   bstring *b;
  377. X
  378. X   /* initialize nvar if necessary */
  379. X
  380. X   if ( init == FALSE )
  381. X      {
  382. X      init = TRUE;
  383. X      var_make( &nvar, (int) STRING );
  384. X      }
  385. X
  386. X   /* check for correct number of parameters */
  387. X
  388. X   if ( argc < 1 )
  389. X      {
  390. X#if PROG_ERRORS
  391. X      sprintf( bwb_ebuf, "Not enough parameters (%d) to function TAB().",
  392. X         argc );
  393. X      bwb_error( bwb_ebuf );
  394. X#else
  395. X      bwb_error( err_syntax );
  396. X#endif
  397. X      break_handler();
  398. X      return NULL;
  399. X      }
  400. X   else if ( argc > 1 )
  401. X      {
  402. X#if PROG_ERRORS
  403. X      sprintf( bwb_ebuf, "Too many parameters (%d) to function TAB().",
  404. X         argc );
  405. X      bwb_error( bwb_ebuf );
  406. X#else
  407. X      bwb_error( err_syntax );
  408. X#endif
  409. X      break_handler();
  410. X      return NULL;
  411. X      }
  412. X
  413. X   t_string[ 0 ] = PRN_TAB;
  414. X   t_string[ 1 ] = (char) var_getnval( &( argv[ 0 ] ));
  415. X   t_string[ 2 ] = '\0';
  416. X
  417. X   b = var_getsval( &nvar );
  418. X   str_ctob( b, t_string );
  419. X
  420. X   return &nvar;
  421. X   }
  422. X
  423. X#if COMMON_FUNCS
  424. X
  425. X/***************************************************************
  426. X
  427. X
  428. X        FUNCTION:       fnc_date()
  429. X
  430. X        DESCRIPTION:    This C function implements the BASIC
  431. X                        predefined DATE$ function, returning
  432. X                        a string containing the year, month,
  433. X                        and day of the month.
  434. X
  435. X    SYNTAX:        DATE$
  436. X
  437. X***************************************************************/
  438. X
  439. X#if ANSI_C
  440. Xstruct bwb_variable *
  441. Xfnc_date( int argc, struct bwb_variable *argv, int unique_id )
  442. X#else
  443. Xstruct bwb_variable *
  444. Xfnc_date( argc, argv, unique_id )
  445. X   int argc;
  446. X   struct bwb_variable *argv;
  447. X   int unique_id;
  448. X#endif
  449. X   {
  450. X   static struct bwb_variable nvar;
  451. X   static int init = FALSE;
  452. X   static char *tbuf;
  453. X
  454. X   /* initialize the variable if necessary */
  455. X
  456. X   if ( init == FALSE )
  457. X      {
  458. X      init = TRUE;
  459. X      var_make( &nvar, STRING );
  460. X      if ( ( tbuf = calloc( MAXSTRINGSIZE + 1, sizeof( char ) )) == NULL )
  461. X         {
  462. X#if PROG_ERRORS
  463. X         bwb_error( "in fnc_date(): failed to get memory for tbuf" );
  464. X#else
  465. X         bwb_error( err_getmem );
  466. X#endif
  467. X         }
  468. X      }
  469. X
  470. X   time( &t );
  471. X   lt = localtime( &t );
  472. X
  473. X   sprintf( tbuf, "%02d-%02d-%04d", lt->tm_mon + 1, lt->tm_mday,
  474. X      1900 + lt->tm_year );
  475. X   str_ctob( var_findsval( &nvar, nvar.array_pos ), tbuf );
  476. X
  477. X   return &nvar;
  478. X   }
  479. X
  480. X/***************************************************************
  481. X
  482. X        FUNCTION:       fnc_time()
  483. X
  484. X        DESCRIPTION:    This C function implements the BASIC
  485. X                        predefined TIME$ function, returning a
  486. X                        string containing the hour, minute, and
  487. X                        second count.
  488. X
  489. X    SYNTAX:        TIME$
  490. X
  491. X***************************************************************/
  492. X
  493. X#if ANSI_C
  494. Xstruct bwb_variable *
  495. Xfnc_time( int argc, struct bwb_variable *argv, int unique_id )
  496. X#else
  497. Xstruct bwb_variable *
  498. Xfnc_time( argc, argv, unique_id )
  499. X   int argc;
  500. X   struct bwb_variable *argv;
  501. X   int unique_id;
  502. X#endif
  503. X   {
  504. X   static struct bwb_variable nvar;
  505. X   static char *tbuf;
  506. X   static int init = FALSE;
  507. X
  508. X   /* initialize the variable if necessary */
  509. X
  510. X   if ( init == FALSE )
  511. X      {
  512. X      init = TRUE;
  513. X      var_make( &nvar, STRING );
  514. X      if ( ( tbuf = calloc( MAXSTRINGSIZE + 1, sizeof( char ) )) == NULL )
  515. X         {
  516. X#if PROG_ERRORS
  517. X         bwb_error( "in fnc_time(): failed to get memory for tbuf" );
  518. X#else
  519. X         bwb_error( err_getmem );
  520. X#endif
  521. X         }
  522. X      }
  523. X
  524. X   time( &t );
  525. X   lt = localtime( &t );
  526. X
  527. X   sprintf( tbuf, "%02d:%02d:%02d", lt->tm_hour, lt->tm_min,
  528. X      lt->tm_sec );
  529. X   str_ctob( var_findsval( &nvar, nvar.array_pos ), tbuf );
  530. X
  531. X   return &nvar;
  532. X   }
  533. X
  534. X/***************************************************************
  535. X
  536. X        FUNCTION:       fnc_chr()
  537. X
  538. X        DESCRIPTION:    This C function implements the BASIC
  539. X                        predefined CHR$ function, returning a
  540. X                        string containing the single character
  541. X                        whose ASCII value is the argument to
  542. X                        this function.
  543. X
  544. X    SYNTAX:        CHR$( number )
  545. X
  546. X***************************************************************/
  547. X
  548. X#if ANSI_C
  549. Xstruct bwb_variable *
  550. Xfnc_chr( int argc, struct bwb_variable *argv, int unique_id  )
  551. X#else
  552. Xstruct bwb_variable *
  553. Xfnc_chr( argc, argv, unique_id  )
  554. X   int argc;
  555. X   struct bwb_variable *argv;
  556. X   int unique_id;
  557. X#endif
  558. X   {
  559. X   static struct bwb_variable nvar;
  560. X   char tbuf[ MAXSTRINGSIZE + 1 ];
  561. X   static int init = FALSE;
  562. X#if TEST_BSTRING
  563. X   bstring *b;
  564. X#endif
  565. X
  566. X#if INTENSIVE_DEBUG
  567. X   sprintf( bwb_ebuf, "in fnc_chr(): entered function, argc <%d>",
  568. X      argc );
  569. X   bwb_debug( bwb_ebuf );
  570. X#endif
  571. X
  572. X   /* initialize the variable if necessary */
  573. X
  574. X   if ( init == FALSE )
  575. X      {
  576. X      init = TRUE;
  577. X      var_make( &nvar, STRING );
  578. X#if INTENSIVE_DEBUG
  579. X      sprintf( bwb_ebuf, "in fnc_chr(): entered function, initialized nvar" );
  580. X      bwb_debug( bwb_ebuf );
  581. X#endif
  582. X      }
  583. X
  584. X   /* check arguments */
  585. X
  586. X#if PROG_ERRORS
  587. X   if ( argc < 1 )
  588. X      {
  589. X      sprintf( bwb_ebuf, "Not enough arguments to function CHR$()" );
  590. X      bwb_error( bwb_ebuf );
  591. X      return NULL;
  592. X      }
  593. X   else if ( argc > 1 )
  594. X      {
  595. X      sprintf( bwb_ebuf, "Too many parameters (%d) to function CHR$().",
  596. X         argc );
  597. X      bwb_error( bwb_ebuf );
  598. X      return NULL;
  599. X      }
  600. X#else
  601. X   if ( fnc_checkargs( argc, argv, 1, 1 ) == FALSE )
  602. X      {
  603. X      return NULL;
  604. X      }
  605. X#endif
  606. X
  607. X#if INTENSIVE_DEBUG
  608. X   sprintf( bwb_ebuf, "in fnc_chr(): entered function, checkargs ok" );
  609. X   bwb_debug( bwb_ebuf );
  610. X#endif
  611. X
  612. X   tbuf[ 0 ] = (char) var_getnval( &( argv[ 0 ] ) );
  613. X   tbuf[ 1 ] = '\0';
  614. X   str_ctob( var_findsval( &nvar, nvar.array_pos ), tbuf );
  615. X
  616. X#if TEST_BSTRING
  617. X   b = var_findsval( &nvar, nvar.array_pos );
  618. X   sprintf( bwb_ebuf, "in fnc_chr(): bstring name is <%s>", b->name );
  619. X   bwb_debug( bwb_ebuf );
  620. X#endif
  621. X#if INTENSIVE_DEBUG
  622. X   sprintf( bwb_ebuf, "in fnc_chr(): tbuf[ 0 ] is <%c>", tbuf[ 0 ] );
  623. X   bwb_debug( bwb_ebuf );
  624. X#endif
  625. X
  626. X   return &nvar;
  627. X   }
  628. X
  629. X/***************************************************************
  630. X
  631. X        FUNCTION:       fnc_len()
  632. X
  633. X    DESCRIPTION:    This C function implements the BASIC LEN()
  634. X            function, returning the length of a
  635. X            specified string in bytes.
  636. X
  637. X    SYNTAX:        LEN( string$ )
  638. X
  639. X***************************************************************/
  640. X
  641. X#if ANSI_C
  642. Xstruct bwb_variable *
  643. Xfnc_len( int argc, struct bwb_variable *argv, int unique_id )
  644. X#else
  645. Xstruct bwb_variable *
  646. Xfnc_len( argc, argv, unique_id )
  647. X   int argc;
  648. X   struct bwb_variable *argv;
  649. X   int unique_id;
  650. X#endif
  651. X   {
  652. X   static struct bwb_variable nvar;
  653. X   static int init = FALSE;
  654. X   static char *tbuf;
  655. X
  656. X   /* initialize the variable if necessary */
  657. X
  658. X   if ( init == FALSE )
  659. X      {
  660. X      init = TRUE;
  661. X      var_make( &nvar, NUMBER );
  662. X      if ( ( tbuf = calloc( MAXSTRINGSIZE + 1, sizeof( char ) )) == NULL )
  663. X         {
  664. X#if PROG_ERRORS
  665. X         bwb_error( "in fnc_len(): failed to get memory for tbuf" );
  666. X#else
  667. X         bwb_error( err_getmem );
  668. X#endif
  669. X         }
  670. X      }
  671. X
  672. X   /* check parameters */
  673. X
  674. X#if PROG_ERRORS
  675. X   if ( argc < 1 )
  676. X      {
  677. X      sprintf( bwb_ebuf, "Not enough parameters (%d) to function LEN().",
  678. X         argc );
  679. X      bwb_error( bwb_ebuf );
  680. X      return NULL;
  681. X      }
  682. X   else if ( argc > 1 )
  683. X      {
  684. X      sprintf( bwb_ebuf, "Too many parameters (%d) to function LEN().",
  685. X         argc );
  686. X      bwb_error( bwb_ebuf );
  687. X      return NULL;
  688. X      }
  689. X#else
  690. X   if ( fnc_checkargs( argc, argv, 1, 1 ) == FALSE )
  691. X      {
  692. X      return NULL;
  693. X      }
  694. X#endif
  695. X
  696. X   /* return length as an integer */
  697. X
  698. X   str_btoc( tbuf, var_getsval( &( argv[ 0 ] )) );
  699. X   * var_findnval( &nvar, nvar.array_pos )
  700. X      = (bnumber) strlen( tbuf );
  701. X
  702. X   return &nvar;
  703. X   }
  704. X
  705. X/***************************************************************
  706. X
  707. X        FUNCTION:       fnc_pos()
  708. X
  709. X    DESCRIPTION:    This C function implements the BASIC
  710. X            POS() function, returning the current
  711. X            column position for the output device.
  712. X
  713. X    SYNTAX:        POS
  714. X
  715. X***************************************************************/
  716. X
  717. X#if ANSI_C
  718. Xstruct bwb_variable *
  719. Xfnc_pos( int argc, struct bwb_variable *argv, int unique_id )
  720. X#else
  721. Xstruct bwb_variable *
  722. Xfnc_pos( argc, argv, unique_id )
  723. X   int argc;
  724. X   struct bwb_variable *argv;
  725. X   int unique_id;
  726. X#endif
  727. X   {
  728. X   static struct bwb_variable nvar;
  729. X   static int init = FALSE;
  730. X
  731. X   /* initialize nvar if necessary */
  732. X
  733. X   if ( init == FALSE )
  734. X      {
  735. X      init = TRUE;
  736. X      var_make( &nvar, (int) NUMBER );
  737. X      }
  738. X
  739. X   * var_findnval( &nvar, nvar.array_pos ) = (bnumber) prn_col;
  740. X
  741. X   return &nvar;
  742. X   }
  743. X
  744. X#endif                    /* COMMON_FUNCS */
  745. X
  746. X#if MS_FUNCS
  747. X
  748. X/***************************************************************
  749. X
  750. X        FUNCTION:       fnc_timer()
  751. X
  752. X        DESCRIPTION:    This C function implements the BASIC
  753. X                        predefined TIMER function
  754. X
  755. X    SYNTAX:        TIMER
  756. X
  757. X***************************************************************/
  758. X
  759. X#if ANSI_C
  760. Xstruct bwb_variable *
  761. Xfnc_timer( int argc, struct bwb_variable *argv, int unique_id  )
  762. X#else
  763. Xstruct bwb_variable *
  764. Xfnc_timer( argc, argv, unique_id  )
  765. X   int argc;
  766. X   struct bwb_variable *argv;
  767. X   int unique_id;
  768. X#endif
  769. X   {
  770. X   static struct bwb_variable nvar;
  771. X   static time_t now;
  772. X   static int init = FALSE;
  773. X
  774. X   /* initialize the variable if necessary */
  775. X
  776. X   if ( init == FALSE )
  777. X      {
  778. X      init = TRUE;
  779. X      var_make( &nvar, NUMBER );
  780. X      }
  781. X
  782. X   time( &now );
  783. X   * var_findnval( &nvar, nvar.array_pos )
  784. X      = (float) fmod( (bnumber) now, (bnumber) (60*60*24));
  785. X
  786. X   return &nvar;
  787. X   }
  788. X
  789. X/***************************************************************
  790. X
  791. X        FUNCTION:       fnc_mid()
  792. X
  793. X        DESCRIPTION:    This C function implements the BASIC
  794. X                        predefined MID$ function
  795. X
  796. X    SYNTAX:        MID$( string$, start-position-in-string[, number-of-spaces ] )
  797. X
  798. X***************************************************************/
  799. X
  800. X#if ANSI_C
  801. Xstruct bwb_variable *
  802. Xfnc_mid( int argc, struct bwb_variable *argv, int unique_id  )
  803. X#else
  804. Xstruct bwb_variable *
  805. Xfnc_mid( argc, argv, unique_id  )
  806. X   int argc;
  807. X   struct bwb_variable *argv;
  808. X   int unique_id;
  809. X#endif
  810. X   {
  811. X   static struct bwb_variable nvar;
  812. X   register int c;
  813. X   char target_string[ MAXSTRINGSIZE + 1 ];
  814. X   int target_counter, num_spaces;
  815. X   char tbuf[ MAXSTRINGSIZE + 1 ];
  816. X   static int init = FALSE;
  817. X
  818. X   /* initialize the variable if necessary */
  819. X
  820. X   if ( init == FALSE )
  821. X      {
  822. X      init = TRUE;
  823. X      var_make( &nvar, STRING );
  824. X      }
  825. X
  826. X   /* check arguments */
  827. X
  828. X#if PROG_ERRORS
  829. X   if ( argc < 2 )
  830. X      {
  831. X      sprintf( bwb_ebuf, "Not enough arguments to function MID$()" );
  832. X      bwb_error( bwb_ebuf );
  833. X      return &nvar;
  834. X      }
  835. X
  836. X   if ( argc > 3 )
  837. X      {
  838. X      sprintf( bwb_ebuf, "Two many arguments to function MID$()" );
  839. X      bwb_error( bwb_ebuf );
  840. X      return &nvar;
  841. X      }
  842. X
  843. X#else
  844. X   if ( fnc_checkargs( argc, argv, 2, 3 ) == FALSE )
  845. X      {
  846. X      return NULL;
  847. X      }
  848. X#endif
  849. X
  850. X   /* get arguments */
  851. X
  852. X   str_btoc( target_string, var_getsval( &( argv[ 0 ] ) ));
  853. X   target_counter = (int) var_getnval( &( argv[ 1 ] ) ) - 1;
  854. X   if ( target_counter > (int) strlen( target_string ))
  855. X      {
  856. X      tbuf[ 0 ] = '\0';
  857. X      str_ctob( var_findsval( &nvar, nvar.array_pos ), tbuf );
  858. X      return &nvar;
  859. X      }
  860. X
  861. X   if ( argc == 3 )
  862. X      {
  863. X      num_spaces = (int) var_getnval( &( argv[ 2 ] ));
  864. X      }
  865. X   else
  866. X      {
  867. X      num_spaces = MAXSTRINGSIZE;
  868. X      }
  869. X
  870. X#if INTENSIVE_DEBUG
  871. X   sprintf( bwb_ebuf, "in fnc_mid() string <%s> startpos <%d> spaces <%d>",
  872. X      target_string, target_counter, num_spaces );
  873. X   bwb_debug( bwb_ebuf );
  874. X#endif
  875. X
  876. X   c = 0;
  877. X   tbuf[ c ] = '\0';
  878. X   while ( ( c < num_spaces ) && ( target_string[ target_counter ] != '\0' ))
  879. X      {
  880. X      tbuf[ c ] = target_string[ target_counter ];
  881. X      ++c;
  882. X      tbuf[ c ] = '\0';
  883. X      ++target_counter;
  884. X      }
  885. X   str_ctob( var_findsval( &nvar, nvar.array_pos ), tbuf );
  886. X
  887. X   return &nvar;
  888. X   }
  889. X
  890. X/***************************************************************
  891. X
  892. X        FUNCTION:       fnc_left()
  893. X
  894. X        DESCRIPTION:    This C function implements the BASIC
  895. X                        predefined LEFT$ function
  896. X
  897. X    SYNTAX:        LEFT$( string$, number-of-spaces )
  898. X
  899. X***************************************************************/
  900. X
  901. X#if ANSI_C
  902. Xstruct bwb_variable *
  903. Xfnc_left( int argc, struct bwb_variable *argv, int unique_id  )
  904. X#else
  905. Xstruct bwb_variable *
  906. Xfnc_left( argc, argv, unique_id  )
  907. X   int argc;
  908. X   struct bwb_variable *argv;
  909. X   int unique_id;
  910. X#endif
  911. X   {
  912. X   static struct bwb_variable nvar;
  913. X   register int c;
  914. X   char target_string[ MAXSTRINGSIZE + 1 ];
  915. X   int target_counter, num_spaces;
  916. X   char tbuf[ MAXSTRINGSIZE + 1 ];
  917. X   static int init = FALSE;
  918. X
  919. X   /* initialize the variable if necessary */
  920. X
  921. X   if ( init == FALSE )
  922. X      {
  923. X      init = TRUE;
  924. X      var_make( &nvar, STRING );
  925. X      }
  926. X
  927. X   /* check arguments */
  928. X
  929. X#if PROG_ERRORS
  930. X   if ( argc < 2 )
  931. X      {
  932. X      sprintf( bwb_ebuf, "Not enough arguments to function LEFT$()" );
  933. X      bwb_error( bwb_ebuf );
  934. X      return &nvar;
  935. X      }
  936. X
  937. X   if ( argc > 2 )
  938. X      {
  939. X      sprintf( bwb_ebuf, "Two many arguments to function LEFT$()" );
  940. X      bwb_error( bwb_ebuf );
  941. X      return &nvar;
  942. X      }
  943. X
  944. X#else
  945. X   if ( fnc_checkargs( argc, argv, 2, 2 ) == FALSE )
  946. X      {
  947. X      return NULL;
  948. X      }
  949. X#endif
  950. X
  951. X   /* get arguments */
  952. X
  953. X   str_btoc( tbuf, var_getsval( &( argv[ 0 ] ) ));
  954. X   target_counter = 0;
  955. X   num_spaces = (int) var_getnval( &( argv[ 1 ] ));
  956. X
  957. X#if INTENSIVE_DEBUG
  958. X   sprintf( bwb_ebuf, "in fnc_left() string <%s> startpos <%d> spaces <%d>",
  959. X      tbuf, target_counter, num_spaces );
  960. X   bwb_debug( bwb_ebuf );
  961. X#endif
  962. X
  963. X   c = 0;
  964. X   target_string[ 0 ] = '\0';
  965. X   while (( c < num_spaces ) && ( tbuf[ c ] != '\0' ))
  966. X      {
  967. X      target_string[ target_counter ] = tbuf[ c ];
  968. X      ++target_counter;
  969. X      target_string[ target_counter ] = '\0';
  970. X      ++c;
  971. X      }
  972. X   str_ctob( var_findsval( &nvar, nvar.array_pos ), target_string );
  973. X
  974. X   return &nvar;
  975. X   }
  976. X
  977. X/***************************************************************
  978. X
  979. X        FUNCTION:       fnc_right()
  980. X
  981. X        DESCRIPTION:    This C function implements the BASIC
  982. X                        predefined RIGHT$ function
  983. X
  984. X    SYNTAX:        RIGHT$( string$, number-of-spaces )
  985. X
  986. X***************************************************************/
  987. X
  988. X#if ANSI_C
  989. Xstruct bwb_variable *
  990. Xfnc_right( int argc, struct bwb_variable *argv, int unique_id  )
  991. X#else
  992. Xstruct bwb_variable *
  993. Xfnc_right( argc, argv, unique_id  )
  994. X   int argc;
  995. X   struct bwb_variable *argv;
  996. X   int unique_id;
  997. X#endif
  998. X   {
  999. X   static struct bwb_variable nvar;
  1000. X   register int c;
  1001. X   char target_string[ MAXSTRINGSIZE + 1 ];
  1002. X   int target_counter, num_spaces;
  1003. X   char tbuf[ MAXSTRINGSIZE + 1 ];
  1004. X   static int init = FALSE;
  1005. X
  1006. X   /* initialize the variable if necessary */
  1007. X
  1008. X   if ( init == FALSE )
  1009. X      {
  1010. X      init = TRUE;
  1011. X      var_make( &nvar, STRING );
  1012. X      }
  1013. X
  1014. X   /* check arguments */
  1015. X
  1016. X#if PROG_ERRORS
  1017. X   if ( argc < 2 )
  1018. X      {
  1019. X      sprintf( bwb_ebuf, "Not enough arguments to function RIGHT$()" );
  1020. X      bwb_error( bwb_ebuf );
  1021. X      return &nvar;
  1022. X      }
  1023. X
  1024. X   if ( argc > 2 )
  1025. X      {
  1026. X      sprintf( bwb_ebuf, "Two many arguments to function RIGHT$()" );
  1027. X      bwb_error( bwb_ebuf );
  1028. X      return &nvar;
  1029. X      }
  1030. X
  1031. X#else
  1032. X   if ( fnc_checkargs( argc, argv, 2, 2 ) == FALSE )
  1033. X      {
  1034. X      return NULL;
  1035. X      }
  1036. X#endif
  1037. X
  1038. X   /* get arguments */
  1039. X
  1040. X   str_btoc( target_string, var_getsval( &( argv[ 0 ] ) ));
  1041. X   target_counter = strlen( target_string ) - (int) var_getnval( &( argv[ 1 ] ));
  1042. X   num_spaces = MAXSTRINGSIZE;
  1043. X
  1044. X#if INTENSIVE_DEBUG
  1045. X   sprintf( bwb_ebuf, "in fnc_right() string <%s> startpos <%d> spaces <%d>",
  1046. X      target_string, target_counter, num_spaces );
  1047. X   bwb_debug( bwb_ebuf );
  1048. X#endif
  1049. X
  1050. X   c = 0;
  1051. X   tbuf[ c ] = '\0';
  1052. X   while ( ( c < num_spaces ) && ( target_string[ target_counter ] != '\0' ))
  1053. X      {
  1054. X      tbuf[ c ] = target_string[ target_counter ];
  1055. X      ++c;
  1056. X      tbuf[ c ] = '\0';
  1057. X      ++target_counter;
  1058. X      }
  1059. X   str_ctob( var_findsval( &nvar, nvar.array_pos ), tbuf );
  1060. X
  1061. X   return &nvar;
  1062. X   }
  1063. X
  1064. X/***************************************************************
  1065. X
  1066. X        FUNCTION:       fnc_asc()
  1067. X
  1068. X        DESCRIPTION:    This function implements the predefined
  1069. X            BASIC ASC() function, returning the ASCII
  1070. X            number associated with the first character
  1071. X            in the string argument.
  1072. X
  1073. X    SYNTAX:        ASC( string$ )
  1074. X
  1075. X***************************************************************/
  1076. X
  1077. X#if ANSI_C
  1078. Xstruct bwb_variable *
  1079. Xfnc_asc( int argc, struct bwb_variable *argv, int unique_id )
  1080. X#else
  1081. Xstruct bwb_variable *
  1082. Xfnc_asc( argc, argv, unique_id )
  1083. X   int argc;
  1084. X   struct bwb_variable *argv;
  1085. X   int unique_id;
  1086. X#endif
  1087. X   {
  1088. X   static struct bwb_variable nvar;
  1089. X   static char *tbuf;
  1090. X   static int init = FALSE;
  1091. X
  1092. X   /* initialize the variable if necessary */
  1093. X
  1094. X   if ( init == FALSE )
  1095. X      {
  1096. X      init = TRUE;
  1097. X      var_make( &nvar, NUMBER );
  1098. X      if ( ( tbuf = calloc( MAXSTRINGSIZE + 1, sizeof( char ) )) == NULL )
  1099. X         {
  1100. X#if PROG_ERRORS
  1101. X         bwb_error( "in fnc_asc(): failed to get memory for tbuf" );
  1102. X#else
  1103. X         bwb_error( err_getmem );
  1104. X#endif
  1105. X         }
  1106. X      }
  1107. X
  1108. X   /* check parameters */
  1109. X
  1110. X#if PROG_ERRORS
  1111. X   if ( argc < 1 )
  1112. X      {
  1113. X      sprintf( bwb_ebuf, "Not enough parameters (%d) to function ASC().",
  1114. X         argc );
  1115. X      bwb_error( bwb_ebuf );
  1116. X      return NULL;
  1117. X      }
  1118. X   else if ( argc > 1 )
  1119. X      {
  1120. X      sprintf( bwb_ebuf, "Too many parameters (%d) to function ASC().",
  1121. X         argc );
  1122. X      bwb_error( bwb_ebuf );
  1123. X      return NULL;
  1124. X      }
  1125. X#else
  1126. X   if ( fnc_checkargs( argc, argv, 1, 1 ) == FALSE )
  1127. X      {
  1128. X      return NULL;
  1129. X      }
  1130. X#endif
  1131. X
  1132. X   if ( argv[ 0 ].type != STRING )
  1133. X      {
  1134. X#if PROG_ERRORS
  1135. X      sprintf( bwb_ebuf, "Argument to function ASC() must be a string." );
  1136. X      bwb_error( bwb_ebuf );
  1137. X#else
  1138. X      bwb_error( err_mismatch );
  1139. X#endif
  1140. X      return NULL;
  1141. X      }
  1142. X
  1143. X   /* assign ASCII value of first character in the buffer */
  1144. X
  1145. X   str_btoc( tbuf, var_findsval( &( argv[ 0 ] ), argv[ 0 ].array_pos ) );
  1146. X   * var_findnval( &nvar, nvar.array_pos ) = (bnumber) tbuf[ 0 ];
  1147. X
  1148. X#if INTENSIVE_DEBUG
  1149. X   sprintf( bwb_ebuf, "in fnc_asc(): string is <%s>",
  1150. X      tbuf );
  1151. X   bwb_debug( bwb_ebuf );
  1152. X#endif
  1153. X
  1154. X   return &nvar;
  1155. X   }
  1156. X
  1157. X/***************************************************************
  1158. X
  1159. X        FUNCTION:       fnc_string()
  1160. X
  1161. X        DESCRIPTION:    This C function implements the BASIC
  1162. X            STRING$() function.
  1163. X
  1164. X    SYNTAX:        STRING$( number, ascii-value|string$ )
  1165. X
  1166. X***************************************************************/
  1167. X
  1168. X#if ANSI_C
  1169. Xstruct bwb_variable *
  1170. Xfnc_string( int argc, struct bwb_variable *argv, int unique_id )
  1171. X#else
  1172. Xstruct bwb_variable *
  1173. Xfnc_string( argc, argv, unique_id )
  1174. X   int argc;
  1175. X   struct bwb_variable *argv;
  1176. X   int unique_id;
  1177. X#endif
  1178. X   {
  1179. X   static struct bwb_variable nvar;
  1180. X   int length;
  1181. X   register int i;
  1182. X   char c;
  1183. X   static char *tbuf;
  1184. X   static int init = FALSE;
  1185. X
  1186. X   /* initialize the variable if necessary */
  1187. X
  1188. X   if ( init == FALSE )
  1189. X      {
  1190. X      init = TRUE;
  1191. X      var_make( &nvar, STRING );
  1192. X      if ( ( tbuf = calloc( MAXSTRINGSIZE + 1, sizeof( char ) )) == NULL )
  1193. X         {
  1194. X#if PROG_ERRORS
  1195. X         bwb_error( "in fnc_string(): failed to get memory for tbuf" );
  1196. X#else
  1197. X         bwb_error( err_getmem );
  1198. X#endif
  1199. X         }
  1200. X      }
  1201. X
  1202. X   /* check for correct number of parameters */
  1203. X
  1204. X#if PROG_ERRORS
  1205. X   if ( argc < 2 )
  1206. X      {
  1207. X      sprintf( bwb_ebuf, "Not enough parameters (%d) to function STRING$().",
  1208. X         argc );
  1209. X      bwb_error( bwb_ebuf );
  1210. X      return NULL;
  1211. X      }
  1212. X   else if ( argc > 2 )
  1213. X      {
  1214. X      sprintf( bwb_ebuf, "Too many parameters (%d) to function STRING$().",
  1215. X         argc );
  1216. X      bwb_error( bwb_ebuf );
  1217. X      return NULL;
  1218. X      }
  1219. X#else
  1220. X   if ( fnc_checkargs( argc, argv, 2, 2 ) == FALSE )
  1221. X      {
  1222. X      return NULL;
  1223. X      }
  1224. X#endif
  1225. X
  1226. X   strcpy( nvar.name, "(string$)!" );
  1227. X   nvar.type = STRING;
  1228. X   tbuf[ 0 ] = '\0';
  1229. X   length = (int) var_getnval( &( argv[ 0 ] ));
  1230. X
  1231. X   if ( argv[ 1 ].type == STRING )
  1232. X      {
  1233. X      str_btoc( tbuf, var_getsval( &( argv[ 1 ] )));
  1234. X      c = tbuf[ 0 ];
  1235. X      }
  1236. X   else
  1237. X      {
  1238. X      c = (char) var_getnval( &( argv[ 1 ] ) );
  1239. X      }
  1240. X
  1241. X#if INTENSIVE_DEBUG
  1242. X   sprintf( bwb_ebuf, "in fnc_string(): argument <%s> arg type <%c>, length <%d>",
  1243. X      argv[ 1 ].string, argv[ 1 ].type, length );
  1244. X   bwb_debug( bwb_ebuf );
  1245. X   sprintf( bwb_ebuf, "in fnc_string(): type <%c>, c <0x%x>=<%c>",
  1246. X      argv[ 1 ].type, c, c );
  1247. X   bwb_debug( bwb_ebuf );
  1248. X#endif
  1249. X
  1250. X   /* add characters to the string */
  1251. X
  1252. X   for ( i = 0; i < length; ++i )
  1253. X      {
  1254. X      tbuf[ i ] = c;
  1255. X      tbuf[ i + 1 ] = '\0';
  1256. X      }
  1257. X   str_ctob( var_findsval( &nvar, nvar.array_pos ), tbuf );
  1258. X
  1259. X   return &nvar;
  1260. X   }
  1261. X
  1262. X/***************************************************************
  1263. X
  1264. X        FUNCTION:       fnc_instr()
  1265. X
  1266. X        DESCRIPTION:    This C function implements the BASIC 
  1267. X            INSTR() function, returning the position
  1268. X            in string string-searched$ at which
  1269. X            string-pattern$ occurs.
  1270. X
  1271. X    SYNTAX:        INSTR( [start-position,] string-searched$, string-pattern$ )
  1272. X
  1273. X***************************************************************/
  1274. X
  1275. X#if ANSI_C
  1276. Xstruct bwb_variable *
  1277. Xfnc_instr( int argc, struct bwb_variable *argv, int unique_id )
  1278. X#else
  1279. Xstruct bwb_variable *
  1280. Xfnc_instr( argc, argv, unique_id )
  1281. X   int argc;
  1282. X   struct bwb_variable *argv;
  1283. X   int unique_id;
  1284. X#endif
  1285. X   {
  1286. X   static struct bwb_variable nvar;
  1287. X   static int init = FALSE;
  1288. X   int n_pos, x_pos, y_pos;
  1289. X   int start_pos;
  1290. X   register int n;
  1291. X   char xbuf[ MAXSTRINGSIZE + 1 ];
  1292. X   char ybuf[ MAXSTRINGSIZE + 1 ];
  1293. X
  1294. X   /* initialize the variable if necessary */
  1295. X
  1296. X   if ( init == FALSE )
  1297. X      {
  1298. X      init = TRUE;
  1299. X      var_make( &nvar, NUMBER );
  1300. X      }
  1301. X
  1302. X   /* check for correct number of parameters */
  1303. X
  1304. X#if PROG_ERRORS
  1305. X   if ( argc < 2 )
  1306. X      {
  1307. X      sprintf( bwb_ebuf, "Not enough parameters (%d) to function INSTR().",
  1308. X         argc );
  1309. X      bwb_error( bwb_ebuf );
  1310. X      return NULL;
  1311. X      }
  1312. X   else if ( argc > 3 )
  1313. X      {
  1314. X      sprintf( bwb_ebuf, "Too many parameters (%d) to function INSTR().",
  1315. X         argc );
  1316. X      bwb_error( bwb_ebuf );
  1317. X      return NULL;
  1318. X      }
  1319. X#else
  1320. X   if ( fnc_checkargs( argc, argv, 2, 3 ) == FALSE )
  1321. X      {
  1322. X      return NULL;
  1323. X      }
  1324. X#endif
  1325. X
  1326. X   /* determine argument positions */
  1327. X
  1328. X   if ( argc == 3 )
  1329. X      {
  1330. X      n_pos = 0;
  1331. X      x_pos = 1;
  1332. X      y_pos = 2;
  1333. X      }
  1334. X   else
  1335. X      {
  1336. X      n_pos = -1;
  1337. X      x_pos = 0;
  1338. X      y_pos = 1;
  1339. X      }
  1340. X
  1341. X   /* determine starting position */
  1342. X
  1343. X   if ( n_pos == 0 )
  1344. X      {
  1345. X      start_pos = (int) var_getnval( &( argv[ n_pos ] ) ) - 1;
  1346. X      }
  1347. X   else
  1348. X      {
  1349. X      start_pos = 0;
  1350. X      }
  1351. X
  1352. X   /* get x and y strings */
  1353. X
  1354. X   str_btoc( xbuf, var_getsval( &( argv[ x_pos ] ) ) );
  1355. X   str_btoc( ybuf, var_getsval( &( argv[ y_pos ] ) ) );
  1356. X
  1357. X   /* now search for match */
  1358. X
  1359. X   for ( n = start_pos; n < (int) strlen( xbuf ); ++n )
  1360. X      {
  1361. X      if ( strncmp( &( xbuf[ n ] ), ybuf, strlen( ybuf ) ) == 0 )
  1362. X         {
  1363. X         * var_findnval( &nvar, nvar.array_pos ) = (bnumber) n + 1;
  1364. X         return &nvar;
  1365. X         }
  1366. X      }
  1367. X
  1368. X   /* match not found */
  1369. X
  1370. X   * var_findnval( &nvar, nvar.array_pos ) = (bnumber) 0;
  1371. X   return &nvar;
  1372. X
  1373. X   }
  1374. X
  1375. X/***************************************************************
  1376. X
  1377. X        FUNCTION:       fnc_spc()
  1378. X
  1379. X    DESCRIPTION:    This C function implements the BASIC
  1380. X            SPC() function, returning a string
  1381. X            containing a specified number of
  1382. X            (blank) spaces.
  1383. X
  1384. X    SYNTAX:        SPC( number )
  1385. X
  1386. X***************************************************************/
  1387. X
  1388. X#if ANSI_C
  1389. Xstruct bwb_variable *
  1390. Xfnc_spc( int argc, struct bwb_variable *argv, int unique_id )
  1391. X#else
  1392. Xstruct bwb_variable *
  1393. Xfnc_spc( argc, argv, unique_id )
  1394. X   int argc;
  1395. X   struct bwb_variable *argv;
  1396. X   int unique_id;
  1397. X#endif
  1398. X   {
  1399. X   return fnc_space( argc, argv, unique_id );
  1400. X   }
  1401. X
  1402. X/***************************************************************
  1403. X
  1404. X        FUNCTION:       fnc_space()
  1405. X
  1406. X    DESCRIPTION:    This C function implements the BASIC
  1407. X            SPACE() function, returning a string
  1408. X            containing a specified number of
  1409. X            (blank) spaces.
  1410. X
  1411. X    SYNTAX:        SPACE$( number )
  1412. X
  1413. X***************************************************************/
  1414. X
  1415. X#if ANSI_C
  1416. Xstruct bwb_variable *
  1417. Xfnc_space( int argc, struct bwb_variable *argv, int unique_id )
  1418. X#else
  1419. Xstruct bwb_variable *
  1420. Xfnc_space( argc, argv, unique_id )
  1421. X   int argc;
  1422. X   struct bwb_variable *argv;
  1423. X   int unique_id;
  1424. X#endif
  1425. X   {
  1426. X   static struct bwb_variable nvar;
  1427. X   static char *tbuf;
  1428. X   static int init = FALSE;
  1429. X   int spaces;
  1430. X   register int i;
  1431. X   bstring *b;
  1432. X
  1433. X   /* check for correct number of parameters */
  1434. X
  1435. X   if ( argc < 1 )
  1436. X      {
  1437. X#if PROG_ERRORS
  1438. X      sprintf( bwb_ebuf, "Not enough parameters (%d) to function SPACE$().",
  1439. X         argc );
  1440. X      bwb_error( bwb_ebuf );
  1441. X#else
  1442. X      bwb_error( err_syntax );
  1443. X#endif
  1444. X      break_handler();
  1445. X      return NULL;
  1446. X      }
  1447. X   else if ( argc > 1 )
  1448. X      {
  1449. X#if PROG_ERRORS
  1450. X      sprintf( bwb_ebuf, "Too many parameters (%d) to function SPACE$().",
  1451. X         argc );
  1452. X      bwb_error( bwb_ebuf );
  1453. X#else
  1454. X      bwb_error( err_syntax );
  1455. X#endif
  1456. X      break_handler();
  1457. X      return NULL;
  1458. X      }
  1459. X
  1460. X   /* initialize nvar if necessary */
  1461. X
  1462. X   if ( init == FALSE )
  1463. X      {
  1464. X      init = TRUE;
  1465. X      var_make( &nvar, (int) STRING );
  1466. X      if ( ( tbuf = calloc( MAXSTRINGSIZE + 1, sizeof( char ) )) == NULL )
  1467. X         {
  1468. X#if PROG_ERRORS
  1469. X         bwb_error( "in fnc_space(): failed to get memory for tbuf" );
  1470. X#else
  1471. X         bwb_error( err_getmem );
  1472. X#endif
  1473. X         }
  1474. X      }
  1475. X
  1476. X   tbuf[ 0 ] = '\0';
  1477. X   spaces = (int) var_getnval( &( argv[ 0 ] ));
  1478. X
  1479. X   /* add spaces to the string */
  1480. X
  1481. X   for ( i = 0; i < spaces; ++i )
  1482. X      {
  1483. X      tbuf[ i ] = ' ';
  1484. X      tbuf[ i + 1 ] = '\0';
  1485. X      }
  1486. X
  1487. X   b = var_getsval( &nvar );
  1488. X   str_ctob( b, tbuf );
  1489. X
  1490. X   return &nvar;
  1491. X   }
  1492. X
  1493. X/***************************************************************
  1494. X
  1495. X        FUNCTION:       fnc_environ()
  1496. X
  1497. X        DESCRIPTION:    This C function implements the BASIC
  1498. X            ENVIRON$() function, returning the value
  1499. X            of a specified environment string.
  1500. X
  1501. X    SYNTAX:        ENVIRON$( variable-string )
  1502. X
  1503. X***************************************************************/
  1504. X
  1505. X#if ANSI_C
  1506. Xstruct bwb_variable *
  1507. Xfnc_environ( int argc, struct bwb_variable *argv, int unique_id )
  1508. X#else
  1509. Xstruct bwb_variable *
  1510. Xfnc_environ( argc, argv, unique_id )
  1511. X   int argc;
  1512. X   struct bwb_variable *argv;
  1513. X   int unique_id;
  1514. X#endif
  1515. X   {
  1516. X   char tbuf[ MAXSTRINGSIZE + 1 ];
  1517. X   char tmp[ MAXSTRINGSIZE + 1 ];
  1518. X   static struct bwb_variable nvar;
  1519. X   static int init = FALSE;
  1520. X
  1521. X   /* initialize the variable if necessary */
  1522. X
  1523. X   if ( init == FALSE )
  1524. X      {
  1525. X      init = TRUE;
  1526. X      var_make( &nvar, STRING );
  1527. X      }
  1528. X
  1529. X   /* check for correct number of parameters */
  1530. X
  1531. X#if PROG_ERRORS
  1532. X   if ( argc < 1 )
  1533. X      {
  1534. X      sprintf( bwb_ebuf, "Not enough parameters (%d) to function ENVIRON$().",
  1535. X         argc );
  1536. X      bwb_error( bwb_ebuf );
  1537. X      return NULL;
  1538. X      }
  1539. X   else if ( argc > 1 )
  1540. X      {
  1541. X      sprintf( bwb_ebuf, "Too many parameters (%d) to function ENVIRON$().",
  1542. X         argc );
  1543. X      bwb_error( bwb_ebuf );
  1544. X      return NULL;
  1545. X      }
  1546. X#else
  1547. X   if ( fnc_checkargs( argc, argv, 1, 1 ) == FALSE )
  1548. X      {
  1549. X      return NULL;
  1550. X      }
  1551. X#endif
  1552. X
  1553. X   /* resolve the argument and place string value in tbuf */
  1554. X
  1555. X   str_btoc( tbuf, var_getsval( &( argv[ 0 ] )));
  1556. X
  1557. X   /* call getenv() then write value to string */
  1558. X
  1559. X   strcpy( tmp, getenv( tbuf ));
  1560. X   str_ctob( var_findsval( &nvar, nvar.array_pos ), tmp );
  1561. X
  1562. X   /* return address of nvar */
  1563. X
  1564. X   return &nvar;
  1565. X
  1566. X   }
  1567. X
  1568. X/***************************************************************
  1569. X
  1570. X        FUNCTION:       fnc_err()
  1571. X
  1572. X    DESCRIPTION:    This C function implements the BASIC
  1573. X            ERR function, returning the error number
  1574. X            for the most recent error.
  1575. X
  1576. X            Please note that as of revision level
  1577. X            2.10, bwBASIC does not utilize a standard
  1578. X            list of error numbers, so numbers returned
  1579. X            by this function will not be those found
  1580. X            in either ANSI or Microsoft or other
  1581. X            BASIC error tables.
  1582. X
  1583. X    SYNTAX:        ERR
  1584. X
  1585. X***************************************************************/
  1586. X
  1587. X#if ANSI_C
  1588. Xstruct bwb_variable *
  1589. Xfnc_err( int argc, struct bwb_variable *argv, int unique_id )
  1590. X#else
  1591. Xstruct bwb_variable *
  1592. Xfnc_err( argc, argv, unique_id )
  1593. X   int argc;
  1594. X   struct bwb_variable *argv;
  1595. X   int unique_id;
  1596. X#endif
  1597. X   {
  1598. X   static struct bwb_variable nvar;
  1599. X   static int init = FALSE;
  1600. X
  1601. X   /* initialize nvar if necessary */
  1602. X
  1603. X   if ( init == FALSE )
  1604. X      {
  1605. X      init = TRUE;
  1606. X      var_make( &nvar, (int) NUMBER );
  1607. X      }
  1608. X
  1609. X   * var_findnval( &nvar, nvar.array_pos ) = (bnumber) err_number;
  1610. X
  1611. X   return &nvar;
  1612. X   }
  1613. X
  1614. X/***************************************************************
  1615. X
  1616. X        FUNCTION:       fnc_erl()
  1617. X
  1618. X    DESCRIPTION:    This C function implements the BASIC
  1619. X            ERL function, returning the line number
  1620. X            for the most recent error.
  1621. X
  1622. X    SYNTAX:        ERL
  1623. X
  1624. X***************************************************************/
  1625. X
  1626. X#if ANSI_C
  1627. Xstruct bwb_variable *
  1628. Xfnc_erl( int argc, struct bwb_variable *argv, int unique_id )
  1629. X#else
  1630. Xstruct bwb_variable *
  1631. Xfnc_erl( argc, argv, unique_id )
  1632. X   int argc;
  1633. X   struct bwb_variable *argv;
  1634. X   int unique_id;
  1635. X#endif
  1636. X   {
  1637. X   static struct bwb_variable nvar;
  1638. X   static int init = FALSE;
  1639. X
  1640. X   /* initialize nvar if necessary */
  1641. X
  1642. X   if ( init == FALSE )
  1643. X      {
  1644. X      init = TRUE;
  1645. X      var_make( &nvar, (int) NUMBER );
  1646. X      }
  1647. X
  1648. X   * var_findnval( &nvar, nvar.array_pos ) = (bnumber) err_line;
  1649. X
  1650. X   return &nvar;
  1651. X   }
  1652. X
  1653. X/***************************************************************
  1654. X
  1655. X        FUNCTION:       fnc_loc()
  1656. X
  1657. X        DESCRIPTION:    This C function implements the BASIC
  1658. X            LOC() function. As implemented here,
  1659. X            this only workd for random-acess files.
  1660. X
  1661. X    SYNTAX:        LOC( device-number )
  1662. X
  1663. X***************************************************************/
  1664. X
  1665. X#if ANSI_C
  1666. Xstruct bwb_variable *
  1667. Xfnc_loc( int argc, struct bwb_variable *argv, int unique_id )
  1668. X#else
  1669. Xstruct bwb_variable *
  1670. Xfnc_loc( argc, argv, unique_id )
  1671. X   int argc;
  1672. X   struct bwb_variable *argv;
  1673. X   int unique_id;
  1674. X#endif
  1675. X   {
  1676. X   static struct bwb_variable nvar;
  1677. X   static int init = FALSE;
  1678. X   int dev_number;
  1679. X
  1680. X#if INTENSIVE_DEBUG
  1681. X   sprintf( bwb_ebuf, "in fnc_loc(): received f_arg <%f> ",
  1682. X      var_getnval( &( argv[ 0 ] ) ) );
  1683. X   bwb_debug( bwb_ebuf );
  1684. X#endif
  1685. X
  1686. X   if ( argc < 1 )
  1687. X      {
  1688. X#if PROG_ERRORS
  1689. X      sprintf( bwb_ebuf, "Not enough parameters (%d) to function LOC().",
  1690. X         argc );
  1691. X      bwb_error( bwb_ebuf );
  1692. X#else
  1693. X      bwb_error( err_syntax );
  1694. X#endif
  1695. X      return NULL;
  1696. X      }
  1697. X   else if ( argc > 1 )
  1698. X      {
  1699. X#if PROG_ERRORS
  1700. X      sprintf( bwb_ebuf, "Too many parameters (%d) to function LOC().",
  1701. X         argc );
  1702. X      bwb_error( bwb_ebuf );
  1703. X#else
  1704. X      bwb_error( err_syntax );
  1705. X#endif
  1706. X      return NULL;
  1707. X      }
  1708. X
  1709. X   dev_number = (int) var_getnval( &( argv[ 0 ] ) );
  1710. X
  1711. X   if ( init == FALSE )
  1712. X      {
  1713. X      init = TRUE;
  1714. X      var_make( &nvar, NUMBER );
  1715. X      }
  1716. X
  1717. X   /* note if this is the very beginning of the file */
  1718. X
  1719. X   if ( dev_table[ dev_number ].loc == 0 )
  1720. X      {
  1721. X      * var_findnval( &nvar, nvar.array_pos ) = (bnumber) 0;
  1722. X      }
  1723. X   else
  1724. X      {
  1725. X      * var_findnval( &nvar, nvar.array_pos ) =
  1726. X         (bnumber) dev_table[ dev_number ].next_record;
  1727. X      }
  1728. X
  1729. X   return &nvar;
  1730. X   }
  1731. X
  1732. X/***************************************************************
  1733. X
  1734. X        FUNCTION:       fnc_eof()
  1735. X
  1736. X        DESCRIPTION:    This C function implements the BASIC
  1737. X            EOF() function.
  1738. X
  1739. X    SYNTAX:        EOF( device-number )
  1740. X
  1741. X***************************************************************/
  1742. X
  1743. X#if ANSI_C
  1744. Xstruct bwb_variable *
  1745. Xfnc_eof( int argc, struct bwb_variable *argv, int unique_id )
  1746. X#else
  1747. Xstruct bwb_variable *
  1748. Xfnc_eof( argc, argv, unique_id )
  1749. X   int argc;
  1750. X   struct bwb_variable *argv;
  1751. X   int unique_id;
  1752. X#endif
  1753. X   {
  1754. X   static struct bwb_variable nvar;
  1755. X   static int init = FALSE;
  1756. X   int dev_number;
  1757. X
  1758. X#if INTENSIVE_DEBUG
  1759. X   sprintf( bwb_ebuf, "in fnc_loc(): received f_arg <%f> ",
  1760. X      var_getnval( &( argv[ 0 ] ) ) );
  1761. X   bwb_debug( bwb_ebuf );
  1762. X#endif
  1763. X
  1764. X   if ( argc < 1 )
  1765. X      {
  1766. X#if PROG_ERRORS
  1767. X      sprintf( bwb_ebuf, "Not enough parameters (%d) to function EOF().",
  1768. X         argc );
  1769. X      bwb_error( bwb_ebuf );
  1770. X#else
  1771. X      bwb_error( err_syntax );
  1772. X#endif
  1773. X      return NULL;
  1774. X      }
  1775. X   else if ( argc > 1 )
  1776. X      {
  1777. X#if PROG_ERRORS
  1778. X      sprintf( bwb_ebuf, "Too many parameters (%d) to function EOF().",
  1779. X         argc );
  1780. X      bwb_error( bwb_ebuf );
  1781. X#else
  1782. X      bwb_error( err_syntax );
  1783. X#endif
  1784. X      return NULL;
  1785. X      }
  1786. X
  1787. X   dev_number = (int) var_getnval( &( argv[ 0 ] ) );
  1788. X
  1789. X   if ( init == FALSE )
  1790. X      {
  1791. X      init = TRUE;
  1792. X      var_make( &nvar, NUMBER );
  1793. X      }
  1794. X
  1795. X   /* note if this is the very beginning of the file */
  1796. X
  1797. X   if ( dev_table[ dev_number ].mode == DEVMODE_AVAILABLE )
  1798. X      {
  1799. X      bwb_error( err_devnum );
  1800. X      * var_findnval( &nvar, nvar.array_pos ) = (bnumber) TRUE;
  1801. X      }
  1802. X   else if ( dev_table[ dev_number ].mode == DEVMODE_CLOSED )
  1803. X      {
  1804. X      bwb_error( err_devnum );
  1805. X      * var_findnval( &nvar, nvar.array_pos ) = (bnumber) TRUE;
  1806. X      }
  1807. X   else if ( feof( dev_table[ dev_number ].cfp ) == 0 )
  1808. X      {
  1809. X      * var_findnval( &nvar, nvar.array_pos ) = (bnumber) FALSE;
  1810. X      }
  1811. X   else
  1812. X      {
  1813. X      * var_findnval( &nvar, nvar.array_pos ) = (bnumber) TRUE;
  1814. X      }
  1815. X
  1816. X   return &nvar;
  1817. X   }
  1818. X
  1819. X/***************************************************************
  1820. X
  1821. X        FUNCTION:       fnc_lof()
  1822. X
  1823. X        DESCRIPTION:    This C function implements the BASIC
  1824. X            LOF() function.
  1825. X
  1826. X    SYNTAX:        LOF( device-number )
  1827. X
  1828. X***************************************************************/
  1829. X
  1830. X#if ANSI_C
  1831. Xstruct bwb_variable *
  1832. Xfnc_lof( int argc, struct bwb_variable *argv, int unique_id )
  1833. X#else
  1834. Xstruct bwb_variable *
  1835. Xfnc_lof( argc, argv, unique_id )
  1836. X   int argc;
  1837. X   struct bwb_variable *argv;
  1838. X   int unique_id;
  1839. X#endif
  1840. X   {
  1841. X   static struct bwb_variable nvar;
  1842. X   static int init = FALSE;
  1843. X   int dev_number;
  1844. X#if UNIX_CMDS
  1845. X   static struct stat statbuf;
  1846. X   int r;
  1847. X#endif
  1848. X
  1849. X#if INTENSIVE_DEBUG
  1850. X   sprintf( bwb_ebuf, "in fnc_lof(): received f_arg <%f> ",
  1851. X      var_getnval( &( argv[ 0 ] ) ) );
  1852. X   bwb_debug( bwb_ebuf );
  1853. X#endif
  1854. X
  1855. X   if ( argc < 1 )
  1856. X      {
  1857. X#if PROG_ERRORS
  1858. X      sprintf( bwb_ebuf, "Not enough parameters (%d) to function LOF().",
  1859. X         argc );
  1860. X      bwb_error( bwb_ebuf );
  1861. X#else
  1862. X      bwb_error( err_syntax );
  1863. X#endif
  1864. X      return NULL;
  1865. X      }
  1866. X   else if ( argc > 1 )
  1867. X      {
  1868. X#if PROG_ERRORS
  1869. X      sprintf( bwb_ebuf, "Too many parameters (%d) to function LOF().",
  1870. X         argc );
  1871. X      bwb_error( bwb_ebuf );
  1872. X#else
  1873. X      bwb_error( err_syntax );
  1874. X#endif
  1875. X      return NULL;
  1876. X      }
  1877. X
  1878. X   dev_number = (int) var_getnval( &( argv[ 0 ] ) );
  1879. X
  1880. X   if ( init == FALSE )
  1881. X      {
  1882. X      init = TRUE;
  1883. X      var_make( &nvar, NUMBER );
  1884. X      }
  1885. X
  1886. X   /* stat the file */
  1887. X
  1888. X#if UNIX_CMDS
  1889. X
  1890. X   r = stat( dev_table[ dev_number ].filename, &statbuf );
  1891. X
  1892. X   if ( r != 0 )
  1893. X      {
  1894. X#if PROG_ERRORS
  1895. X      sprintf( bwb_ebuf, "in fnc_lof(): failed to find file <%s>",
  1896. X         dev_table[ dev_number ].filename );
  1897. X      bwb_error( bwb_ebuf );
  1898. X#else
  1899. X      sprintf( bwb_ebuf, ERR_OPENFILE,
  1900. X         dev_table[ dev_number ].filename );
  1901. X      bwb_error( bwb_ebuf );
  1902. X#endif
  1903. X      return NULL;
  1904. X      }
  1905. X
  1906. X   * var_findnval( &nvar, nvar.array_pos ) = (bnumber) statbuf.st_size;
  1907. X
  1908. X#else
  1909. X
  1910. X   * var_findnval( &nvar, nvar.array_pos ) = (bnumber) FALSE;
  1911. X
  1912. X#endif
  1913. X
  1914. X   return &nvar;
  1915. X   }
  1916. X
  1917. X#endif                    /* MS_FUNCS */
  1918. X
  1919. X/***************************************************************
  1920. X
  1921. X        FUNCTION:       fnc_test()
  1922. X
  1923. X        DESCRIPTION:    This is a test function, developed in
  1924. X                        order to test argument passing to
  1925. X                        BASIC functions.
  1926. X
  1927. X***************************************************************/
  1928. X
  1929. X#if INTENSIVE_DEBUG
  1930. X#if ANSI_C
  1931. Xstruct bwb_variable *
  1932. Xfnc_test( int argc, struct bwb_variable *argv, int unique_id )
  1933. X#else
  1934. Xstruct bwb_variable *
  1935. Xfnc_test( argc, argv, unique_id )
  1936. X   int argc;
  1937. X   struct bwb_variable *argv;
  1938. X   int unique_id;
  1939. X#endif
  1940. X   {
  1941. X   register int c;
  1942. X   static struct bwb_variable rvar;
  1943. X   static char *tbuf;
  1944. X   static int init = FALSE;
  1945. X
  1946. X   /* initialize the variable if necessary */
  1947. X
  1948. X   if ( init == FALSE )
  1949. X      {
  1950. X      init = TRUE;
  1951. X      var_make( &rvar, NUMBER );
  1952. X      if ( ( tbuf = calloc( MAXSTRINGSIZE + 1, sizeof( char ) )) == NULL )
  1953. X         {
  1954. X#if PROG_ERRORS
  1955. X         bwb_error( "in fnc_test(): failed to get memory for tbuf" );
  1956. X#else
  1957. X         bwb_error( err_getmem );
  1958. X#endif
  1959. X         }
  1960. X      }
  1961. X
  1962. X   sprintf( bwb_ebuf, "TEST function: received %d arguments: \n", argc );
  1963. X   prn_xprintf( stderr, bwb_ebuf );
  1964. X
  1965. X   for ( c = 0; c < argc; ++c )
  1966. X      {
  1967. X      str_btoc( tbuf, var_getsval( &argv[ c ] ) );
  1968. X      sprintf( bwb_ebuf, "                  arg %d (%c): <%s> \n", c,
  1969. X     argv[ c ].type, tbuf );
  1970. X      prn_xprintf( stderr, bwb_ebuf );
  1971. X      }
  1972. X
  1973. X   return &rvar;
  1974. X
  1975. X   }
  1976. X#endif
  1977. X
  1978. X/***************************************************************
  1979. X
  1980. X        FUNCTION:       fnc_checkargs()
  1981. X
  1982. X        DESCRIPTION:    This C function checks the arguments to
  1983. X            functions.
  1984. X
  1985. X***************************************************************/
  1986. X
  1987. X#if PROG_ERRORS
  1988. X#else
  1989. X#if ANSI_C
  1990. Xint
  1991. Xfnc_checkargs( int argc, struct bwb_variable *argv, int min, int max )
  1992. X#else
  1993. Xint
  1994. Xfnc_checkargs( argc, argv, min, max )
  1995. X   int argc;
  1996. X   struct bwb_variable *argv;
  1997. X   int min;
  1998. X   int max;
  1999. X#endif
  2000. X   {
  2001. X
  2002. X   if ( argc < min )
  2003. X      {
  2004. X      bwb_error( err_syntax );
  2005. X      return FALSE;
  2006. X      }
  2007. X   if ( argc > max )
  2008. X      {
  2009. X      bwb_error( err_syntax );
  2010. X      return FALSE;
  2011. X      }
  2012. X
  2013. X   return TRUE;
  2014. X
  2015. X   }
  2016. X#endif
  2017. X
  2018. X/***************************************************************
  2019. X
  2020. X        FUNCTION:       fnc_fncs()
  2021. X
  2022. X        DESCRIPTION:    This C function is used for debugging
  2023. X                        purposes; it prints a list of all defined
  2024. X                        functions.
  2025. X
  2026. X    SYNTAX:        FNCS
  2027. X
  2028. X***************************************************************/
  2029. X
  2030. X#if PERMANENT_DEBUG
  2031. X
  2032. X#if ANSI_C
  2033. Xstruct bwb_line *
  2034. Xbwb_fncs( struct bwb_line *l )
  2035. X#else
  2036. Xstruct bwb_line *
  2037. Xbwb_fncs( l )
  2038. X   struct bwb_line *l;
  2039. X#endif
  2040. X   {
  2041. X   struct bwb_function *f;
  2042. X
  2043. X   for ( f = CURTASK fnc_start.next; f != &CURTASK fnc_end; f = f->next )
  2044. X      {
  2045. X      sprintf( bwb_ebuf, "%s\t%c \n", f->name, f->type );
  2046. X      prn_xprintf( stderr, bwb_ebuf );
  2047. X      }
  2048. X
  2049. X   return bwb_zline( l );
  2050. X
  2051. X   }
  2052. X#endif
  2053. X
  2054. END_OF_FILE
  2055.   if test 43270 -ne `wc -c <'bwbasic-2.10/bwb_fnc.c'`; then
  2056.     echo shar: \"'bwbasic-2.10/bwb_fnc.c'\" unpacked with wrong size!
  2057.   fi
  2058.   # end of 'bwbasic-2.10/bwb_fnc.c'
  2059. fi
  2060. if test -f 'bwbasic-2.10/bwb_par.c' -a "${1}" != "-c" ; then 
  2061.   echo shar: Will not clobber existing file \"'bwbasic-2.10/bwb_par.c'\"
  2062. else
  2063.   echo shar: Extracting \"'bwbasic-2.10/bwb_par.c'\" \(3220 characters\)
  2064.   sed "s/^X//" >'bwbasic-2.10/bwb_par.c' <<'END_OF_FILE'
  2065. X/***************************************************************
  2066. X
  2067. X        bwb_par.c       Parallel Action (Multitasking) Routines
  2068. X                        for Bywater BASIC Interpreter
  2069. X
  2070. X            Currently UNDER CONSTRUCTION
  2071. X
  2072. X                        Copyright (c) 1993, Ted A. Campbell
  2073. X                        Bywater Software
  2074. X
  2075. X                        email: tcamp@delphi.com
  2076. X
  2077. X        Copyright and Permissions Information:
  2078. X
  2079. X        All U.S. and international rights are claimed by the author,
  2080. X        Ted A. Campbell.
  2081. X
  2082. X    This software is released under the terms of the GNU General
  2083. X    Public License (GPL), which is distributed with this software
  2084. X    in the file "COPYING".  The GPL specifies the terms under
  2085. X    which users may copy and use the software in this distribution.
  2086. X
  2087. X    A separate license is available for commercial distribution,
  2088. X    for information on which you should contact the author.
  2089. X
  2090. X***************************************************************/
  2091. X
  2092. X#include <stdio.h>
  2093. X
  2094. X#include "bwbasic.h"
  2095. X#include "bwb_mes.h"
  2096. X
  2097. X#if PARACT            /* this whole file ignored if FALSE */
  2098. X
  2099. X/***************************************************************
  2100. X
  2101. X        FUNCTION:       bwb_newtask()
  2102. X
  2103. X        DESCRIPTION:    This C function allocates and initializes
  2104. X                memory for a new task.
  2105. X
  2106. X***************************************************************/
  2107. X
  2108. X#if ANSI_C
  2109. Xint
  2110. Xbwb_newtask( int task_requested )
  2111. X#else
  2112. Xint
  2113. Xbwb_newtask( task_requested )
  2114. X   int task_requested;
  2115. X#endif
  2116. X   {
  2117. X   static char start_buf[] = "\0";
  2118. X   static char end_buf[] = "\0";
  2119. X   register int c;
  2120. X
  2121. X   /* find if requested task slot is available */ 
  2122. X
  2123. X   if ( bwb_tasks[ task_requested ] != NULL )
  2124. X      {
  2125. X#if PROG_ERRORS
  2126. X      sprintf( bwb_ebuf, "in bwb_newtask(): Slot requested is already in use" );
  2127. X      bwb_error( bwb_ebuf );
  2128. X#else
  2129. X      bwb_error( err_overflow );
  2130. X      return -1;
  2131. X#endif
  2132. X      }
  2133. X
  2134. X   /* get memory for task structure */
  2135. X
  2136. X   if ( ( bwb_tasks[ task_requested ] = calloc( 1, sizeof( struct bwb_task ) ) )
  2137. X      == NULL )
  2138. X      {
  2139. X#if PROG_ERRORS
  2140. X      bwb_error( "in bwb_newtask(): failed to find memory for task structure" );
  2141. X#else
  2142. X      bwb_error( err_getmem );
  2143. X#endif
  2144. X      }
  2145. X
  2146. X   /* set some initial variables */
  2147. X
  2148. X   bwb_tasks[ task_requested ]->bwb_start.number = 0;
  2149. X   bwb_tasks[ task_requested ]->bwb_start.next = &bwb_tasks[ task_requested ]->bwb_end;
  2150. X   bwb_tasks[ task_requested ]->bwb_end.number = MAXLINENO + 1;
  2151. X   bwb_tasks[ task_requested ]->bwb_end.next = &bwb_tasks[ task_requested ]->bwb_end;
  2152. X   bwb_tasks[ task_requested ]->bwb_start.buffer = start_buf;
  2153. X   bwb_tasks[ task_requested ]->bwb_end.buffer = end_buf;
  2154. X   bwb_tasks[ task_requested ]->data_line = &bwb_tasks[ task_requested ]->bwb_start;
  2155. X   bwb_tasks[ task_requested ]->data_pos = 0;
  2156. X   bwb_tasks[ task_requested ]->rescan = TRUE;
  2157. X   bwb_tasks[ task_requested ]->exsc = -1;
  2158. X   bwb_tasks[ task_requested ]->expsc = 0;
  2159. X   bwb_tasks[ task_requested ]->xtxtsc = 0;
  2160. X
  2161. X   /* Variable and function table initializations */
  2162. X
  2163. X   var_init( task_requested );             /* initialize variable chain */
  2164. X   fnc_init( task_requested );             /* initialize function chain */
  2165. X   fslt_init( task_requested );        /* initialize funtion-sub  chain */
  2166. X
  2167. X   return task_requested;
  2168. X
  2169. X   }
  2170. X
  2171. X#endif
  2172. X
  2173. X
  2174. END_OF_FILE
  2175.   if test 3220 -ne `wc -c <'bwbasic-2.10/bwb_par.c'`; then
  2176.     echo shar: \"'bwbasic-2.10/bwb_par.c'\" unpacked with wrong size!
  2177.   fi
  2178.   # end of 'bwbasic-2.10/bwb_par.c'
  2179. fi
  2180. if test -f 'bwbasic-2.10/bwb_str.c' -a "${1}" != "-c" ; then 
  2181.   echo shar: Will not clobber existing file \"'bwbasic-2.10/bwb_str.c'\"
  2182. else
  2183.   echo shar: Extracting \"'bwbasic-2.10/bwb_str.c'\" \(7352 characters\)
  2184.   sed "s/^X//" >'bwbasic-2.10/bwb_str.c' <<'END_OF_FILE'
  2185. X/***************************************************************
  2186. X
  2187. X    bwb_str.c       String-Management Routines
  2188. X                        for Bywater BASIC Interpreter
  2189. X
  2190. X                        Copyright (c) 1993, Ted A. Campbell
  2191. X                        Bywater Software
  2192. X
  2193. X                        email: tcamp@delphi.com
  2194. X
  2195. X        Copyright and Permissions Information:
  2196. X
  2197. X        All U.S. and international rights are claimed by the author,
  2198. X        Ted A. Campbell.
  2199. X
  2200. X    This software is released under the terms of the GNU General
  2201. X    Public License (GPL), which is distributed with this software
  2202. X    in the file "COPYING".  The GPL specifies the terms under
  2203. X    which users may copy and use the software in this distribution.
  2204. X
  2205. X    A separate license is available for commercial distribution,
  2206. X    for information on which you should contact the author.
  2207. X
  2208. X***************************************************************/
  2209. X
  2210. X#include <stdio.h>
  2211. X
  2212. X#include "bwbasic.h"
  2213. X#include "bwb_mes.h"
  2214. X
  2215. X#if INTENSIVE_DEBUG || TEST_BSTRING
  2216. Xstatic char tbuf[ MAXSTRINGSIZE + 1 ];
  2217. X#endif
  2218. X
  2219. X/***************************************************************
  2220. X
  2221. X        FUNCTION:       str_btob()
  2222. X
  2223. X        DESCRIPTION:    This C function assigns a bwBASIC string
  2224. X            structure to another bwBASIC string
  2225. X            structure.
  2226. X
  2227. X***************************************************************/
  2228. X
  2229. X#if ANSI_C
  2230. Xint
  2231. Xstr_btob( bstring *d, bstring *s )
  2232. X#else
  2233. Xint
  2234. Xstr_btob( d, s )
  2235. X   bstring *d;
  2236. X   bstring *s;
  2237. X#endif
  2238. X   {
  2239. X   char *t;
  2240. X   register int i;
  2241. X
  2242. X#if TEST_BSTRING
  2243. X   sprintf( tbuf, "in str_btob(): entry, source b string name is <%s>", s->name );
  2244. X   bwb_debug( tbuf );
  2245. X   sprintf( tbuf, "in str_btob(): entry, destination b string name is <%s>", d->name );
  2246. X   bwb_debug( tbuf );
  2247. X#endif
  2248. X
  2249. X   /* get memory for new buffer */
  2250. X
  2251. X   if ( ( t = (char *) calloc( s->length + 1, 1 )) == NULL )
  2252. X      {
  2253. X#if PROG_ERRORS
  2254. X      bwb_error( "in str_btob(): failed to get memory for new buffer" );
  2255. X#else
  2256. X      bwb_error( err_getmem );
  2257. X#endif
  2258. X      return FALSE;
  2259. X      }
  2260. X
  2261. X   /* write the c string to the b string */
  2262. X
  2263. X   t[ 0 ] = '\0';
  2264. X   for ( i = 0; i < (int) s->length; ++i )
  2265. X      {
  2266. X      t[ i ] = s->sbuffer[ i ];
  2267. X#if INTENSIVE_DEBUG
  2268. X      tbuf[ i ] = s->sbuffer[ i ];
  2269. X      tbuf[ i + 1 ] = '\0';
  2270. X#endif
  2271. X      }
  2272. X
  2273. X   /* deallocate old memory */
  2274. X
  2275. X#if INTENSIVE_DEBUG
  2276. X   if ( d->rab == TRUE )
  2277. X      {
  2278. X      sprintf( bwb_ebuf, "in str_btob(): reallocating RAB" );
  2279. X      bwb_debug( bwb_ebuf );
  2280. X      }
  2281. X#endif
  2282. X
  2283. X   if (( d->rab != TRUE ) && ( d->sbuffer != NULL ))
  2284. X      {
  2285. X#if INTENSIVE_DEBUG
  2286. X      sprintf( tbuf, "in str_btob(): deallocating string memory" );
  2287. X      bwb_debug ( tbuf );
  2288. X#endif
  2289. X      free( d->sbuffer );
  2290. X      }
  2291. X   else
  2292. X      {
  2293. X      d->rab = (char) FALSE;
  2294. X      }
  2295. X
  2296. X   /* reassign buffer */
  2297. X
  2298. X   d->sbuffer = t;
  2299. X
  2300. X   /* reassign length */
  2301. X
  2302. X   d->length = s->length;
  2303. X
  2304. X#if INTENSIVE_DEBUG
  2305. X   sprintf( bwb_ebuf, "in str_btob(): exit length <%d> string <%s>",
  2306. X      d->length, tbuf );
  2307. X   bwb_debug( bwb_ebuf );
  2308. X#endif
  2309. X
  2310. X   /* return */
  2311. X
  2312. X   return TRUE;
  2313. X
  2314. X   }
  2315. X
  2316. X/***************************************************************
  2317. X
  2318. X        FUNCTION:       str_ctob()
  2319. X
  2320. X        DESCRIPTION:    This C function assigns a null-terminated
  2321. X            C string to a bwBASIC string structure.
  2322. X
  2323. X***************************************************************/
  2324. X
  2325. X#if ANSI_C
  2326. Xint
  2327. Xstr_ctob( bstring *s, char *buffer )
  2328. X#else
  2329. Xint
  2330. Xstr_ctob( s, buffer )
  2331. X   bstring *s;
  2332. X   char *buffer;
  2333. X#endif
  2334. X   {
  2335. X   char *t;
  2336. X   register int i;
  2337. X
  2338. X#if INTENSIVE_DEBUG
  2339. X   sprintf( tbuf, "in str_ctob(): entry, c string is <%s>", buffer );
  2340. X   bwb_debug( tbuf );
  2341. X#endif
  2342. X#if TEST_BSTRING
  2343. X   sprintf( tbuf, "in str_ctob(): entry, b string name is <%s>", s->name );
  2344. X   bwb_debug( tbuf );
  2345. X#endif
  2346. X
  2347. X   /* get memory for new buffer */
  2348. X
  2349. X   if ( ( t = (char *) calloc( strlen( buffer ) + 1, 1 )) == NULL )
  2350. X      {
  2351. X#if PROG_ERRORS
  2352. X      bwb_error( "in str_ctob(): failed to get memory for new buffer" );
  2353. X#else
  2354. X      bwb_error( err_getmem );
  2355. X#endif
  2356. X      return FALSE;
  2357. X      }
  2358. X
  2359. X   /* write the c string to the b string */
  2360. X
  2361. X   t[ 0 ] = '\0';
  2362. X   for ( i = 0; i < (int) strlen( buffer ); ++i )
  2363. X      {
  2364. X      t[ i ] = buffer[ i ];
  2365. X#if INTENSIVE_DEBUG
  2366. X      tbuf[ i ] = buffer[ i ];
  2367. X      tbuf[ i + 1 ] = '\0';
  2368. X#endif
  2369. X      }
  2370. X
  2371. X   /* deallocate old memory */
  2372. X
  2373. X#if INTENSIVE_DEBUG
  2374. X   if ( s->rab == TRUE )
  2375. X      {
  2376. X      sprintf( bwb_ebuf, "in str_ctob(): reallocating RAB" );
  2377. X      bwb_debug( bwb_ebuf );
  2378. X      }
  2379. X#endif
  2380. X
  2381. X   if (( s->rab != TRUE ) && ( s->sbuffer != NULL ))
  2382. X      {
  2383. X      free( s->sbuffer );
  2384. X      }
  2385. X   else
  2386. X      {
  2387. X      s->rab = (char) FALSE;
  2388. X      }
  2389. X
  2390. X   /* reassign buffer */
  2391. X
  2392. X   s->sbuffer = t;
  2393. X
  2394. X   /* reassign length */
  2395. X
  2396. X   s->length = (unsigned char) strlen( buffer );
  2397. X
  2398. X#if INTENSIVE_DEBUG
  2399. X   sprintf( bwb_ebuf, "in str_ctob(): exit length <%d> string <%s>",
  2400. X      s->length, tbuf );
  2401. X   bwb_debug( bwb_ebuf );
  2402. X#endif
  2403. X
  2404. X   /* return */
  2405. X
  2406. X   return TRUE;
  2407. X
  2408. X   }
  2409. X
  2410. X/***************************************************************
  2411. X
  2412. X        FUNCTION:       str_btoc()
  2413. X
  2414. X        DESCRIPTION:    This C function assigns a null-terminated
  2415. X            C string to a bwBASIC string structure.
  2416. X
  2417. X***************************************************************/
  2418. X
  2419. X#if ANSI_C
  2420. Xint
  2421. Xstr_btoc( char *buffer, bstring *s )
  2422. X#else
  2423. Xint
  2424. Xstr_btoc( buffer, s )
  2425. X   char *buffer;
  2426. X   bstring *s;
  2427. X#endif
  2428. X   {
  2429. X   register int i;
  2430. X
  2431. X#if INTENSIVE_DEBUG
  2432. X   sprintf( tbuf, "in str_btoc(): entry, b string length is <%d>",
  2433. X      s->length );
  2434. X   bwb_debug( tbuf );
  2435. X#endif
  2436. X#if TEST_BSTRING
  2437. X   sprintf( tbuf, "in str_btoc(): entry, b string name is <%s>", s->name );
  2438. X   bwb_debug( tbuf );
  2439. X#endif
  2440. X
  2441. X   /* write the b string to the c string */
  2442. X
  2443. X   buffer[ 0 ] = '\0';
  2444. X   for ( i = 0; i < (int) s->length; ++i )
  2445. X      {
  2446. X      buffer[ i ] = s->sbuffer[ i ];
  2447. X      buffer[ i + 1 ] = '\0';
  2448. X      if ( i >= MAXSTRINGSIZE )
  2449. X         {
  2450. X         i = s->length + 1;
  2451. X         }
  2452. X      }
  2453. X
  2454. X#if INTENSIVE_DEBUG
  2455. X   sprintf( tbuf, "in str_btoc(): exit, c string is <%s>", buffer );
  2456. X   bwb_debug( tbuf );
  2457. X#endif
  2458. X
  2459. X   /* return */
  2460. X
  2461. X   return TRUE;
  2462. X
  2463. X   }
  2464. X
  2465. X/***************************************************************
  2466. X
  2467. X        FUNCTION:       str_cat()
  2468. X
  2469. X        DESCRIPTION:    This C function performs the equivalent
  2470. X            of the C strcat() function, using BASIC
  2471. X            strings.
  2472. X
  2473. X***************************************************************/
  2474. X
  2475. X#if ANSI_C
  2476. Xchar *
  2477. Xstr_cat( bstring *a, bstring *b )
  2478. X#else
  2479. Xchar *
  2480. Xstr_cat( a, b )
  2481. X   bstring *a;
  2482. X   bstring *b;
  2483. X#endif
  2484. X   {
  2485. X   char abuf[ MAXSTRINGSIZE + 1 ];
  2486. X   char bbuf[ MAXSTRINGSIZE + 1 ];
  2487. X   char *r;
  2488. X
  2489. X   str_btoc( abuf, a );
  2490. X   str_btoc( bbuf, b );
  2491. X
  2492. X#if INTENSIVE_DEBUG
  2493. X   sprintf( bwb_ebuf, "in str_cat(): a <%s> b <%s>", abuf, bbuf );
  2494. X   bwb_debug( bwb_ebuf );
  2495. X#endif
  2496. X
  2497. X   strcat( abuf, bbuf );
  2498. X   str_ctob( a, abuf );
  2499. X
  2500. X#if INTENSIVE_DEBUG
  2501. X   sprintf( bwb_ebuf, "in str_cat(): returns <%s>", abuf );
  2502. X   bwb_debug( bwb_ebuf );
  2503. X#endif
  2504. X
  2505. X   return r;
  2506. X   }
  2507. X
  2508. X/***************************************************************
  2509. X
  2510. X        FUNCTION:       str_cmp()
  2511. X
  2512. X    DESCRIPTION:    This C function performs the equivalent
  2513. X            of the C strcmp() function, using BASIC
  2514. X            strings.
  2515. X
  2516. X***************************************************************/
  2517. X
  2518. X#if ANSI_C
  2519. Xint
  2520. Xstr_cmp( bstring *a, bstring *b )
  2521. X#else
  2522. Xint
  2523. Xstr_cmp( a, b )
  2524. X   bstring *a;
  2525. X   bstring *b;
  2526. X#endif
  2527. X   {
  2528. X   char abuf[ MAXSTRINGSIZE + 1 ];
  2529. X   char bbuf[ MAXSTRINGSIZE + 1 ];
  2530. X
  2531. X   str_btoc( abuf, a );
  2532. X   str_btoc( bbuf, b );
  2533. X
  2534. X   return strcmp( abuf, bbuf );
  2535. X   }
  2536. X
  2537. X
  2538. X
  2539. END_OF_FILE
  2540.   if test 7352 -ne `wc -c <'bwbasic-2.10/bwb_str.c'`; then
  2541.     echo shar: \"'bwbasic-2.10/bwb_str.c'\" unpacked with wrong size!
  2542.   fi
  2543.   # end of 'bwbasic-2.10/bwb_str.c'
  2544. fi
  2545. if test -f 'bwbasic-2.10/bwbasic.mak' -a "${1}" != "-c" ; then 
  2546.   echo shar: Will not clobber existing file \"'bwbasic-2.10/bwbasic.mak'\"
  2547. else
  2548.   echo shar: Extracting \"'bwbasic-2.10/bwbasic.mak'\" \(1400 characters\)
  2549.   sed "s/^X//" >'bwbasic-2.10/bwbasic.mak' <<'END_OF_FILE'
  2550. XPROJ    =BWBASIC
  2551. XDEBUG    =0
  2552. XCC    =qcl
  2553. XCFLAGS_G    = /AL /W3 /Za /DMSDOS 
  2554. XCFLAGS_D    = /Zd /Gi$(PROJ).mdt /Od 
  2555. XCFLAGS_R    = /O /Ot /Gs /DNDEBUG 
  2556. XCFLAGS    =$(CFLAGS_G) $(CFLAGS_R)
  2557. XLFLAGS_G    = /CP:0xffff /NOI /NOE /SE:0x80 /ST:0x1fa0 
  2558. XLFLAGS_D    = /INCR 
  2559. XLFLAGS_R    = 
  2560. XLFLAGS    =$(LFLAGS_G) $(LFLAGS_R)
  2561. XRUNFLAGS    =
  2562. XOBJS_EXT =     
  2563. XLIBS_EXT =     
  2564. X
  2565. Xall:    $(PROJ).exe
  2566. X
  2567. Xbwbasic.obj:    bwbasic.c
  2568. X
  2569. Xbwb_cmd.obj:    bwb_cmd.c
  2570. X
  2571. Xbwb_cnd.obj:    bwb_cnd.c
  2572. X
  2573. Xbwb_dio.obj:    bwb_dio.c
  2574. X
  2575. Xbwb_elx.obj:    bwb_elx.c
  2576. X
  2577. Xbwb_exp.obj:    bwb_exp.c
  2578. X
  2579. Xbwb_fnc.obj:    bwb_fnc.c
  2580. X
  2581. Xbwb_inp.obj:    bwb_inp.c
  2582. X
  2583. Xbwb_int.obj:    bwb_int.c
  2584. X
  2585. Xbwb_mth.obj:    bwb_mth.c
  2586. X
  2587. Xbwb_ops.obj:    bwb_ops.c
  2588. X
  2589. Xbwb_par.obj:    bwb_par.c
  2590. X
  2591. Xbwb_prn.obj:    bwb_prn.c
  2592. X
  2593. Xbwb_stc.obj:    bwb_stc.c
  2594. X
  2595. Xbwb_str.obj:    bwb_str.c
  2596. X
  2597. Xbwb_tbl.obj:    bwb_tbl.c
  2598. X
  2599. Xbwb_var.obj:    bwb_var.c
  2600. X
  2601. Xbwx_tty.obj:    bwx_tty.c
  2602. X
  2603. X$(PROJ).exe:    bwbasic.obj bwb_cmd.obj bwb_cnd.obj bwb_dio.obj bwb_elx.obj bwb_exp.obj \
  2604. X    bwb_fnc.obj bwb_inp.obj bwb_int.obj bwb_mth.obj bwb_ops.obj bwb_par.obj bwb_prn.obj \
  2605. X    bwb_stc.obj bwb_str.obj bwb_tbl.obj bwb_var.obj bwx_tty.obj $(OBJS_EXT)
  2606. X    echo >NUL @<<$(PROJ).crf
  2607. Xbwbasic.obj +
  2608. Xbwb_cmd.obj +
  2609. Xbwb_cnd.obj +
  2610. Xbwb_dio.obj +
  2611. Xbwb_elx.obj +
  2612. Xbwb_exp.obj +
  2613. Xbwb_fnc.obj +
  2614. Xbwb_inp.obj +
  2615. Xbwb_int.obj +
  2616. Xbwb_mth.obj +
  2617. Xbwb_ops.obj +
  2618. Xbwb_par.obj +
  2619. Xbwb_prn.obj +
  2620. Xbwb_stc.obj +
  2621. Xbwb_str.obj +
  2622. Xbwb_tbl.obj +
  2623. Xbwb_var.obj +
  2624. Xbwx_tty.obj +
  2625. X$(OBJS_EXT)
  2626. X$(PROJ).exe
  2627. X
  2628. X$(LIBS_EXT);
  2629. X<<
  2630. X    link $(LFLAGS) @$(PROJ).crf
  2631. X
  2632. Xrun: $(PROJ).exe
  2633. X    $(PROJ) $(RUNFLAGS)
  2634. X
  2635. END_OF_FILE
  2636.   if test 1400 -ne `wc -c <'bwbasic-2.10/bwbasic.mak'`; then
  2637.     echo shar: \"'bwbasic-2.10/bwbasic.mak'\" unpacked with wrong size!
  2638.   fi
  2639.   # end of 'bwbasic-2.10/bwbasic.mak'
  2640. fi
  2641. if test -f 'bwbasic-2.10/bwbtest/index.txt' -a "${1}" != "-c" ; then 
  2642.   echo shar: Will not clobber existing file \"'bwbasic-2.10/bwbtest/index.txt'\"
  2643. else
  2644.   echo shar: Extracting \"'bwbasic-2.10/bwbtest/index.txt'\" \(1141 characters\)
  2645.   sed "s/^X//" >'bwbasic-2.10/bwbtest/index.txt' <<'END_OF_FILE'
  2646. XTest Programs for bwBASIC:
  2647. X-------------------------
  2648. X
  2649. X___ ___ ABS      BAS    
  2650. X___ ___ ASSIGN   BAS    
  2651. X___ ___ CALLFUNC BAS    * STRUCT_CMDS
  2652. X___ ___ CALLSUB  BAS    * STRUCT_CMDS
  2653. X___ ___ CHAIN1   BAS    
  2654. X___ ___ CHAIN2   BAS    * called from CHAIN1.BAS
  2655. X___ ___ DATAREAD BAS    
  2656. X___ ___ DEFFN    BAS    
  2657. X___ ___ DIM      BAS    
  2658. X___ ___ DOLOOP   BAS    * STRUCT_CMDS
  2659. X___ ___ DOWHILE  BAS    * STRUCT_CMDS
  2660. X___ ___ ELSEIF   BAS    * STRUCT_CMDS
  2661. X___ ___ END      BAS    
  2662. X___ ___ ERR      BAS    
  2663. X___ ___ FORNEXT  BAS    
  2664. X___ ___ FUNCTION BAS
  2665. X___ ___ GOSUB    BAS    
  2666. X___ ___ GOTOLABL BAS    * STRUCT_CMDS
  2667. X___ ___ IFLINE   BAS
  2668. X___ ___ INPUT    BAS    
  2669. X___ ___ LOF      BAS    * LOF(): IMPLEMENTATION-SPECIFIC
  2670. X___ ___ LOOPUNTL BAS    * STRUCT_CMDS
  2671. X___ ___ MAIN     BAS    * STRUCT_CMDS
  2672. X___ ___ MLIFTHEN BAS    * STRUCT_CMDS
  2673. X___ ___ ON       BAS    
  2674. X___ ___ ONERR    BAS    
  2675. X___ ___ ONERRLBL BAS    * STRUCT_CMDS
  2676. X___ ___ ONGOSUB  BAS    
  2677. X___ ___ OPENTEST BAS    
  2678. X___ ___ OPTION   BAS    
  2679. X___ ___ PUTGET   BAS    * KILL: IMPLEMENTATION-SPECIFIC
  2680. X___ ___ RANDOM   BAS    
  2681. X___ ___ SELCASE  BAS    * STRUCT_CMDS
  2682. X___ ___ SNGLFUNC BAS    
  2683. X___ ___ STOP     BAS    
  2684. X___ ___ TERM     BAS    
  2685. X___ ___ WHILWEND BAS    
  2686. X___ ___ WIDTH    BAS    
  2687. X___ ___ WRITEINP BAS    
  2688. X
  2689. END_OF_FILE
  2690.   if test 1141 -ne `wc -c <'bwbasic-2.10/bwbtest/index.txt'`; then
  2691.     echo shar: \"'bwbasic-2.10/bwbtest/index.txt'\" unpacked with wrong size!
  2692.   fi
  2693.   # end of 'bwbasic-2.10/bwbtest/index.txt'
  2694. fi
  2695. if test -f 'bwbasic-2.10/bwx_iqc.h' -a "${1}" != "-c" ; then 
  2696.   echo shar: Will not clobber existing file \"'bwbasic-2.10/bwx_iqc.h'\"
  2697. else
  2698.   echo shar: Extracting \"'bwbasic-2.10/bwx_iqc.h'\" \(1589 characters\)
  2699.   sed "s/^X//" >'bwbasic-2.10/bwx_iqc.h' <<'END_OF_FILE'
  2700. X/***************************************************************
  2701. X
  2702. X        bwx_iqc.h       Header File for IBM PC and Compatible
  2703. X            Implementation of bwBASIC
  2704. X            Using Microsoft QuickC (tm) Compiler
  2705. X
  2706. X                        Copyright (c) 1993, Ted A. Campbell
  2707. X            Bywater Software
  2708. X
  2709. X                        email: tcamp@delphi.com
  2710. X
  2711. X        Copyright and Permissions Information:
  2712. X
  2713. X        All U.S. and international rights are claimed by the author,
  2714. X        Ted A. Campbell.
  2715. X
  2716. X    This software is released under the terms of the GNU General
  2717. X    Public License (GPL), which is distributed with this software
  2718. X    in the file "COPYING".  The GPL specifies the terms under
  2719. X    which users may copy and use the software in this distribution.
  2720. X
  2721. X    A separate license is available for commercial distribution,
  2722. X    for information on which you should contact the author.
  2723. X
  2724. X***************************************************************/
  2725. X
  2726. X#define IMP_IDSTRING    "IQC"           /* unique ID string for this implementation */
  2727. X
  2728. X/* Definitions indicating which commands and functions are implemented */
  2729. X
  2730. X#define IMP_FNCINKEY    1               /* 0 if INKEY$ is not implemented, 1 if it is */
  2731. X#define IMP_CMDCLS    1        /* 0 if CLS is not implemented, 1 if it is */
  2732. X#define IMP_CMDLOC    1        /* 0 if LOCATE is not implemented, 1 if it is */
  2733. X#define IMP_CMDCOLOR    1               /* 0 if COLOR is not implemented, 1 if it is */
  2734. X
  2735. X#define UNIX_CMDS       TRUE
  2736. X#define MKDIR_ONE_ARG    TRUE        /* TRUE if your mkdir has but one argument;
  2737. X                       FALSE if it has two */
  2738. X#define PERMISSIONS    493        /* permissions to set in Unix-type system */
  2739. END_OF_FILE
  2740.   if test 1589 -ne `wc -c <'bwbasic-2.10/bwx_iqc.h'`; then
  2741.     echo shar: \"'bwbasic-2.10/bwx_iqc.h'\" unpacked with wrong size!
  2742.   fi
  2743.   # end of 'bwbasic-2.10/bwx_iqc.h'
  2744. fi
  2745. if test -f 'bwbasic-2.10/bwx_tty.h' -a "${1}" != "-c" ; then 
  2746.   echo shar: Will not clobber existing file \"'bwbasic-2.10/bwx_tty.h'\"
  2747. else
  2748.   echo shar: Extracting \"'bwbasic-2.10/bwx_tty.h'\" \(1648 characters\)
  2749.   sed "s/^X//" >'bwbasic-2.10/bwx_tty.h' <<'END_OF_FILE'
  2750. X/***************************************************************
  2751. X
  2752. X        bwx_tty.h       Header file for TTY-style hardware
  2753. X            implementation of bwBASIC
  2754. X
  2755. X            This file may be used as a template
  2756. X            for developing more sophisticated
  2757. X            hardware implementations
  2758. X
  2759. X                        Copyright (c) 1993, Ted A. Campbell
  2760. X            Bywater Software
  2761. X
  2762. X                        email: tcamp@delphi.com
  2763. X
  2764. X        Copyright and Permissions Information:
  2765. X
  2766. X        All U.S. and international rights are claimed by the author,
  2767. X        Ted A. Campbell.
  2768. X
  2769. X    This software is released under the terms of the GNU General
  2770. X    Public License (GPL), which is distributed with this software
  2771. X    in the file "COPYING".  The GPL specifies the terms under
  2772. X    which users may copy and use the software in this distribution.
  2773. X
  2774. X    A separate license is available for commercial distribution,
  2775. X    for information on which you should contact the author.
  2776. X
  2777. X***************************************************************/
  2778. X
  2779. X#define IMP_IDSTRING    "TTY"           /* unique ID string for this implementation */
  2780. X
  2781. X/* Definitions indicating which commands and functions are implemented */
  2782. X
  2783. X#define IMP_FNCINKEY    0        /* 0 if INKEY$ is not implemented, 1 if it is */
  2784. X#define IMP_CMDCLS    0        /* 0 if CLS is not implemented, 1 if it is */
  2785. X#define IMP_CMDLOC    0        /* 0 if LOCATE is not implemented, 1 if it is */
  2786. X#define IMP_CMDCOLOR    0               /* 0 if COLOR is not implemented, 1 if it is */
  2787. X
  2788. X#define UNIX_CMDS       FALSE
  2789. X#define MKDIR_ONE_ARG   FALSE           /* TRUE if your mkdir has but one argument;
  2790. X                       FALSE if it has two */
  2791. X#define PERMISSIONS    493        /* permissions to set in Unix-type system */
  2792. END_OF_FILE
  2793.   if test 1648 -ne `wc -c <'bwbasic-2.10/bwx_tty.h'`; then
  2794.     echo shar: \"'bwbasic-2.10/bwx_tty.h'\" unpacked with wrong size!
  2795.   fi
  2796.   # end of 'bwbasic-2.10/bwx_tty.h'
  2797. fi
  2798. if test -f 'bwbasic-2.10/makefile.qcl' -a "${1}" != "-c" ; then 
  2799.   echo shar: Will not clobber existing file \"'bwbasic-2.10/makefile.qcl'\"
  2800. else
  2801.   echo shar: Extracting \"'bwbasic-2.10/makefile.qcl'\" \(1449 characters\)
  2802.   sed "s/^X//" >'bwbasic-2.10/makefile.qcl' <<'END_OF_FILE'
  2803. X#               Microsoft QuickC Makefile for Bywater BASIC Interpreter
  2804. X#
  2805. X#        This makefile is for line-oriented QuickC only, not for
  2806. X#        the QuickC integrated environment. To make the program:
  2807. X#        type "nmake -f makefile.qcl".
  2808. X#
  2809. X#        To implement the bwx_iqc implementation (using specific
  2810. X#        features for the IBM PC and compatibles), chainge each
  2811. X#        instance of "bwx_tty" to "bwx_iqc".
  2812. X#
  2813. XPROJ=           bwbasic
  2814. XCC=             qcl
  2815. X
  2816. X#
  2817. X#        These are the normal flags I used to compile bwBASIC:
  2818. X#
  2819. XCFLAGS=         -O -AL -W3 -Za -DMSDOS
  2820. X#
  2821. X#        The following flags can be used for debugging:
  2822. X#
  2823. X#CFLAGS=         -Od -AL -W3 -Za -Zr -Zi -DMSDOS
  2824. X
  2825. XLFLAGS=         /NOE /ST:8192
  2826. X
  2827. XOFILES=         bwbasic.obj bwb_int.obj bwb_tbl.obj bwb_cmd.obj bwb_prn.obj\
  2828. X                bwb_exp.obj bwb_var.obj bwb_inp.obj bwb_fnc.obj bwb_cnd.obj\
  2829. X                bwb_ops.obj bwb_dio.obj bwb_str.obj bwb_elx.obj bwb_mth.obj\
  2830. X        bwb_stc.obj bwb_par.obj bwx_tty.obj
  2831. X
  2832. XHFILES=         bwbasic.h bwb_mes.h
  2833. X
  2834. Xall:            $(PROJ).exe
  2835. X
  2836. X$(OFILES):      $(HFILES) makefile.qcl
  2837. X
  2838. X$(PROJ).exe:    $(OFILES)
  2839. X        echo >NUL @<<$(PROJ).crf
  2840. Xbwbasic.obj +
  2841. Xbwb_cmd.obj +
  2842. Xbwb_cnd.obj +
  2843. Xbwb_fnc.obj +
  2844. Xbwb_inp.obj +
  2845. Xbwb_int.obj +
  2846. Xbwb_prn.obj +
  2847. Xbwb_tbl.obj +
  2848. Xbwb_var.obj +
  2849. Xbwb_exp.obj +
  2850. Xbwb_ops.obj +
  2851. Xbwb_dio.obj +
  2852. Xbwb_str.obj +
  2853. Xbwb_elx.obj +
  2854. Xbwb_mth.obj +
  2855. Xbwb_stc.obj +
  2856. Xbwb_par.obj +
  2857. Xbwx_tty.obj +
  2858. X$(OBJS_EXT)
  2859. X$(PROJ).exe
  2860. X
  2861. X$(LIBS_EXT);
  2862. X<<
  2863. X        link $(LFLAGS) @$(PROJ).crf
  2864. X    erase $(PROJ).crf
  2865. X
  2866. END_OF_FILE
  2867.   if test 1449 -ne `wc -c <'bwbasic-2.10/makefile.qcl'`; then
  2868.     echo shar: \"'bwbasic-2.10/makefile.qcl'\" unpacked with wrong size!
  2869.   fi
  2870.   # end of 'bwbasic-2.10/makefile.qcl'
  2871. fi
  2872. echo shar: End of archive 9 \(of 15\).
  2873. cp /dev/null ark9isdone
  2874. MISSING=""
  2875. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ; do
  2876.     if test ! -f ark${I}isdone ; then
  2877.     MISSING="${MISSING} ${I}"
  2878.     fi
  2879. done
  2880. if test "${MISSING}" = "" ; then
  2881.     echo You have unpacked all 15 archives.
  2882.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  2883. else
  2884.     echo You still must unpack the following archives:
  2885.     echo "        " ${MISSING}
  2886. fi
  2887. exit 0
  2888. exit 0 # Just in case...
  2889.