home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-10-29 | 70.3 KB | 2,389 lines |
- Newsgroups: comp.sources.misc
- From: tcamp@delphi.com (Ted A. Campbell)
- Subject: v40i057: bwbasic - Bywater BASIC interpreter version 2.10, Part06/15
- Message-ID: <1993Oct29.162551.3698@sparky.sterling.com>
- X-Md4-Signature: 64200060318e96eed1483be3c9a4493c
- Sender: kent@sparky.sterling.com (Kent Landfield)
- Organization: Sterling Software
- Date: Fri, 29 Oct 1993 16:25:51 GMT
- Approved: kent@sparky.sterling.com
-
- Submitted-by: tcamp@delphi.com (Ted A. Campbell)
- Posting-number: Volume 40, Issue 57
- Archive-name: bwbasic/part06
- Environment: UNIX, DOS
- Supersedes: bwbasic: Volume 33, Issue 37-47
-
- #! /bin/sh
- # This is a shell archive. Remove anything before this line, then feed it
- # into a shell via "sh file" or similar. To overwrite existing files,
- # type "sh file -c".
- # Contents: bwbasic-2.10/COPYING bwbasic-2.10/bwb_ops.c
- # bwbasic-2.10/bwbtest/function.bas
- # Wrapped by kent@sparky on Thu Oct 21 10:47:49 1993
- PATH=/bin:/usr/bin:/usr/ucb:/usr/local/bin:/usr/lbin ; export PATH
- echo If this archive is complete, you will see the following message:
- echo ' "shar: End of archive 6 (of 15)."'
- if test -f 'bwbasic-2.10/COPYING' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'bwbasic-2.10/COPYING'\"
- else
- echo shar: Extracting \"'bwbasic-2.10/COPYING'\" \(17984 characters\)
- sed "s/^X//" >'bwbasic-2.10/COPYING' <<'END_OF_FILE'
- X
- X GNU GENERAL PUBLIC LICENSE
- X Version 2, June 1991
- X
- X Copyright (C) 1989, 1991 Free Software Foundation, Inc.
- X 675 Mass Ave, Cambridge, MA 02139, USA
- X Everyone is permitted to copy and distribute verbatim copies
- X of this license document, but changing it is not allowed.
- X
- X Preamble
- X
- X The licenses for most software are designed to take away your
- Xfreedom to share and change it. By contrast, the GNU General Public
- XLicense is intended to guarantee your freedom to share and change free
- Xsoftware--to make sure the software is free for all its users. This
- XGeneral Public License applies to most of the Free Software
- XFoundation's software and to any other program whose authors commit to
- Xusing it. (Some other Free Software Foundation software is covered by
- Xthe GNU Library General Public License instead.) You can apply it to
- Xyour programs, too.
- X
- X When we speak of free software, we are referring to freedom, not
- Xprice. Our General Public Licenses are designed to make sure that you
- Xhave the freedom to distribute copies of free software (and charge for
- Xthis service if you wish), that you receive source code or can get it
- Xif you want it, that you can change the software or use pieces of it
- Xin new free programs; and that you know you can do these things.
- X
- X To protect your rights, we need to make restrictions that forbid
- Xanyone to deny you these rights or to ask you to surrender the rights.
- XThese restrictions translate to certain responsibilities for you if you
- Xdistribute copies of the software, or if you modify it.
- X
- X For example, if you distribute copies of such a program, whether
- Xgratis or for a fee, you must give the recipients all the rights that
- Xyou have. You must make sure that they, too, receive or can get the
- Xsource code. And you must show them these terms so they know their
- Xrights.
- X
- X We protect your rights with two steps: (1) copyright the software, and
- X(2) offer you this license which gives you legal permission to copy,
- Xdistribute and/or modify the software.
- X
- X Also, for each author's protection and ours, we want to make certain
- Xthat everyone understands that there is no warranty for this free
- Xsoftware. If the software is modified by someone else and passed on, we
- Xwant its recipients to know that what they have is not the original, so
- Xthat any problems introduced by others will not reflect on the original
- Xauthors' reputations.
- X
- X Finally, any free program is threatened constantly by software
- Xpatents. We wish to avoid the danger that redistributors of a free
- Xprogram will individually obtain patent licenses, in effect making the
- Xprogram proprietary. To prevent this, we have made it clear that any
- Xpatent must be licensed for everyone's free use or not licensed at all.
- X
- X The precise terms and conditions for copying, distribution and
- Xmodification follow.
- X
- X GNU GENERAL PUBLIC LICENSE
- X TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
- X
- X 0. This License applies to any program or other work which contains
- Xa notice placed by the copyright holder saying it may be distributed
- Xunder the terms of this General Public License. The "Program", below,
- Xrefers to any such program or work, and a "work based on the Program"
- Xmeans either the Program or any derivative work under copyright law:
- Xthat is to say, a work containing the Program or a portion of it,
- Xeither verbatim or with modifications and/or translated into another
- Xlanguage. (Hereinafter, translation is included without limitation in
- Xthe term "modification".) Each licensee is addressed as "you".
- X
- XActivities other than copying, distribution and modification are not
- Xcovered by this License; they are outside its scope. The act of
- Xrunning the Program is not restricted, and the output from the Program
- Xis covered only if its contents constitute a work based on the
- XProgram (independent of having been made by running the Program).
- XWhether that is true depends on what the Program does.
- X
- X 1. You may copy and distribute verbatim copies of the Program's
- Xsource code as you receive it, in any medium, provided that you
- Xconspicuously and appropriately publish on each copy an appropriate
- Xcopyright notice and disclaimer of warranty; keep intact all the
- Xnotices that refer to this License and to the absence of any warranty;
- Xand give any other recipients of the Program a copy of this License
- Xalong with the Program.
- X
- XYou may charge a fee for the physical act of transferring a copy, and
- Xyou may at your option offer warranty protection in exchange for a fee.
- X
- X 2. You may modify your copy or copies of the Program or any portion
- Xof it, thus forming a work based on the Program, and copy and
- Xdistribute such modifications or work under the terms of Section 1
- Xabove, provided that you also meet all of these conditions:
- X
- X a) You must cause the modified files to carry prominent notices
- X stating that you changed the files and the date of any change.
- X
- X b) You must cause any work that you distribute or publish, that in
- X whole or in part contains or is derived from the Program or any
- X part thereof, to be licensed as a whole at no charge to all third
- X parties under the terms of this License.
- X
- X c) If the modified program normally reads commands interactively
- X when run, you must cause it, when started running for such
- X interactive use in the most ordinary way, to print or display an
- X announcement including an appropriate copyright notice and a
- X notice that there is no warranty (or else, saying that you provide
- X a warranty) and that users may redistribute the program under
- X these conditions, and telling the user how to view a copy of this
- X License. (Exception: if the Program itself is interactive but
- X does not normally print such an announcement, your work based on
- X the Program is not required to print an announcement.)
- X
- XThese requirements apply to the modified work as a whole. If
- Xidentifiable sections of that work are not derived from the Program,
- Xand can be reasonably considered independent and separate works in
- Xthemselves, then this License, and its terms, do not apply to those
- Xsections when you distribute them as separate works. But when you
- Xdistribute the same sections as part of a whole which is a work based
- Xon the Program, the distribution of the whole must be on the terms of
- Xthis License, whose permissions for other licensees extend to the
- Xentire whole, and thus to each and every part regardless of who wrote it.
- X
- XThus, it is not the intent of this section to claim rights or contest
- Xyour rights to work written entirely by you; rather, the intent is to
- Xexercise the right to control the distribution of derivative or
- Xcollective works based on the Program.
- X
- XIn addition, mere aggregation of another work not based on the Program
- Xwith the Program (or with a work based on the Program) on a volume of
- Xa storage or distribution medium does not bring the other work under
- Xthe scope of this License.
- X
- X 3. You may copy and distribute the Program (or a work based on it,
- Xunder Section 2) in object code or executable form under the terms of
- XSections 1 and 2 above provided that you also do one of the following:
- X
- X a) Accompany it with the complete corresponding machine-readable
- X source code, which must be distributed under the terms of Sections
- X 1 and 2 above on a medium customarily used for software interchange; or,
- X
- X b) Accompany it with a written offer, valid for at least three
- X years, to give any third party, for a charge no more than your
- X cost of physically performing source distribution, a complete
- X machine-readable copy of the corresponding source code, to be
- X distributed under the terms of Sections 1 and 2 above on a medium
- X customarily used for software interchange; or,
- X
- X c) Accompany it with the information you received as to the offer
- X to distribute corresponding source code. (This alternative is
- X allowed only for noncommercial distribution and only if you
- X received the program in object code or executable form with such
- X an offer, in accord with Subsection b above.)
- X
- XThe source code for a work means the preferred form of the work for
- Xmaking modifications to it. For an executable work, complete source
- Xcode means all the source code for all modules it contains, plus any
- Xassociated interface definition files, plus the scripts used to
- Xcontrol compilation and installation of the executable. However, as a
- Xspecial exception, the source code distributed need not include
- Xanything that is normally distributed (in either source or binary
- Xform) with the major components (compiler, kernel, and so on) of the
- Xoperating system on which the executable runs, unless that component
- Xitself accompanies the executable.
- X
- XIf distribution of executable or object code is made by offering
- Xaccess to copy from a designated place, then offering equivalent
- Xaccess to copy the source code from the same place counts as
- Xdistribution of the source code, even though third parties are not
- Xcompelled to copy the source along with the object code.
- X
- X 4. You may not copy, modify, sublicense, or distribute the Program
- Xexcept as expressly provided under this License. Any attempt
- Xotherwise to copy, modify, sublicense or distribute the Program is
- Xvoid, and will automatically terminate your rights under this License.
- XHowever, parties who have received copies, or rights, from you under
- Xthis License will not have their licenses terminated so long as such
- Xparties remain in full compliance.
- X
- X 5. You are not required to accept this License, since you have not
- Xsigned it. However, nothing else grants you permission to modify or
- Xdistribute the Program or its derivative works. These actions are
- Xprohibited by law if you do not accept this License. Therefore, by
- Xmodifying or distributing the Program (or any work based on the
- XProgram), you indicate your acceptance of this License to do so, and
- Xall its terms and conditions for copying, distributing or modifying
- Xthe Program or works based on it.
- X
- X 6. Each time you redistribute the Program (or any work based on the
- XProgram), the recipient automatically receives a license from the
- Xoriginal licensor to copy, distribute or modify the Program subject to
- Xthese terms and conditions. You may not impose any further
- Xrestrictions on the recipients' exercise of the rights granted herein.
- XYou are not responsible for enforcing compliance by third parties to
- Xthis License.
- X
- X 7. If, as a consequence of a court judgment or allegation of patent
- Xinfringement or for any other reason (not limited to patent issues),
- Xconditions are imposed on you (whether by court order, agreement or
- Xotherwise) that contradict the conditions of this License, they do not
- Xexcuse you from the conditions of this License. If you cannot
- Xdistribute so as to satisfy simultaneously your obligations under this
- XLicense and any other pertinent obligations, then as a consequence you
- Xmay not distribute the Program at all. For example, if a patent
- Xlicense would not permit royalty-free redistribution of the Program by
- Xall those who receive copies directly or indirectly through you, then
- Xthe only way you could satisfy both it and this License would be to
- Xrefrain entirely from distribution of the Program.
- X
- XIf any portion of this section is held invalid or unenforceable under
- Xany particular circumstance, the balance of the section is intended to
- Xapply and the section as a whole is intended to apply in other
- Xcircumstances.
- X
- XIt is not the purpose of this section to induce you to infringe any
- Xpatents or other property right claims or to contest validity of any
- Xsuch claims; this section has the sole purpose of protecting the
- Xintegrity of the free software distribution system, which is
- Ximplemented by public license practices. Many people have made
- Xgenerous contributions to the wide range of software distributed
- Xthrough that system in reliance on consistent application of that
- Xsystem; it is up to the author/donor to decide if he or she is willing
- Xto distribute software through any other system and a licensee cannot
- Ximpose that choice.
- X
- XThis section is intended to make thoroughly clear what is believed to
- Xbe a consequence of the rest of this License.
- X
- X 8. If the distribution and/or use of the Program is restricted in
- Xcertain countries either by patents or by copyrighted interfaces, the
- Xoriginal copyright holder who places the Program under this License
- Xmay add an explicit geographical distribution limitation excluding
- Xthose countries, so that distribution is permitted only in or among
- Xcountries not thus excluded. In such case, this License incorporates
- Xthe limitation as if written in the body of this License.
- X
- X 9. The Free Software Foundation may publish revised and/or new versions
- Xof the General Public License from time to time. Such new versions will
- Xbe similar in spirit to the present version, but may differ in detail to
- Xaddress new problems or concerns.
- X
- XEach version is given a distinguishing version number. If the Program
- Xspecifies a version number of this License which applies to it and "any
- Xlater version", you have the option of following the terms and conditions
- Xeither of that version or of any later version published by the Free
- XSoftware Foundation. If the Program does not specify a version number of
- Xthis License, you may choose any version ever published by the Free Software
- XFoundation.
- X
- X 10. If you wish to incorporate parts of the Program into other free
- Xprograms whose distribution conditions are different, write to the author
- Xto ask for permission. For software which is copyrighted by the Free
- XSoftware Foundation, write to the Free Software Foundation; we sometimes
- Xmake exceptions for this. Our decision will be guided by the two goals
- Xof preserving the free status of all derivatives of our free software and
- Xof promoting the sharing and reuse of software generally.
- X
- X NO WARRANTY
- X
- X 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
- XFOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
- XOTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
- XPROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
- XOR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- XMERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
- XTO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
- XPROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
- XREPAIR OR CORRECTION.
- X
- X 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
- XWILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
- XREDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
- XINCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
- XOUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
- XTO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
- XYOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
- XPROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
- XPOSSIBILITY OF SUCH DAMAGES.
- X
- X END OF TERMS AND CONDITIONS
- X
- X Appendix: How to Apply These Terms to Your New Programs
- X
- X If you develop a new program, and you want it to be of the greatest
- Xpossible use to the public, the best way to achieve this is to make it
- Xfree software which everyone can redistribute and change under these terms.
- X
- X To do so, attach the following notices to the program. It is safest
- Xto attach them to the start of each source file to most effectively
- Xconvey the exclusion of warranty; and each file should have at least
- Xthe "copyright" line and a pointer to where the full notice is found.
- X
- X <one line to give the program's name and a brief idea of what it does.>
- X Copyright (C) 19yy <name of author>
- X
- X This program is free software; you can redistribute it and/or modify
- X it under the terms of the GNU General Public License as published by
- X the Free Software Foundation; either version 2 of the License, or
- X (at your option) any later version.
- X
- X This program is distributed in the hope that it will be useful,
- X but WITHOUT ANY WARRANTY; without even the implied warranty of
- X MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- X GNU General Public License for more details.
- X
- X You should have received a copy of the GNU General Public License
- X along with this program; if not, write to the Free Software
- X Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- X
- XAlso add information on how to contact you by electronic and paper mail.
- X
- XIf the program is interactive, make it output a short notice like this
- Xwhen it starts in an interactive mode:
- X
- X Gnomovision version 69, Copyright (C) 19yy name of author
- X Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
- X This is free software, and you are welcome to redistribute it
- X under certain conditions; type `show c' for details.
- X
- XThe hypothetical commands `show w' and `show c' should show the appropriate
- Xparts of the General Public License. Of course, the commands you use may
- Xbe called something other than `show w' and `show c'; they could even be
- Xmouse-clicks or menu items--whatever suits your program.
- X
- XYou should also get your employer (if you work as a programmer) or your
- Xschool, if any, to sign a "copyright disclaimer" for the program, if
- Xnecessary. Here is a sample; alter the names:
- X
- X Yoyodyne, Inc., hereby disclaims all copyright interest in the program
- X `Gnomovision' (which makes passes at compilers) written by James Hacker.
- X
- X <signature of Ty Coon>, 1 April 1989
- X Ty Coon, President of Vice
- X
- XThis General Public License does not permit incorporating your program into
- Xproprietary programs. If your program is a subroutine library, you may
- Xconsider it more useful to permit linking proprietary applications with the
- Xlibrary. If this is what you want to do, use the GNU Library General
- XPublic License instead of this License.
- X
- END_OF_FILE
- if test 17984 -ne `wc -c <'bwbasic-2.10/COPYING'`; then
- echo shar: \"'bwbasic-2.10/COPYING'\" unpacked with wrong size!
- fi
- # end of 'bwbasic-2.10/COPYING'
- fi
- if test -f 'bwbasic-2.10/bwb_ops.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'bwbasic-2.10/bwb_ops.c'\"
- else
- echo shar: Extracting \"'bwbasic-2.10/bwb_ops.c'\" \(46972 characters\)
- sed "s/^X//" >'bwbasic-2.10/bwb_ops.c' <<'END_OF_FILE'
- X/****************************************************************
- X
- X bwb_ops.c Expression Parsing Operations
- X for Bywater BASIC Interpreter
- X
- X Copyright (c) 1993, Ted A. Campbell
- X Bywater Software
- X
- X email: tcamp@delphi.com
- X
- X Copyright and Permissions Information:
- X
- X All U.S. and international rights are claimed by the author,
- X Ted A. Campbell.
- X
- X This software is released under the terms of the GNU General
- X Public License (GPL), which is distributed with this software
- X in the file "COPYING". The GPL specifies the terms under
- X which users may copy and use the software in this distribution.
- X
- X A separate license is available for commercial distribution,
- X for information on which you should contact the author.
- X
- X****************************************************************/
- X
- X#include <stdio.h>
- X#include <ctype.h>
- X#include <math.h>
- X
- X#include "bwbasic.h"
- X#include "bwb_mes.h"
- X
- X/* declarations for functions visible in this file only */
- X
- X#if ANSI_C
- Xstatic int op_oplevel( int level );
- Xstatic int op_add( int level, int precision );
- Xstatic int op_subtract( int level, int precision );
- Xstatic int op_multiply( int level, int precision );
- Xstatic int op_divide( int level, int precision );
- Xstatic int op_assign( int level, int precision );
- Xstatic int op_equals( int level, int precision );
- Xstatic int op_lessthan( int level, int precision );
- Xstatic int op_greaterthan( int level, int precision );
- Xstatic int op_lteq( int level, int precision );
- Xstatic int op_gteq( int level, int precision );
- Xstatic int op_notequal( int level, int precision );
- Xstatic int op_modulus( int level, int precision );
- Xstatic int op_exponent( int level, int precision );
- Xstatic int op_intdiv( int level, int precision );
- Xstatic int op_or( int level, int precision );
- Xstatic int op_and( int level, int precision );
- Xstatic int op_not( int level, int precision );
- Xstatic int op_xor( int level, int precision );
- Xstatic int op_islevelstr( int level );
- Xstatic int op_getprecision( int level );
- Xstatic int op_isoperator( int operation );
- Xstatic int op_pulldown( int how_far );
- X#else
- Xstatic int op_oplevel();
- Xstatic int op_add();
- Xstatic int op_subtract();
- Xstatic int op_multiply();
- Xstatic int op_divide();
- Xstatic int op_assign();
- Xstatic int op_equals();
- Xstatic int op_lessthan();
- Xstatic int op_greaterthan();
- Xstatic int op_lteq();
- Xstatic int op_gteq();
- Xstatic int op_notequal();
- Xstatic int op_modulus();
- Xstatic int op_exponent();
- Xstatic int op_intdiv();
- Xstatic int op_or();
- Xstatic int op_and();
- Xstatic int op_not();
- Xstatic int op_xor();
- Xstatic int op_islevelstr();
- Xstatic int op_getprecision();
- Xstatic int op_isoperator();
- Xstatic int op_pulldown();
- X#endif /* ANSI_C for prototypes */
- X
- Xstatic int op_level;
- X
- X/***************************************************************
- X
- X FUNCTION: exp_operation()
- X
- X DESCRIPTION: This function performs whatever operations
- X are necessary at the end of function bwb_exp()
- X (i.e., the end of the parsing of an expression;
- X see file bwb_exp.c).
- X
- X***************************************************************/
- X
- X#if ANSI_C
- Xint
- Xexp_operation( int entry_level )
- X#else
- Xint
- Xexp_operation( entry_level )
- X int entry_level;
- X#endif
- X {
- X register int precedence;
- X int operator;
- X
- X#if INTENSIVE_DEBUG
- X sprintf( bwb_ebuf, "in exp_operation(): entered function." );
- X bwb_debug( bwb_ebuf );
- X#endif
- X
- X /* cycle through all levels of precedence and perform required
- X operations */
- X
- X for ( precedence = 0; precedence <= MAX_PRECEDENCE; ++precedence )
- X {
- X
- X /* Operation loop: cycle through every level above entry level
- X and perform required operations as needed */
- X
- X op_level = entry_level + 1;
- X while( ( op_level < CURTASK expsc )
- X && ( op_isoperator( CURTASK exps[ op_level ].operation ) == FALSE ))
- X {
- X ++op_level;
- X }
- X
- X while ( ( op_level > entry_level ) && ( op_level < CURTASK expsc ) )
- X {
- X
- X /* see if the operation at this level is an operator with the
- X appropriate precedence level by running through the table
- X of operators */
- X
- X for ( operator = 0; operator < N_OPERATORS; ++operator )
- X {
- X
- X if ( exp_ops[ operator ].operation == CURTASK exps[ op_level ].operation )
- X {
- X
- X /* check for appropriate level of precedence */
- X
- X if ( exp_ops[ operator ].precedence == precedence )
- X {
- X
- X#if INTENSIVE_DEBUG
- X sprintf( bwb_ebuf, "in exp_operation(): level <%d> operation <%d>",
- X op_level, CURTASK exps[ op_level ].operation );
- X bwb_debug( bwb_ebuf );
- X#endif
- X
- X op_oplevel( op_level ); /* perform the operation */
- X
- X }
- X }
- X }
- X
- X /* advance level if appropriate; one must check, however, since
- X the op_oplevel() function may have decremented CURTASK expsc */
- X
- X if ( op_level < CURTASK expsc )
- X {
- X ++op_level;
- X
- X#if INTENSIVE_DEBUG
- X sprintf( bwb_ebuf, "in exp_operation() first increment op_level to <%d>",
- X op_level );
- X bwb_debug( bwb_ebuf );
- X#endif
- X
- X while ( ( op_isoperator( CURTASK exps [ op_level ].operation ) == FALSE )
- X && ( op_level < CURTASK expsc ) )
- X {
- X ++op_level;
- X
- X#if INTENSIVE_DEBUG
- X sprintf( bwb_ebuf, "in exp_operation() further increment op_level to <%d>",
- X op_level );
- X bwb_debug( bwb_ebuf );
- X#endif
- X
- X }
- X } /* end of increment of op_level */
- X
- X } /* end of for loop for stack levels */
- X
- X } /* end of for loop for precedence levels */
- X
- X return TRUE;
- X
- X } /* end of function exp_operation() */
- X
- X
- X/***************************************************************
- X
- X FUNCTION: op_oplevel()
- X
- X DESCRIPTION: This function performs a specific operation
- X at a specific level as the expression parser
- X resolves its arguments.
- X
- X***************************************************************/
- X
- X#if ANSI_C
- Xstatic int
- Xop_oplevel( int level )
- X#else
- Xstatic int
- Xop_oplevel( level )
- X int level;
- X#endif
- X {
- X int precision;
- X
- X /* set the precision */
- X
- X if ( ( precision = op_getprecision( level ) ) == OP_ERROR )
- X {
- X#if PROG_ERRORS
- X sprintf( bwb_ebuf, "exp_operation(): failed to set precision." );
- X bwb_error( bwb_ebuf );
- X#else
- X bwb_error( err_mismatch ); /*** ??? ***/
- X#endif
- X op_pulldown( 2 );
- X }
- X
- X /* precision is set correctly */
- X
- X else
- X {
- X#if INTENSIVE_DEBUG
- X sprintf( bwb_ebuf, "in op_oplevel(): level <%d>, precision <%c>",
- X level, precision );
- X bwb_debug( bwb_ebuf );
- X#endif
- X
- X switch ( CURTASK exps[ level ].operation )
- X {
- X case OP_ADD:
- X op_add( level, precision );
- X break;
- X
- X case OP_SUBTRACT:
- X op_subtract( level, precision );
- X break;
- X
- X case OP_MULTIPLY:
- X op_multiply( level, precision );
- X break;
- X
- X case OP_DIVIDE:
- X op_divide( level, precision );
- X break;
- X
- X case OP_ASSIGN:
- X op_assign( level, precision );
- X break;
- X
- X case OP_EQUALS:
- X op_equals( level, precision );
- X break;
- X
- X case OP_LESSTHAN:
- X op_lessthan( level, precision );
- X break;
- X
- X case OP_GREATERTHAN:
- X op_greaterthan( level, precision );
- X break;
- X
- X case OP_LTEQ:
- X op_lteq( level, precision );
- X break;
- X
- X case OP_GTEQ:
- X op_gteq( level, precision );
- X break;
- X
- X case OP_NOTEQUAL:
- X op_notequal( level, precision );
- X break;
- X
- X case OP_MODULUS:
- X op_modulus( level, precision );
- X break;
- X
- X case OP_INTDIVISION:
- X op_intdiv( level, precision );
- X break;
- X
- X case OP_OR:
- X op_or( level, precision );
- X break;
- X
- X case OP_AND:
- X op_and( level, precision );
- X break;
- X
- X case OP_NOT:
- X op_not( level, precision );
- X break;
- X
- X case OP_XOR:
- X op_xor( level, precision );
- X break;
- X
- X case OP_EXPONENT:
- X op_exponent( level, precision );
- X break;
- X
- X default:
- X#if PROG_ERRORS
- X sprintf( bwb_ebuf, "PROGRAMMING ERROR: operator <%d> not (yet) supported.", CURTASK exps[ level ].operation );
- X op_pulldown( 2 );
- X bwb_error( bwb_ebuf );
- X#else
- X bwb_error( err_syntax );
- X#endif
- X break;
- X } /* end of case statement for operators */
- X } /* end of else statement, precision set */
- X
- X return TRUE;
- X
- X } /* end of function op_oplevel() */
- X
- X/***************************************************************
- X
- X FUNCTION: op_isoperator()
- X
- X DESCRIPTION: This function detects whether its argument
- X is an operator.
- X
- X***************************************************************/
- X
- X#if ANSI_C
- Xstatic int
- Xop_isoperator( int operation )
- X#else
- Xstatic int
- Xop_isoperator( operation )
- X int operation;
- X#endif
- X {
- X register int c;
- X
- X for( c = 0; c < N_OPERATORS; ++c )
- X {
- X if ( operation == exp_ops[ c ].operation )
- X {
- X
- X#if INTENSIVE_DEBUG
- X sprintf( bwb_ebuf, "in op_isoperator(): found match <%s>",
- X exp_ops[ c ].symbol );
- X bwb_debug( bwb_ebuf );
- X#endif
- X
- X return TRUE;
- X }
- X }
- X
- X /* test failed; return FALSE */
- X
- X#if INTENSIVE_DEBUG
- X sprintf( bwb_ebuf, "in op_isoperator(): no match found for operation <%d>",
- X operation );
- X bwb_debug( bwb_ebuf );
- X#endif
- X
- X return FALSE;
- X
- X }
- X
- X/***************************************************************
- X
- X FUNCTION: op_add()
- X
- X DESCRIPTION: This function adds two numbers or
- X concatenates two strings.
- X
- X***************************************************************/
- X
- X#if ANSI_C
- Xstatic int
- Xop_add( int level, int precision )
- X#else
- Xstatic int
- Xop_add( level, precision )
- X int level;
- X int precision;
- X#endif
- X {
- X int error_condition;
- X
- X error_condition = FALSE;
- X
- X switch( precision )
- X {
- X case STRING:
- X
- X /* both sides of the operation should be strings for
- X string addition; if not, report an error */
- X
- X if ( ( op_islevelstr( level - 1 ) != TRUE )
- X || ( op_islevelstr( level + 1 ) != TRUE ) )
- X {
- X#if PROG_ERRORS
- X sprintf( bwb_ebuf, "in op_add(): Type mismatch in string addition." );
- X bwb_error( bwb_ebuf );
- X#else
- X bwb_error( err_mismatch );
- X#endif
- X error_condition = TRUE;
- X }
- X
- X /* concatenate the two strings */
- X
- X if ( error_condition == FALSE )
- X {
- X
- X#if INTENSIVE_DEBUG
- X sprintf( bwb_ebuf, "in op_add(): try exp_getsval(), level <%d> op <%d> type <%c>:",
- X level - 1, CURTASK exps[ level - 1 ].operation, CURTASK exps[ level - 1 ].type );
- X bwb_debug( bwb_ebuf );
- X exp_getsval( &( CURTASK exps[ level - 1 ] ));
- X sprintf( bwb_ebuf, "in op_add(): try exp_getsval(), level <%d> op <%d> type <%c>:",
- X level + 1, CURTASK exps[ level + 1 ].operation, CURTASK exps[ level + 1 ].type );
- X bwb_debug( bwb_ebuf );
- X exp_getsval( &( CURTASK exps[ level + 1 ] ));
- X sprintf( bwb_ebuf, "in op_add(): string addition, exp_getsval()s completed" );
- X bwb_debug( bwb_ebuf );
- X#endif
- X
- X str_cat( exp_getsval( &( CURTASK exps[ level - 1 ] ) ),
- X exp_getsval( &( CURTASK exps[ level + 1 ] ) ) );
- X
- X#if INTENSIVE_DEBUG
- X sprintf( bwb_ebuf, "in op_add(): str_cat() returns <%d>-byte string to level <%d>",
- X exp_getsval( &( CURTASK exps[ level - 1 ] ) )->length, level - 1 );
- X bwb_debug( bwb_ebuf );
- X#endif
- X }
- X
- X break;
- X
- X case NUMBER:
- X CURTASK exps[ level - 1 ].nval
- X = exp_getnval( &( CURTASK exps[ level - 1 ] ))
- X + exp_getnval( &( CURTASK exps[ level + 1 ] ));
- X CURTASK exps[ level - 1 ].operation = NUMBER;
- X break;
- X
- X }
- X
- X /* set variable to requested precision */
- X
- X CURTASK exps[ level - 1 ].type = (char) precision;
- X
- X#if INTENSIVE_DEBUG
- X sprintf( bwb_ebuf, "in op_add() returns with operation <%d> type <%c>",
- X CURTASK exps[ level - 1 ].operation, CURTASK exps[ level - 1 ].type );
- X bwb_debug( bwb_ebuf );
- X#endif
- X
- X /* decrement the stack twice */
- X
- X op_pulldown( 2 );
- X
- X return TRUE;
- X
- X }
- X
- X/***************************************************************
- X
- X FUNCTION: op_subtract()
- X
- X DESCRIPTION: This function subtracts the number on
- X the left from the number on the right.
- X
- X***************************************************************/
- X
- X#if ANSI_C
- Xstatic int
- Xop_subtract( int level, int precision )
- X#else
- Xstatic int
- Xop_subtract( level, precision )
- X int level;
- X int precision;
- X#endif
- X {
- X
- X switch( precision )
- X {
- X case STRING:
- X
- X /* both sides of the operation should be numbers for
- X string addition; if not, report an error */
- X
- X#if PROG_ERRORS
- X sprintf( bwb_ebuf, "Strings cannot be subtracted." );
- X bwb_error( bwb_ebuf );
- X#else
- X bwb_error( err_mismatch );
- X#endif
- X
- X break;
- X
- X case NUMBER:
- X CURTASK exps[ level - 1 ].nval
- X = exp_getnval( &( CURTASK exps[ level - 1 ] ))
- X - exp_getnval( &( CURTASK exps[ level + 1 ] ));
- X break;
- X
- X }
- X
- X /* set variable to requested precision */
- X
- X CURTASK exps[ level - 1 ].type = (char) precision;
- X CURTASK exps[ level - 1 ].operation = NUMBER;
- X
- X /* decrement the stack twice */
- X
- X op_pulldown( 2 );
- X
- X return TRUE;
- X
- X }
- X
- X/***************************************************************
- X
- X FUNCTION: op_multiply()
- X
- X DESCRIPTION: This function multiplies the number on
- X the left by the number on the right.
- X
- X***************************************************************/
- X
- X#if ANSI_C
- Xstatic int
- Xop_multiply( int level, int precision )
- X#else
- Xstatic int
- Xop_multiply( level, precision )
- X int level;
- X int precision;
- X#endif
- X {
- X
- X switch( precision )
- X {
- X case STRING:
- X
- X /* both sides of the operation should be numbers for
- X string addition; if not, report an error */
- X
- X#if PROG_ERRORS
- X sprintf( bwb_ebuf, "Strings cannot be multiplied." );
- X bwb_error( bwb_ebuf );
- X#else
- X bwb_error( err_mismatch );
- X#endif
- X
- X break;
- X
- X case NUMBER:
- X CURTASK exps[ level - 1 ].nval
- X = exp_getnval( &( CURTASK exps[ level - 1 ] ))
- X * exp_getnval( &( CURTASK exps[ level + 1 ] ));
- X break;
- X
- X }
- X
- X /* set variable to requested precision */
- X
- X CURTASK exps[ level - 1 ].type = (char) precision;
- X CURTASK exps[ level - 1 ].operation = NUMBER;
- X
- X /* decrement the stack twice */
- X
- X op_pulldown( 2 );
- X
- X return TRUE;
- X
- X }
- X
- X/***************************************************************
- X
- X FUNCTION: op_divide()
- X
- X DESCRIPTION: This function divides the number on
- X the left by the number on the right.
- X
- X***************************************************************/
- X
- X#if ANSI_C
- Xstatic int
- Xop_divide( int level, int precision )
- X#else
- Xstatic int
- Xop_divide( level, precision )
- X int level;
- X int precision;
- X#endif
- X {
- X
- X switch( precision )
- X {
- X case STRING:
- X
- X /* both sides of the operation should be numbers for
- X division; if not, report an error */
- X
- X#if PROG_ERRORS
- X sprintf( bwb_ebuf, "Strings cannot be divided." );
- X bwb_error( bwb_ebuf );
- X#else
- X bwb_error( err_mismatch );
- X#endif
- X
- X break;
- X
- X case NUMBER:
- X if ( exp_getnval( &( CURTASK exps[ level + 1 ] ))
- X == (bnumber) 0 )
- X {
- X CURTASK exps[ level - 1 ].nval = (bnumber) -1.0;
- X op_pulldown( 2 );
- X#if PROG_ERRORS
- X sprintf( bwb_ebuf, "Divide by 0." );
- X bwb_error( bwb_ebuf );
- X#else
- X bwb_error( err_dbz );
- X#endif
- X return FALSE;
- X }
- X CURTASK exps[ level - 1 ].nval
- X = exp_getnval( &( CURTASK exps[ level - 1 ] ))
- X / exp_getnval( &( CURTASK exps[ level + 1 ] ));
- X break;
- X }
- X
- X /* set variable to requested precision */
- X
- X CURTASK exps[ level - 1 ].type = (char) precision;
- X CURTASK exps[ level - 1 ].operation = NUMBER;
- X
- X /* decrement the stack twice */
- X
- X op_pulldown( 2 );
- X
- X return TRUE;
- X
- X }
- X
- X/***************************************************************
- X
- X FUNCTION: op_assign()
- X
- X DESCRIPTION: This function assigns the value in the
- X right hand side to the variable in the
- X left hand side.
- X
- X***************************************************************/
- X
- X#if ANSI_C
- Xstatic int
- Xop_assign( int level, int precision )
- X#else
- Xstatic int
- Xop_assign( level, precision )
- X int level;
- X int precision;
- X#endif
- X {
- X
- X /* Make sure the position one level below is a variable */
- X
- X if ( CURTASK exps[ level - 1 ].operation != VARIABLE )
- X {
- X op_pulldown( 2 );
- X#if PROG_ERRORS
- X sprintf( bwb_ebuf, "in op_assign(): Assignment must be to variable: level -1 <%d> op <%d>",
- X level - 1, CURTASK exps[ level - 1 ].operation );
- X bwb_error( bwb_ebuf );
- X#else
- X bwb_error( err_syntax );
- X#endif
- X return FALSE;
- X }
- X
- X#if INTENSIVE_DEBUG
- X sprintf( bwb_ebuf, "in op_assign(): entered function level <%d>",
- X level );
- X bwb_debug( bwb_ebuf );
- X#endif
- X
- X /* if the assignment is numerical, then the precision should be set
- X to that of the variable on the left-hand side of the assignment */
- X
- X if ( precision != STRING )
- X {
- X precision = (int) CURTASK exps[ level - 1 ].type;
- X }
- X
- X switch( precision )
- X {
- X case STRING:
- X
- X#if INTENSIVE_DEBUG
- X sprintf( bwb_ebuf, "in op_assign(): try exp_getsval(), level <%d> op <%d> type <%c>:",
- X level - 1, CURTASK exps[ level - 1 ].operation, CURTASK exps[ level - 1 ].type );
- X bwb_debug( bwb_ebuf );
- X exp_getsval( &( CURTASK exps[ level - 1 ] ));
- X sprintf( bwb_ebuf, "in op_assign(): try exp_getsval(), level <%d> op <%d> type <%c>:",
- X level + 1, CURTASK exps[ level + 1 ].operation, CURTASK exps[ level + 1 ].type );
- X bwb_debug( bwb_ebuf );
- X exp_getsval( &( CURTASK exps[ level + 1 ] ));
- X sprintf( bwb_ebuf, "in op_assign(): string addition, exp_getsval()s completed" );
- X bwb_debug( bwb_ebuf );
- X#endif
- X
- X str_btob( exp_getsval( &( CURTASK exps[ level - 1 ] )),
- X exp_getsval( &( CURTASK exps[ level + 1 ] )) );
- X break;
- X
- X case NUMBER:
- X * var_findnval( CURTASK exps[ level - 1 ].xvar,
- X CURTASK exps[ level - 1 ].array_pos ) =
- X CURTASK exps[ level - 1 ].nval =
- X exp_getnval( &( CURTASK exps[ level + 1 ] ) );
- X break;
- X
- X default:
- X#if PROG_ERRORS
- X sprintf( bwb_ebuf, "in op_assign(): Variable before assignment operator has unidentified type." );
- X bwb_error( bwb_ebuf );
- X#else
- X bwb_error( err_mismatch );
- X#endif
- X return FALSE;
- X
- X }
- X
- X /* set variable to requested precision */
- X
- X CURTASK exps[ level - 1 ].type = (char) precision;
- X
- X /* decrement the stack twice */
- X
- X op_pulldown( 2 );
- X
- X return TRUE;
- X
- X }
- X
- X/***************************************************************
- X
- X FUNCTION: op_equals()
- X
- X DESCRIPTION: This function compares two values and
- X returns an integer value: TRUE if they are
- X the same and FALSE if they are not.
- X
- X***************************************************************/
- X
- X#if ANSI_C
- Xstatic int
- Xop_equals( int level, int precision )
- X#else
- Xstatic int
- Xop_equals( level, precision )
- X int level;
- X int precision;
- X#endif
- X {
- X int error_condition;
- X static bstring b;
- X bstring *bp;
- X
- X error_condition = FALSE;
- X b.rab = FALSE;
- X
- X switch( precision )
- X {
- X case STRING:
- X
- X /* both sides of the operation should be strings for
- X string addition; if not, report an error */
- X
- X if ( ( op_islevelstr( level - 1 ) != TRUE )
- X || ( op_islevelstr( level + 1 ) != TRUE ) )
- X {
- X#if PROG_ERRORS
- X sprintf( bwb_ebuf, "in op_equals(): Type mismatch in string comparison." );
- X bwb_error( bwb_ebuf );
- X#else
- X bwb_error( err_mismatch );
- X#endif
- X error_condition = TRUE;
- X }
- X
- X /* compare the two strings */
- X
- X if ( error_condition == FALSE )
- X {
- X bp = exp_getsval( &( CURTASK exps[ level - 1 ] ));
- X#if OLDWAY
- X b.length = bp->length;
- X b.sbuffer = bp->sbuffer;
- X#endif
- X str_btob( &b, bp );
- X
- X if ( str_cmp( &b,
- X exp_getsval( &( CURTASK exps[ level + 1 ] )) ) == 0 )
- X {
- X CURTASK exps[ level - 1 ].nval = (bnumber) TRUE;
- X }
- X else
- X {
- X CURTASK exps[ level - 1 ].nval = (bnumber) FALSE;
- X }
- X }
- X break;
- X
- X case NUMBER:
- X if ( exp_getnval( &( CURTASK exps[ level - 1 ] ))
- X == exp_getnval( &( CURTASK exps[ level + 1 ] )) )
- X {
- X CURTASK exps[ level - 1 ].nval = (bnumber) TRUE;
- X }
- X else
- X {
- X CURTASK exps[ level - 1 ].nval = (bnumber) FALSE;
- X }
- X break;
- X
- X }
- X
- X /* set variable to integer and operation to NUMBER:
- X this must be done at the end, since at the beginning it
- X might cause op_islevelstr() to return a false error */
- X
- X CURTASK exps[ level - 1 ].type = NUMBER;
- X CURTASK exps[ level - 1 ].operation = NUMBER;
- X
- X /* decrement the stack */
- X
- X op_pulldown( 2 );
- X
- X return TRUE;
- X
- X }
- X
- X/***************************************************************
- X
- X FUNCTION: op_lessthan()
- X
- X DESCRIPTION: This function compares two values and
- X returns an integer value: TRUE if the
- X left hand value is less than the right,
- X and FALSE if it is not.
- X
- X***************************************************************/
- X
- X#if ANSI_C
- Xstatic int
- Xop_lessthan( int level, int precision )
- X#else
- Xstatic int
- Xop_lessthan( level, precision )
- X int level;
- X int precision;
- X#endif
- X {
- X int error_condition;
- X
- X error_condition = FALSE;
- X
- X switch( precision )
- X {
- X case STRING:
- X
- X /* both sides of the operation should be numbers for
- X string addition; if not, report an error */
- X
- X if ( ( op_islevelstr( level - 1 ) != TRUE )
- X || ( op_islevelstr( level + 1 ) != TRUE ) )
- X {
- X#if PROG_ERRORS
- X sprintf( bwb_ebuf, "Type mismatch in string comparison." );
- X bwb_error( bwb_ebuf );
- X#else
- X bwb_error( err_mismatch );
- X#endif
- X error_condition = TRUE;
- X }
- X
- X /* compare the two strings */
- X
- X if ( error_condition == FALSE )
- X {
- X if ( str_cmp( exp_getsval( &( CURTASK exps[ level - 1 ] )),
- X exp_getsval( &( CURTASK exps[ level + 1 ] )) ) < 0 )
- X {
- X CURTASK exps[ level - 1 ].nval = (bnumber) TRUE;
- X }
- X else
- X {
- X CURTASK exps[ level - 1 ].nval = (bnumber) FALSE;
- X }
- X }
- X break;
- X
- X case NUMBER:
- X if ( exp_getnval( &( CURTASK exps[ level - 1 ] ))
- X < exp_getnval( &( CURTASK exps[ level + 1 ] )) )
- X {
- X CURTASK exps[ level - 1 ].nval = (bnumber) TRUE;
- X }
- X else
- X {
- X CURTASK exps[ level - 1 ].nval = (bnumber) FALSE;
- X }
- X break;
- X
- X }
- X
- X /* set variable to integer and operation to NUMBER:
- X this must be done at the end, since at the beginning it
- X might cause op_islevelstr() to return a false error */
- X
- X CURTASK exps[ level - 1 ].type = NUMBER;
- X CURTASK exps[ level - 1 ].operation = NUMBER;
- X
- X /* decrement the stack */
- X
- X op_pulldown( 2 );
- X
- X return TRUE;
- X
- X }
- X
- X/***************************************************************
- X
- X FUNCTION: op_greaterthan()
- X
- X DESCRIPTION: This function compares two values and
- X returns an integer value: TRUE if the
- X left hand value is greater than the right,
- X and FALSE if it is not.
- X
- X***************************************************************/
- X
- X#if ANSI_C
- Xstatic int
- Xop_greaterthan( int level, int precision )
- X#else
- Xstatic int
- Xop_greaterthan( level, precision )
- X int level;
- X int precision;
- X#endif
- X {
- X int error_condition;
- X
- X error_condition = FALSE;
- X
- X switch( precision )
- X {
- X case STRING:
- X
- X /* both sides of the operation should be numbers for
- X string addition; if not, report an error */
- X
- X if ( ( op_islevelstr( level - 1 ) != TRUE )
- X || ( op_islevelstr( level + 1 ) != TRUE ) )
- X {
- X#if PROG_ERRORS
- X sprintf( bwb_ebuf, "Type mismatch in string comparison." );
- X bwb_error( bwb_ebuf );
- X#else
- X bwb_error( err_mismatch );
- X#endif
- X error_condition = TRUE;
- X }
- X
- X /* compare the two strings */
- X
- X if ( error_condition == FALSE )
- X {
- X if ( str_cmp( exp_getsval( &( CURTASK exps[ level - 1 ] )),
- X exp_getsval( &( CURTASK exps[ level + 1 ] )) ) > 0 )
- X {
- X CURTASK exps[ level - 1 ].nval = (bnumber) TRUE;
- X }
- X else
- X {
- X CURTASK exps[ level - 1 ].nval = (bnumber) FALSE;
- X }
- X }
- X break;
- X
- X case NUMBER:
- X if ( exp_getnval( &( CURTASK exps[ level - 1 ] ))
- X > exp_getnval( &( CURTASK exps[ level + 1 ] )) )
- X {
- X CURTASK exps[ level - 1 ].nval = (bnumber) TRUE;
- X }
- X else
- X {
- X CURTASK exps[ level - 1 ].nval = (bnumber) FALSE;
- X }
- X break;
- X
- X }
- X
- X /* set variable to integer and operation to NUMBER:
- X this must be done at the end, since at the beginning it
- X might cause op_islevelstr() to return a false error */
- X
- X CURTASK exps[ level - 1 ].type = NUMBER;
- X CURTASK exps[ level - 1 ].operation = NUMBER;
- X
- X /* decrement the stack */
- X
- X op_pulldown( 2 );
- X
- X return TRUE;
- X
- X }
- X
- X/***************************************************************
- X
- X FUNCTION: op_lteq()
- X
- X DESCRIPTION: This function compares two values and
- X returns an integer value: TRUE if the
- X left hand value is less than or equal
- X to the right, and FALSE if it is not.
- X
- X***************************************************************/
- X
- X#if ANSI_C
- Xstatic int
- Xop_lteq( int level, int precision )
- X#else
- Xstatic int
- Xop_lteq( level, precision )
- X int level;
- X int precision;
- X#endif
- X {
- X int error_condition;
- X
- X error_condition = FALSE;
- X
- X switch( precision )
- X {
- X case STRING:
- X
- X /* both sides of the operation should be numbers for
- X string addition; if not, report an error */
- X
- X if ( ( op_islevelstr( level - 1 ) != TRUE )
- X || ( op_islevelstr( level + 1 ) != TRUE ) )
- X {
- X#if PROG_ERRORS
- X sprintf( bwb_ebuf, "Type mismatch in string comparison." );
- X bwb_error( bwb_ebuf );
- X#else
- X bwb_error( err_mismatch );
- X#endif
- X error_condition = TRUE;
- X }
- X
- X /* compare the two strings */
- X
- X if ( error_condition == FALSE )
- X {
- X if ( str_cmp( exp_getsval( &( CURTASK exps[ level - 1 ] )),
- X exp_getsval( &( CURTASK exps[ level + 1 ] )) ) <= 0 )
- X {
- X CURTASK exps[ level - 1 ].nval = (bnumber) TRUE;
- X }
- X else
- X {
- X CURTASK exps[ level - 1 ].nval = (bnumber) FALSE;
- X }
- X }
- X break;
- X
- X case NUMBER:
- X if ( exp_getnval( &( CURTASK exps[ level - 1 ] ))
- X <= exp_getnval( &( CURTASK exps[ level + 1 ] )) )
- X {
- X CURTASK exps[ level - 1 ].nval = (bnumber) TRUE;
- X }
- X else
- X {
- X CURTASK exps[ level - 1 ].nval = (bnumber) FALSE;
- X }
- X break;
- X
- X }
- X
- X /* set variable to integer and operation to NUMBER:
- X this must be done at the end, since at the beginning it
- X might cause op_islevelstr() to return a false error */
- X
- X CURTASK exps[ level - 1 ].type = NUMBER;
- X CURTASK exps[ level - 1 ].operation = NUMBER;
- X
- X /* decrement the stack */
- X
- X op_pulldown( 2 );
- X
- X return TRUE;
- X
- X }
- X
- X/***************************************************************
- X
- X FUNCTION: op_gteq()
- X
- X DESCRIPTION: This function compares two values and
- X returns an integer value: TRUE if the
- X left hand value is greater than or equal
- X to the right, and FALSE if it is not.
- X
- X***************************************************************/
- X
- X#if ANSI_C
- Xstatic int
- Xop_gteq( int level, int precision )
- X#else
- Xstatic int
- Xop_gteq( level, precision )
- X int level;
- X int precision;
- X#endif
- X {
- X int error_condition;
- X
- X error_condition = FALSE;
- X
- X switch( precision )
- X {
- X case STRING:
- X
- X /* both sides of the operation should be numbers for
- X string addition; if not, report an error */
- X
- X if ( ( op_islevelstr( level - 1 ) != TRUE )
- X || ( op_islevelstr( level + 1 ) != TRUE ) )
- X {
- X#if PROG_ERRORS
- X sprintf( bwb_ebuf, "Type mismatch in string comparison." );
- X bwb_error( bwb_ebuf );
- X#else
- X bwb_error( err_mismatch );
- X#endif
- X error_condition = TRUE;
- X }
- X
- X /* compare the two strings */
- X
- X if ( error_condition == FALSE )
- X {
- X if ( str_cmp( exp_getsval( &( CURTASK exps[ level - 1 ] )),
- X exp_getsval( &( CURTASK exps[ level + 1 ] )) ) >= 0 )
- X {
- X CURTASK exps[ level - 1 ].nval = (bnumber) TRUE;
- X }
- X else
- X {
- X CURTASK exps[ level - 1 ].nval = (bnumber) FALSE;
- X }
- X }
- X break;
- X
- X case NUMBER:
- X if ( exp_getnval( &( CURTASK exps[ level - 1 ] ))
- X >= exp_getnval( &( CURTASK exps[ level + 1 ] )) )
- X {
- X CURTASK exps[ level - 1 ].nval = (bnumber) TRUE;
- X }
- X else
- X {
- X CURTASK exps[ level - 1 ].nval = (bnumber) FALSE;
- X }
- X break;
- X
- X }
- X
- X /* set variable to integer and operation to NUMBER:
- X this must be done at the end, since at the beginning it
- X might cause op_islevelstr() to return a false error */
- X
- X CURTASK exps[ level - 1 ].type = NUMBER;
- X CURTASK exps[ level - 1 ].operation = NUMBER;
- X
- X /* decrement the stack */
- X
- X op_pulldown( 2 );
- X
- X return TRUE;
- X
- X }
- X
- X/***************************************************************
- X
- X FUNCTION: op_notequal()
- X
- X DESCRIPTION: This function compares two values and
- X returns an integer value: TRUE if they
- X are not the same and FALSE if they are.
- X
- X***************************************************************/
- X
- X#if ANSI_C
- Xstatic int
- Xop_notequal( int level, int precision )
- X#else
- Xstatic int
- Xop_notequal( level, precision )
- X int level;
- X int precision;
- X#endif
- X {
- X int error_condition;
- X
- X error_condition = FALSE;
- X
- X switch( precision )
- X {
- X case STRING:
- X
- X /* both sides of the operation should be numbers for
- X string addition; if not, report an error */
- X
- X if ( ( op_islevelstr( level - 1 ) != TRUE )
- X || ( op_islevelstr( level + 1 ) != TRUE ) )
- X {
- X#if PROG_ERRORS
- X sprintf( bwb_ebuf, "Type mismatch in string comparison." );
- X bwb_error( bwb_ebuf );
- X#else
- X bwb_error( err_mismatch );
- X#endif
- X error_condition = TRUE;
- X }
- X
- X /* compare the two strings */
- X
- X if ( error_condition == FALSE )
- X
- X {
- X if ( str_cmp( exp_getsval( &( CURTASK exps[ level - 1 ] )),
- X exp_getsval( &( CURTASK exps[ level + 1 ] )) ) != 0 )
- X {
- X CURTASK exps[ level - 1 ].nval = (bnumber) TRUE;
- X }
- X else
- X {
- X CURTASK exps[ level - 1 ].nval = (bnumber) FALSE;
- X }
- X }
- X break;
- X
- X case NUMBER:
- X if ( exp_getnval( &( CURTASK exps[ level - 1 ] ))
- X != exp_getnval( &( CURTASK exps[ level + 1 ] )) )
- X {
- X CURTASK exps[ level - 1 ].nval = (bnumber) TRUE;
- X }
- X else
- X {
- X CURTASK exps[ level - 1 ].nval = (bnumber) FALSE;
- X }
- X break;
- X
- X }
- X
- X /* set variable to integer and operation to NUMBER:
- X this must be done at the end, since at the beginning it
- X might cause op_islevelstr() to return a false error */
- X
- X CURTASK exps[ level - 1 ].type = NUMBER;
- X CURTASK exps[ level - 1 ].operation = NUMBER;
- X
- X /* decrement the stack */
- X
- X op_pulldown( 2 );
- X
- X return TRUE;
- X
- X }
- X
- X/***************************************************************
- X
- X FUNCTION: op_modulus()
- X
- X DESCRIPTION: This function divides the number on
- X the left by the number on the right
- X and returns the remainder.
- X
- X***************************************************************/
- X
- X#if ANSI_C
- Xstatic int
- Xop_modulus( int level, int precision )
- X#else
- Xstatic int
- Xop_modulus( level, precision )
- X int level;
- X int precision;
- X#endif
- X {
- X static double iportion;
- X
- X switch( precision )
- X {
- X case STRING:
- X
- X /* both sides of the operation should be numbers for
- X string addition; if not, report an error */
- X
- X#if PROG_ERRORS
- X sprintf( bwb_ebuf, "Strings cannot be divided." );
- X bwb_error( bwb_ebuf );
- X#else
- X bwb_error( err_syntax );
- X#endif
- X
- X break;
- X
- X case NUMBER:
- X if ( exp_getnval( &( CURTASK exps[ level + 1 ] ))
- X == (bnumber) 0 )
- X {
- X CURTASK exps[ level - 1 ].nval = (bnumber) -1;
- X op_pulldown( 2 );
- X#if PROG_ERRORS
- X sprintf( bwb_ebuf, "Divide by 0." );
- X bwb_error( bwb_ebuf );
- X#else
- X bwb_error( err_dbz );
- X#endif
- X return FALSE;
- X }
- X CURTASK exps[ level ].nval
- X = exp_getnval( &( CURTASK exps[ level - 1 ] ))
- X / exp_getnval( &( CURTASK exps[ level + 1 ] ));
- X modf( (double) CURTASK exps[ level ].nval, &iportion );
- X CURTASK exps[ level - 1 ].nval
- X = exp_getnval( &( CURTASK exps[ level - 1 ] ))
- X - ( exp_getnval( &( CURTASK exps[ level + 1 ] ))
- X * iportion );
- X break;
- X
- X }
- X
- X /* set variable to requested precision */
- X
- X CURTASK exps[ level - 1 ].type = (char) precision;
- X CURTASK exps[ level - 1 ].operation = NUMBER;
- X
- X /* decrement the stack twice */
- X
- X op_pulldown( 2 );
- X
- X return TRUE;
- X
- X }
- X
- X/***************************************************************
- X
- X FUNCTION: op_exponent()
- X
- X DESCRIPTION: This function finds the exponential value
- X of a number (on the left) to the power
- X indicated on the right-hand side.
- X
- X***************************************************************/
- X
- X#if ANSI_C
- Xstatic int
- Xop_exponent( int level, int precision )
- X#else
- Xstatic int
- Xop_exponent( level, precision )
- X int level;
- X int precision;
- X#endif
- X {
- X
- X#if INTENSIVE_DEBUG
- X sprintf( bwb_ebuf, "in op_exponent(): entered function level <%d>.",
- X level );
- X bwb_debug ( bwb_ebuf );
- X#endif
- X
- X switch( precision )
- X {
- X case STRING:
- X
- X /* both sides of the operation should be numbers for
- X string addition; if not, report an error */
- X
- X#if PROG_ERRORS
- X sprintf( bwb_ebuf, "Strings cannot be taken as exponents." );
- X bwb_error( bwb_ebuf );
- X#else
- X bwb_error( err_mismatch );
- X#endif
- X
- X break;
- X
- X case NUMBER:
- X CURTASK exps[ level - 1 ].nval
- X = (bnumber) pow( (double) exp_getnval( &( CURTASK exps[ level - 1 ] )),
- X (double) exp_getnval( &( CURTASK exps[ level + 1 ] )) );
- X break;
- X
- X }
- X
- X /* set variable to requested precision */
- X
- X CURTASK exps[ level - 1 ].type = (char) precision;
- X CURTASK exps[ level - 1 ].operation = NUMBER;
- X
- X /* decrement the stack twice */
- X
- X op_pulldown( 2 );
- X
- X return TRUE;
- X
- X }
- X
- X/***************************************************************
- X
- X FUNCTION: op_intdiv()
- X
- X DESCRIPTION: This function divides the number on
- X the left by the number on the right,
- X returning the result as an integer.
- X
- X***************************************************************/
- X
- X#if ANSI_C
- Xstatic int
- Xop_intdiv( int level, int precision )
- X#else
- Xstatic int
- Xop_intdiv( level, precision )
- X int level;
- X int precision;
- X#endif
- X {
- X
- X switch( precision )
- X {
- X case STRING:
- X
- X /* both sides of the operation should be numbers for
- X string addition; if not, report an error */
- X
- X#if PROG_ERRORS
- X sprintf( bwb_ebuf, "Strings cannot be divided." );
- X bwb_error( bwb_ebuf );
- X#else
- X bwb_error( err_mismatch );
- X#endif
- X
- X break;
- X
- X default:
- X if ( exp_getnval( &( CURTASK exps[ level + 1 ] ))
- X == (bnumber) 0 )
- X {
- X CURTASK exps[ level - 1 ].nval = (bnumber) -1;
- X op_pulldown( 2 );
- X#if PROG_ERRORS
- X sprintf( bwb_ebuf, "Divide by 0." );
- X bwb_error( bwb_ebuf );
- X#else
- X bwb_error( err_dbz );
- X#endif
- X return FALSE;
- X }
- X
- X CURTASK exps[ level - 1 ].nval
- X = exp_getnval( &( CURTASK exps[ level - 1 ] ))
- X / exp_getnval( &( CURTASK exps[ level + 1 ] ));
- X break;
- X }
- X
- X /* set variable to requested precision */
- X
- X CURTASK exps[ level - 1 ].type = NUMBER;
- X CURTASK exps[ level - 1 ].operation = NUMBER;
- X
- X /* decrement the stack twice */
- X
- X op_pulldown( 2 );
- X
- X return TRUE;
- X
- X }
- X
- X/***************************************************************
- X
- X FUNCTION: op_or()
- X
- X DESCRIPTION: This function compares two integers and
- X performs a logical NOT on them.
- X
- X***************************************************************/
- X
- X#if ANSI_C
- Xstatic int
- Xop_or( int level, int precision )
- X#else
- Xstatic int
- Xop_or( level, precision )
- X int level;
- X int precision;
- X#endif
- X {
- X
- X switch( precision )
- X {
- X case STRING:
- X
- X /* both sides of the operation should be numbers for
- X logical comparison; if not, report an error */
- X
- X#if PROG_ERRORS
- X sprintf( bwb_ebuf, "Strings cannot be compared logically." );
- X bwb_error( bwb_ebuf );
- X#else
- X bwb_error( err_mismatch );
- X#endif
- X
- X break;
- X
- X case NUMBER:
- X CURTASK exps[ level - 1 ].nval
- X = (bnumber) ((int) exp_getnval( &( CURTASK exps[ level - 1 ] ))
- X | (int) exp_getnval( &( CURTASK exps[ level + 1 ] )));
- X break;
- X
- X }
- X
- X /* set variable type to integer */
- X
- X CURTASK exps[ level - 1 ].type = NUMBER;
- X CURTASK exps[ level - 1 ].operation = NUMBER;
- X
- X /* decrement the stack twice */
- X
- X op_pulldown( 2 );
- X
- X return TRUE;
- X
- X }
- X
- X/***************************************************************
- X
- X FUNCTION: op_and()
- X
- X DESCRIPTION: This function compares two integers and
- X performs a logical NOT on them.
- X
- X***************************************************************/
- X
- X#if ANSI_C
- Xstatic int
- Xop_and( int level, int precision )
- X#else
- Xstatic int
- Xop_and( level, precision )
- X int level;
- X int precision;
- X#endif
- X {
- X
- X switch( precision )
- X {
- X case STRING:
- X
- X
- X /* both sides of the operation should be numbers for
- X logical comparison; if not, report an error */
- X
- X#if PROG_ERRORS
- X sprintf( bwb_ebuf, "Strings cannot be compared logically." );
- X bwb_error( bwb_ebuf );
- X#else
- X bwb_error( err_mismatch );
- X#endif
- X
- X break;
- X
- X case NUMBER:
- X CURTASK exps[ level - 1 ].nval
- X = (bnumber) ((int) exp_getnval( &( CURTASK exps[ level - 1 ] ))
- X & (int) exp_getnval( &( CURTASK exps[ level + 1 ] )));
- X break;
- X
- X }
- X
- X /* set variable type to integer */
- X
- X CURTASK exps[ level - 1 ].type = NUMBER;
- X CURTASK exps[ level - 1 ].operation = NUMBER;
- X
- X /* decrement the stack twice */
- X
- X op_pulldown( 2 );
- X
- X return TRUE;
- X
- X }
- X
- X/***************************************************************
- X
- X FUNCTION: op_not()
- X
- X DESCRIPTION: This function compares two integers and
- X performs a logical NOT on them.
- X
- X***************************************************************/
- X
- X#if ANSI_C
- Xstatic int
- Xop_not( int level, int precision )
- X#else
- Xstatic int
- Xop_not( level, precision )
- X int level;
- X int precision;
- X#endif
- X {
- X
- X switch( precision )
- X {
- X case STRING:
- X
- X
- X /* both sides of the operation should be numbers for
- X logical comparison; if not, report an error */
- X
- X#if PROG_ERRORS
- X sprintf( bwb_ebuf, "Strings cannot be compared logically." );
- X bwb_error( bwb_ebuf );
- X#else
- X bwb_error( err_mismatch );
- X#endif
- X
- X break;
- X
- X default:
- X
- X#if INTENSIVE_DEBUG
- X sprintf( bwb_ebuf, "in op_not(): argument is <%d>, precision <%c>",
- X (unsigned int) exp_getnval( &( CURTASK exps[ level + 1 ] )), precision );
- X bwb_debug( bwb_ebuf );
- X#endif
- X
- X CURTASK exps[ level ].nval = (bnumber)
- X ~( (int) exp_getnval( &( CURTASK exps[ level + 1 ] )) );
- X
- X#if INTENSIVE_DEBUG
- X sprintf( bwb_ebuf, "in op_not(): result is <%d>, precision <%c>",
- X (int) r, precision );
- X bwb_debug( bwb_ebuf );
- X#endif
- X
- X break;
- X }
- X
- X /* set variable type to integer */
- X
- X CURTASK exps[ level ].type = NUMBER;
- X CURTASK exps[ level ].operation = NUMBER;
- X
- X /* decrement the stack once */
- X
- X op_pulldown( 1 );
- X
- X#if INTENSIVE_DEBUG
- X sprintf( bwb_ebuf, "in op_not(): CURTASK expsc <%d>, level <%d> result <%d>",
- X CURTASK expsc, level, CURTASK exps[ CURTASK expsc ].nval );
- X bwb_debug( bwb_ebuf );
- X#endif
- X
- X return TRUE;
- X
- X }
- X
- X/***************************************************************
- X
- X FUNCTION: op_xor()
- X
- X DESCRIPTION: This function compares two integers and
- X performs a logical NOT on them.
- X
- X***************************************************************/
- X
- X#if ANSI_C
- Xstatic int
- Xop_xor( int level, int precision )
- X#else
- Xstatic int
- Xop_xor( level, precision )
- X int level;
- X int precision;
- X#endif
- X {
- X
- X switch( precision )
- X {
- X case STRING:
- X
- X /* both sides of the operation should be numbers for
- X logical comparison; if not, report an error */
- X
- X#if PROG_ERRORS
- X sprintf( bwb_ebuf, "Strings cannot be compared logically." );
- X bwb_error( bwb_ebuf );
- X#else
- X bwb_error( err_mismatch );
- X#endif
- X
- X break;
- X
- X case NUMBER:
- X CURTASK exps[ level - 1 ].nval
- X = (bnumber) ((int) exp_getnval( &( CURTASK exps[ level - 1 ] ))
- X ^ (int) exp_getnval( &( CURTASK exps[ level + 1 ] )));
- X break;
- X
- X }
- X
- X /* set variable type to integer */
- X
- X CURTASK exps[ level - 1 ].type = NUMBER;
- X CURTASK exps[ level - 1 ].operation = NUMBER;
- X
- X /* decrement the stack twice */
- X
- X op_pulldown( 2 );
- X
- X return TRUE;
- X
- X }
- X
- X/***************************************************************
- X
- X FUNCTION: op_islevelstr()
- X
- X DESCRIPTION: This function determines whether the
- X operation at a specified level involves a
- X string constant or variable.
- X
- X***************************************************************/
- X
- X#if ANSI_C
- Xstatic int
- Xop_islevelstr( int level )
- X#else
- Xstatic int
- Xop_islevelstr( level )
- X int level;
- X#endif
- X {
- X
- X /* first see if the level holds a string constant */
- X
- X if ( CURTASK exps[ level ].operation == CONST_STRING )
- X {
- X
- X#if INTENSIVE_DEBUG
- X sprintf( bwb_ebuf, "in op_islevelstr(): string detected at level <%d>.",
- X level );
- X bwb_debug( bwb_ebuf );
- X#endif
- X
- X return TRUE;
- X }
- X
- X /* see if the level holds a string variable */
- X
- X if ( CURTASK exps[ level ].operation == VARIABLE )
- X {
- X if ( CURTASK exps[ level ].xvar->type == STRING )
- X {
- X
- X#if INTENSIVE_DEBUG
- X sprintf( bwb_ebuf, "in op_islevelstr(): string detected at level <%d>.",
- X level );
- X bwb_debug( bwb_ebuf );
- X#endif
- X
- X return TRUE;
- X }
- X }
- X
- X /* test has failed, return FALSE */
- X
- X#if INTENSIVE_DEBUG
- X sprintf( bwb_ebuf, "in op_islevelstr(): string not detected at level <%d>.",
- X level );
- X bwb_debug( bwb_ebuf );
- X#endif
- X
- X return FALSE;
- X
- X }
- X
- X/***************************************************************
- X
- X FUNCTION: op_getprecision()
- X
- X DESCRIPTION: This function finds the precision for
- X an operation by comparing the precision
- X at this level and that two levels below.
- X
- X***************************************************************/
- X
- X#if ANSI_C
- Xstatic int
- Xop_getprecision( int level )
- X#else
- Xstatic int
- Xop_getprecision( level )
- X int level;
- X#endif
- X {
- X
- X /* first test for string value */
- X
- X if ( ( CURTASK exps[ level + 1 ].type == STRING )
- X || ( CURTASK exps[ level - 1 ].type == STRING ) )
- X {
- X return STRING;
- X }
- X
- X /* Both are numbers, so we should be able to find a suitable
- X precision level by starting with the top and moving down;
- X check first for double precision */
- X
- X else
- X {
- X return NUMBER;
- X }
- X
- X }
- X
- X/***************************************************************
- X
- X FUNCTION: op_pulldown()
- X
- X DESCRIPTION: This function pulls the expression stack
- X down a specified number of levels, decrementing
- X the expression stack counter (bycalling dec_esc())
- X and decrementing the current "level" of operation
- X processing.
- X
- X***************************************************************/
- X
- X#if ANSI_C
- Xstatic int
- Xop_pulldown( int how_far )
- X#else
- Xstatic int
- Xop_pulldown( how_far )
- X int how_far;
- X#endif
- X {
- X int level;
- X register int c;
- X
- X#if INTENSIVE_DEBUG
- X sprintf( bwb_ebuf, "in op_pulldown(): pull down e stack <%d> place(s)",
- X how_far );
- X bwb_debug( bwb_ebuf );
- X#endif
- X
- X /* first pull down the actual variables themselves */
- X
- X level = op_level + ( 2 - how_far );
- X while ( CURTASK expsc >= ( level + how_far ) )
- X {
- X
- X memcpy( &CURTASK exps[ level ], &CURTASK exps[ level + how_far ],
- X (size_t) ( sizeof( struct exp_ese )) );
- X ++level;
- X
- X }
- X
- X /* decrement the expression stack counter */
- X
- X for ( c = 0; c < how_far; ++c )
- X {
- X
- X if ( dec_esc() == TRUE )
- X {
- X --op_level;
- X }
- X else
- X {
- X return FALSE;
- X }
- X
- X }
- X
- X return TRUE;
- X
- X }
- X
- X
- END_OF_FILE
- if test 46972 -ne `wc -c <'bwbasic-2.10/bwb_ops.c'`; then
- echo shar: \"'bwbasic-2.10/bwb_ops.c'\" unpacked with wrong size!
- fi
- # end of 'bwbasic-2.10/bwb_ops.c'
- fi
- if test -f 'bwbasic-2.10/bwbtest/function.bas' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'bwbasic-2.10/bwbtest/function.bas'\"
- else
- echo shar: Extracting \"'bwbasic-2.10/bwbtest/function.bas'\" \(1717 characters\)
- sed "s/^X//" >'bwbasic-2.10/bwbtest/function.bas' <<'END_OF_FILE'
- X1000 PRINT "ABS(-2.2): "; ABS(-2.2)
- X1010 PRINT "DATE$: <"; DATE$; ">"
- X1020 PRINT "TIME$: <"; TIME$; ">"
- X1030 PRINT "ATN(-2.2): "; ATN(-2.2)
- X1040 PRINT "COS(-2.2): "; COS(-2.2)
- X1050 PRINT "LOG(2.2): "; LOG(2.2)
- X1060 PRINT "SIN(-2.2): "; SIN(-2.2)
- X1070 PRINT "SQR(2.2): "; SQR(2.2)
- X1080 PRINT "TAN(-2.2): "; TAN(-2.2)
- X1090 PRINT "SGN(-2.2): "; SGN(-2.2)
- X1100 PRINT "INT(-2.2): "; INT(-2.2)
- X1102 INPUT "Paused";X$
- X1110 PRINT "RND(-2.2): "; RND(-2.2)
- X1120 PRINT "CHR$(&h60): "; CHR$(&H60)
- X1130 PRINT "TAB(52): <"; TAB(52); ">"
- X1140 PRINT "SPC(5): <"; SPC(5); ">"
- X1150 PRINT "SPACE$(5): <"; SPACE$(5); ">"
- X1160 PRINT "STRING$(5,X): <"; STRING$(5,"X"); ">"
- X1170 PRINT "MID$(0123456789, 5, 4): <"; MID$("0123456789", 5, 4); ">"
- X1180 PRINT "LEFT$(0123456789, 5): <"; LEFT$("0123456789", 5); ">"
- X1190 PRINT "RIGHT$(0123456789, 5): <"; RIGHT$("0123456789", 5); ">"
- X1200 PRINT "TIMER: "; TIMER
- X1202 INPUT "Paused";X$
- X1210 PRINT "VAL(X): "; VAL("X")
- X1230 PRINT "ERR: "; ERR
- X1240 PRINT "ERL: "; ERL
- X1250 PRINT "LEN(0123456789): "; LEN("0123456789")
- X1260 PRINT "CSNG(-2.2): "; CSNG(-2.2)
- X1270 PRINT "EXP(-2.2): "; EXP(-2.2)
- X1280 PRINT "INSTR(0123456789, 234): "; INSTR("0123456789", "234")
- X1290 PRINT "STR$(-2.2): <"; STR$(-2.2); ">"
- X1300 PRINT "HEX$(27): <"; HEX$(27); ">"
- X1302 INPUT "Paused";X$
- X1310 PRINT "OCT$(27): <"; OCT$(27); ">"
- X1320 PRINT "CINT(-2.2): "; CINT(-2.2)
- X1330 PRINT "ASC(0123456789): "; ASC("0123456789")
- X1340 PRINT "ENVIRON$(PATH): <"; ENVIRON$("PATH"); ">"
- X1350 PRINT "MKD$(17): <"; MKD$(17); ">"
- X1360 PRINT "MKI$(17): <"; MKI$(17); ">"
- X1370 PRINT "MKS$(17): <"; MKS$(17); ">"
- X1380 PRINT "CVD(MKD$(17)): "; CVD(MKD$(17))
- X1390 PRINT "CVS(MKS$(17)): "; CVS(MKS$(17))
- X1400 PRINT "CVI(MKI$(17)): "; CVI(MKI$(17))
- END_OF_FILE
- if test 1717 -ne `wc -c <'bwbasic-2.10/bwbtest/function.bas'`; then
- echo shar: \"'bwbasic-2.10/bwbtest/function.bas'\" unpacked with wrong size!
- fi
- # end of 'bwbasic-2.10/bwbtest/function.bas'
- fi
- echo shar: End of archive 6 \(of 15\).
- cp /dev/null ark6isdone
- MISSING=""
- for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ; do
- if test ! -f ark${I}isdone ; then
- MISSING="${MISSING} ${I}"
- fi
- done
- if test "${MISSING}" = "" ; then
- echo You have unpacked all 15 archives.
- rm -f ark[1-9]isdone ark[1-9][0-9]isdone
- else
- echo You still must unpack the following archives:
- echo " " ${MISSING}
- fi
- exit 0
- exit 0 # Just in case...
-