G:/ScriptBasic/source/commands/mathfunc.c

Go to the documentation of this file.
00001 /*mathfunc.c
00002 
00003 --GNU LGPL
00004 This library is free software; you can redistribute it and/or
00005 modify it under the terms of the GNU Lesser General Public
00006 License as published by the Free Software Foundation; either
00007 version 2.1 of the License, or (at your option) any later version.
00008 
00009 This library is distributed in the hope that it will be useful,
00010 but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012 Lesser General Public License for more details.
00013 
00014 You should have received a copy of the GNU Lesser General Public
00015 License along with this library; if not, write to the Free Software
00016 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00017 
00018 */
00019 
00020 #include <stdlib.h>
00021 #include <stdio.h>
00022 #include <time.h>
00023 #include <math.h>
00024 #include <limits.h>
00025 
00026 #include "../command.h"
00027 
00028 /* this function is defined in mathops.c */
00029 long *RaiseError(pExecuteObject pEo);
00030 
00031 #define GET_ONE_ARG USE_CALLER_MORTALS; nItem = PARAMETERLIST; Op1 = EVALUATEEXPRESSION(CAR(nItem)); NONULOP(Op1)
00032 
00033 
00034 /*POD
00035 =H Mathematical Functions
00036 
00037 This file defines all the mathematical functions that are implemented in ScriptBasic.
00038 CUT*/
00039 
00040 
00049 COMMAND(POW)
00050 #if NOTIMP_POW
00051 NOTIMPLEMENTED;
00052 #else
00053 
00054 
00055   NODE nItem;
00056   VARIABLE Op1;
00057   double dResult;
00058 
00059   GET_ONE_ARG
00060 
00061   RETURN_DOUBLE_VALUE_OR_LONG( pow(10.0,GETDOUBLEVALUE(Op1)) )
00062 
00063 #endif
00064 END
00065 
00066 
00075 COMMAND(EXP)
00076 #if NOTIMP_EXP
00077 NOTIMPLEMENTED;
00078 #else
00079 
00080 
00081   NODE nItem;
00082   VARIABLE Op1;
00083   double dResult;
00084 
00085   GET_ONE_ARG
00086   RETURN_DOUBLE_VALUE_OR_LONG( exp(GETDOUBLEVALUE(Op1)) )
00087 
00088 #endif
00089 END
00090 
00101 COMMAND(LOG)
00102 #if NOTIMP_LOG
00103 NOTIMPLEMENTED;
00104 #else
00105 
00106   NODE nItem;
00107   VARIABLE Op1;
00108   double dop1,dResult;
00109 
00110   GET_ONE_ARG
00111 
00112   dop1 = GETDOUBLEVALUE(Op1);
00113   if( dop1 <= 0.0 ){
00114     ERRORUNDEF
00115     }
00116   RETURN_DOUBLE_VALUE_OR_LONG( log(dop1) )
00117 
00118 #endif
00119 END
00120 
00131 COMMAND(LOG10)
00132 #if NOTIMP_LOG10
00133 NOTIMPLEMENTED;
00134 #else
00135 
00136   NODE nItem;
00137   VARIABLE Op1;
00138   double dop1,dResult;
00139 
00140   GET_ONE_ARG
00141 
00142   dop1 = GETDOUBLEVALUE(Op1);
00143   if( dop1 <= 0.0 ){
00144     ERRORUNDEF
00145     }
00146   RETURN_DOUBLE_VALUE_OR_LONG( log10(dop1) )
00147 
00148 #endif
00149 END
00150 
00159 COMMAND(SIN)
00160 #if NOTIMP_SIN
00161 NOTIMPLEMENTED;
00162 #else
00163 
00164 
00165   NODE nItem;
00166   VARIABLE Op1;
00167   double dResult;
00168 
00169   GET_ONE_ARG
00170 
00171   RETURN_DOUBLE_VALUE_OR_LONG( sin(GETDOUBLEVALUE(Op1)) )
00172 
00173 #endif
00174 END
00175 
00186 COMMAND(ASIN)
00187 #if NOTIMP_ASIN
00188 NOTIMPLEMENTED;
00189 #else
00190 
00191 
00192   NODE nItem;
00193   VARIABLE Op1;
00194   double dop1,dResult;
00195 
00196   GET_ONE_ARG
00197 
00198   dop1 = GETDOUBLEVALUE(Op1);
00199   if( dop1 < -1 || dop1 > +1 ){
00200     ERRORUNDEF
00201     }
00202   RETURN_DOUBLE_VALUE_OR_LONG( asin(dop1) )
00203 
00204 #endif
00205 END
00206 
00217 COMMAND(ACOS)
00218 #if NOTIMP_ACOS
00219 NOTIMPLEMENTED;
00220 #else
00221 
00222   NODE nItem;
00223   VARIABLE Op1;
00224   double dop1,dResult;
00225 
00226   GET_ONE_ARG
00227 
00228   dop1 = GETDOUBLEVALUE(Op1);
00229   if( dop1 < -1 || dop1 > +1 ){
00230     ERRORUNDEF
00231     }
00232   RETURN_DOUBLE_VALUE_OR_LONG( acos(dop1) )
00233 
00234 #endif
00235 END
00236 
00246 COMMAND(COS)
00247 #if NOTIMP_COS
00248 NOTIMPLEMENTED;
00249 #else
00250 
00251 
00252   NODE nItem;
00253   VARIABLE Op1;
00254   double dResult;
00255 
00256   GET_ONE_ARG
00257 
00258   RETURN_DOUBLE_VALUE_OR_LONG( cos(GETDOUBLEVALUE(Op1)) )
00259 
00260 #endif
00261 END
00262 
00270 COMMAND(RND)
00271 #if NOTIMP_RND
00272 NOTIMPLEMENTED;
00273 #else
00274 
00275   /* this is an operator and not a command, therefore we do not have our own mortal list */
00276   USE_CALLER_MORTALS;
00277   RETURN_DOUBLE_VALUE( rand() )
00278 
00279 #endif
00280 END
00281 
00288 COMMAND(RANDOMIZA)
00289 #if NOTIMP_RANDOMIZA
00290 NOTIMPLEMENTED;
00291 #else
00292   time_t timer;
00293   srand(time(&timer));
00294 
00295 #endif
00296 END
00297 
00298 COMMAND(RANDOMIZE)
00299 #if NOTIMP_RANDOMIZE
00300 NOTIMPLEMENTED;
00301 #else
00302   time_t timer;
00303   NODE nItem;
00304   VARIABLE ItemResult;
00305 
00306   nItem = PARAMETERNODE;
00307   if( nItem ){
00308     ItemResult = _EVALUATEEXPRESSION_A(nItem);
00309     ASSERTOKE;
00310     if( ItemResult )
00311       srand(GETLONGVALUE(ItemResult));
00312     else
00313       srand(time(&timer));
00314     }else{
00315     srand(time(&timer));
00316     }
00317 
00318 #endif
00319 END
00320 
00321 /*SGN
00322 =display SGN()
00323 =section math
00324 
00325 Calculates the signum of the argument. This is -1 for negative numbers, +1 for positive numbers and 0 for zero. The return value is always long except that  T<SGN(undef)> may return T<undef>. If the argument is a string it is converted to long or double.
00326 
00327 T<SGN(undef)> is T<undef> or raises an error if the option T<RaiseMatherror> is set in bit T<sbMathErrUndef>.
00328 */
00329 COMMAND(SGN)
00330 #if NOTIMP_SGN
00331 NOTIMPLEMENTED;
00332 #else
00333 
00334 
00335   NODE nItem;
00336   VARIABLE Op1;
00337   double dop1;
00338   long lop1,result;
00339 
00340   GET_ONE_ARG
00341 
00342   if( ISINTEGER(Op1) ){
00343     lop1 = GETLONGVALUE(Op1);
00344     if( lop1 == 0 )result = 0;
00345     else if( lop1 > 0 )result = 1;
00346     else result = -1;
00347     }else{
00348     dop1 = GETDOUBLEVALUE(Op1);
00349     if( dop1 == 0.0 )result = 0;
00350     else if( dop1 > 0 )result = 1;
00351     else result = -1;
00352     }
00353 
00354   RETURN_LONG_VALUE( result );
00355 
00356 #endif
00357 END
00358 
00375 COMMAND(SQR)
00376 #if NOTIMP_SQR
00377 NOTIMPLEMENTED;
00378 #else
00379 
00380 
00381   NODE nItem;
00382   VARIABLE Op1;
00383   double dResult;
00384   long lSquare,lop1;
00385   double dop1;
00386 
00387   GET_ONE_ARG
00388 
00389   if( ISINTEGER(Op1) ){
00390     lop1 = GETLONGVALUE(Op1);
00391     /* we return undef or raise error based on OPTION setting */
00392     if( lop1 < 0 ){
00393       ERRORUNDEF
00394       }
00395     /* calculate the square root of the argument */
00396     dResult = sqrt((double)lop1);
00397     /* round the result and convert to long to check if it can be handles as a long*/
00398     lSquare = (long) floor(dResult + 0.5);
00399     /* if the square of the rounded result is the same as the argument then it can be returned as a long */
00400     if( lSquare * lSquare == lop1 ){
00401       RETURN_LONG_VALUE(lSquare)
00402       }
00403     /* if it can not be converted to long w/o loosing precision then return the 'double' value */
00404     RETURN_DOUBLE_VALUE(dResult)
00405     }
00406 
00407   /* if the argument is double */
00408   dop1 = GETDOUBLEVALUE(Op1);
00409   /* we return undef or raise error based on OPTION setting */
00410   if( dop1 < 0 ){
00411     ERRORUNDEF
00412     }
00413   /* if the argument was double then the result is double */
00414   RETURN_DOUBLE_VALUE( sqrt(dop1) )
00415 #endif
00416 END
00417 
00425 COMMAND(ABS)
00426 #if NOTIMP_ABS
00427 NOTIMPLEMENTED;
00428 #else
00429 
00430 
00431   NODE nItem;
00432   VARIABLE Op1;
00433   long lop1;
00434   double dop1;
00435 
00436   GET_ONE_ARG
00437 
00438   if( ISINTEGER(Op1) ){
00439     /* if the argument is long then the ABS value of it is also long*/
00440     lop1 = GETLONGVALUE(Op1);
00441     /* ... with the only exception of LONG_MAX because ABS(LONG_MIN) is LONG_MAX-1 usually (two's complement) */
00442     /* if ever you implement ScriptBasic on a machine that uses different signed integer not two's complement then you have to rewrite it */
00443     if( lop1 < LONG_MAX ){
00444       RETURN_LONG_VALUE( lop1 > 0 ? lop1 : -lop1 );
00445       }else{
00446       RETURN_DOUBLE_VALUE( -(double)lop1 );
00447       }
00448     }
00449   /* if the argument is double then the result will also be double */
00450   dop1 = GETDOUBLEVALUE(Op1);
00451   RETURN_DOUBLE_VALUE( dop1 > 0.0 ? dop1 : -dop1 );
00452 #endif
00453 END
00454 
00463 COMMAND(VAL)
00464 #if NOTIMP_VAL
00465 NOTIMPLEMENTED;
00466 #else
00467 
00468 
00469   NODE nItem;
00470   VARIABLE Op1;
00471 
00472   GET_ONE_ARG
00473 
00474   if( TYPE(Op1) == VTYPE_STRING ){
00475     if( ISSTRINGINTEGER(Op1) )
00476       RESULT = CONVERT2LONG(Op1);
00477     else
00478       RESULT = CONVERT2DOUBLE(Op1);
00479     }else{
00480     RESULT = Op1;
00481     }
00482 
00483 #endif
00484 END
00485 
00492 COMMAND(MAXINT)
00493 #if NOTIMP_MAXINT
00494 NOTIMPLEMENTED;
00495 #else
00496 
00497   /* this is an operator and not a command, therefore we do not have our own mortal list */
00498   USE_CALLER_MORTALS;
00499 
00500   RETURN_LONG_VALUE(LONG_MAX)
00501 
00502 #endif
00503 END
00504 
00511 COMMAND(MININT)
00512 #if NOTIMP_MININT
00513 NOTIMPLEMENTED;
00514 #else
00515 
00516   /* this is an operator and not a command, therefore we do not have our own mortal list */
00517   USE_CALLER_MORTALS;
00518 
00519   RETURN_LONG_VALUE(LONG_MIN)
00520 
00521 #endif
00522 END
00523 
00530 COMMAND(PI)
00531 #if NOTIMP_PI
00532 NOTIMPLEMENTED;
00533 #else
00534 
00535   /* this is an operator and not a command, therefore we do not have our own mortal list */
00536   USE_CALLER_MORTALS;
00537 
00538   RETURN_DOUBLE_VALUE(3.1415926)
00539 
00540 #endif
00541 END
00542 
00543 COMMAND(UNDEF)
00544 #if NOTIMP_UNDEF
00545 NOTIMPLEMENTED;
00546 #else
00547 
00548 
00549   /* this is an operator and not a command, therefore we do not have our own mortal list */
00550   USE_CALLER_MORTALS;
00551 
00552   RESULT = NULL;
00553 
00554 #endif
00555 END
00556 
00562 COMMAND(TRUE)
00563 #if NOTIMP_TRUE
00564 NOTIMPLEMENTED;
00565 #else
00566 
00567 
00568   /* this is an operator and not a command, therefore we do not have our own mortal list */
00569   USE_CALLER_MORTALS;
00570   RETURN_LONG_VALUE( -1L )
00571 
00572 #endif
00573 END
00574 
00580 COMMAND(FALSE)
00581 #if NOTIMP_FALSE
00582 NOTIMPLEMENTED;
00583 #else
00584 
00585 
00586   /* this is an operator and not a command, therefore we do not have our own mortal list */
00587   USE_CALLER_MORTALS;
00588 
00589   RETURN_LONG_VALUE( 0L )
00590 
00591 #endif
00592 END
00593 
00612 COMMAND(FIX)
00613 #if NOTIMP_FIX
00614 NOTIMPLEMENTED;
00615 #else
00616 
00617 
00618   NODE nItem;
00619   VARIABLE Op1;
00620   double dop1;
00621   long   lop1;
00622   int isneg;
00623 
00624   GET_ONE_ARG
00625 
00626   if( ISINTEGER(Op1) ){
00627     RETURN_LONG_VALUE( GETLONGVALUE(Op1) )
00628     }
00629   dop1 = GETDOUBLEVALUE(Op1);
00630   if( isneg = dop1 < 0 )dop1 =  -dop1;
00631   dop1 = floor(dop1);
00632   if( isneg )dop1 = - dop1;
00633   lop1 = (long)dop1;
00634   if( dop1 == (double)lop1 ){
00635     RETURN_LONG_VALUE( lop1 );
00636     }
00637 
00638   RETURN_DOUBLE_VALUE( dop1 );
00639 
00640 #endif
00641 END
00642 
00663 COMMAND(INT)
00664 #if NOTIMP_INT
00665 NOTIMPLEMENTED;
00666 #else
00667 
00668 
00669   NODE nItem;
00670   VARIABLE Op1;
00671   double dop1;
00672   long   lop1;
00673 
00674   GET_ONE_ARG
00675 
00676   if( ISINTEGER(Op1) ){
00677     RETURN_LONG_VALUE( GETLONGVALUE(Op1) )
00678     }
00679 
00680   dop1 = floor(GETDOUBLEVALUE(Op1));
00681   lop1 = (long)dop1;
00682   if( dop1 == (double)lop1 ){
00683     RETURN_LONG_VALUE( lop1 );
00684     }
00685 
00686   RETURN_DOUBLE_VALUE( dop1 );
00687 
00688 #endif
00689 END
00690 
00691 
00714 COMMAND(FRAC)
00715 #if NOTIMP_FRAC
00716 NOTIMPLEMENTED;
00717 #else
00718 
00719 
00720   NODE nItem;
00721   VARIABLE Op1;
00722   double dop1;
00723 
00724   GET_ONE_ARG
00725 
00726   if( ISINTEGER(Op1) ){
00727     RETURN_DOUBLE_VALUE( 0.0 )
00728     }
00729 
00730   dop1 = GETDOUBLEVALUE(Op1);
00731   if( dop1 < 0 ){
00732     RETURN_DOUBLE_VALUE( dop1 - floor(dop1) -1 )
00733     }else{
00734     RETURN_DOUBLE_VALUE( dop1 - floor(dop1) )
00735     }
00736 
00737 #endif
00738 END
00739 
00740 
00760 COMMAND(ROUND)
00761 #if NOTIMP_ROUND
00762 NOTIMPLEMENTED;
00763 #else
00764 
00765 
00766   NODE nItem;
00767   VARIABLE Op1;
00768   long iNumberOfDigits,lop1;
00769   double Multiplier,dop1;
00770 
00771   GET_ONE_ARG
00772 
00773   nItem = CDR(nItem);
00774 
00775   iNumberOfDigits = 0;
00776   if( nItem ){
00777     iNumberOfDigits = GETLONGVALUE(EVALUATEEXPRESSION(CAR(nItem)));
00778     ASSERTOKE;
00779     }
00780   if( iNumberOfDigits < 0 )iNumberOfDigits = 0;
00781   if( iNumberOfDigits > 100 )iNumberOfDigits = 100;
00782 
00783   if( ISINTEGER(Op1) ){
00784     RETURN_LONG_VALUE( GETLONGVALUE(Op1) )
00785     }
00786 
00787   dop1 = GETDOUBLEVALUE(Op1);
00788   if( iNumberOfDigits == 0 ){
00789     dop1 = floor( dop1 + 0.5);
00790     lop1 = (long)dop1;
00791     if( dop1 == (double)lop1 ){
00792       RETURN_LONG_VALUE( lop1 )
00793       }else{
00794       RETURN_DOUBLE_VALUE( dop1 )
00795       }
00796     }
00797   Multiplier = 1.0;
00798   while( iNumberOfDigits -- )Multiplier *= 10.0;
00799   dop1 *= Multiplier;
00800   dop1 += 0.5;
00801   dop1 = floor(dop1);
00802 
00803   dop1 /= Multiplier;
00804   lop1 = (long)dop1;
00805   if( dop1 == (double)lop1 ){
00806     RETURN_LONG_VALUE( lop1 )
00807     }else{
00808      RETURN_DOUBLE_VALUE( dop1 )
00809    }
00810 #endif
00811 END
00812 
00820 COMMAND(GCD)
00821 #if NOTIMP_GCD
00822 NOTIMPLEMENTED;
00823 #else
00824 NOTIMPLEMENTED;
00825 #endif
00826 END
00827 
00835 COMMAND(LCM)
00836 #if NOTIMP_LCM
00837 NOTIMPLEMENTED;
00838 #else
00839 NOTIMPLEMENTED;
00840 #endif
00841 END
00842 
00851 COMMAND(ODD)
00852 #if NOTIMP_ODD
00853 NOTIMPLEMENTED;
00854 #else
00855 
00856 
00857   NODE nItem;
00858   VARIABLE Op1;
00859 
00860   GET_ONE_ARG
00861 
00862   RESULT = NEWMORTALLONG;
00863 
00864   if( GETLONGVALUE(Op1) & 1 )
00865     LONGVALUE(RESULT) = -1;
00866   else
00867     LONGVALUE(RESULT) = 0;
00868 
00869 #endif
00870 END
00871 
00879 COMMAND(EVEN)
00880 #if NOTIMP_EVEN
00881 NOTIMPLEMENTED;
00882 #else
00883 
00884 
00885   NODE nItem;
00886   VARIABLE Op1;
00887 
00888   GET_ONE_ARG
00889 
00890   RESULT = NEWMORTALLONG;
00891   ASSERTNULL(RESULT)
00892 
00893   if( GETLONGVALUE(Op1) & 1 )
00894     LONGVALUE(RESULT) = 0;
00895   else
00896     LONGVALUE(RESULT) = -1;
00897 
00898 #endif
00899 END
00900 
00913 COMMAND(LBOUND)
00914 #if NOTIMP_LBOUND
00915 NOTIMPLEMENTED;
00916 #else
00917 
00918   VARIABLE ItemResult;
00919   NODE nItem;
00920 
00921   /* this is an operator and not a command, therefore we do not have our own mortal list */
00922   USE_CALLER_MORTALS;
00923 
00924   /* evaluate the parameter */
00925   nItem = PARAMETERLIST;
00926   ItemResult = _EVALUATEEXPRESSION_A(CAR(nItem));
00927   NONULOP(ItemResult)
00928 
00929   switch( TYPE(ItemResult) ){
00930     case VTYPE_LONG:
00931     case VTYPE_DOUBLE:
00932     case VTYPE_STRING:
00933       RESULT = NULL;
00934       RETURN;
00935     case VTYPE_ARRAY:
00936       RESULT = NEWMORTALLONG;
00937       ASSERTNULL(RESULT)
00938       LONGVALUE(RESULT) = ItemResult->ArrayLowLimit;
00939       RETURN;
00940     }
00941 
00942 #endif
00943 END
00944 
00958 COMMAND(UBOUND)
00959 #if NOTIMP_UBOUND
00960 NOTIMPLEMENTED;
00961 #else
00962 
00963   VARIABLE ItemResult;
00964   NODE nItem;
00965 
00966   /* this is an operator and not a command, therefore we do not have our own mortal list */
00967   USE_CALLER_MORTALS;
00968 
00969   /* evaluate the parameter */
00970   nItem = PARAMETERLIST;
00971   ItemResult = _EVALUATEEXPRESSION_A(CAR(nItem));
00972   NONULOP(ItemResult)
00973 
00974   switch( TYPE(ItemResult) ){
00975     case VTYPE_LONG:
00976     case VTYPE_DOUBLE:
00977     case VTYPE_STRING:
00978       RESULT = NULL;
00979       RETURN;
00980     case VTYPE_ARRAY:
00981       RESULT = NEWMORTALLONG;
00982       ASSERTNULL(RESULT)
00983       LONGVALUE(RESULT) = ItemResult->ArrayHighLimit;
00984       RETURN;
00985     }
00986 
00987 #endif
00988 END
00989 
00998 COMMAND(ISARRAY)
00999 #if NOTIMP_ISARRAY
01000 NOTIMPLEMENTED;
01001 #else
01002 
01003   VARIABLE ItemResult;
01004   NODE nItem;
01005 
01006   /* this is an operator and not a command, therefore we do not have our own mortal list */
01007   USE_CALLER_MORTALS;
01008 
01009   /* evaluate the parameter */
01010   nItem = PARAMETERLIST;
01011   ItemResult = _EVALUATEEXPRESSION_A(CAR(nItem));
01012   ASSERTOKE;
01013 
01014   if( memory_IsUndef(ItemResult) ){
01015     RETURN_FALSE
01016     }
01017   switch( TYPE(ItemResult) ){
01018     case VTYPE_LONG:
01019     case VTYPE_DOUBLE:
01020     case VTYPE_STRING:
01021       RETURN_FALSE
01022     case VTYPE_ARRAY:
01023       RETURN_TRUE
01024     }
01025 
01026 #endif
01027 END
01028 
01037 COMMAND(ISSTRING)
01038 #if NOTIMP_ISSTRING
01039 NOTIMPLEMENTED;
01040 #else
01041 
01042   VARIABLE ItemResult;
01043   NODE nItem;
01044 
01045   /* this is an operator and not a command, therefore we do not have our own mortal list */
01046   USE_CALLER_MORTALS;
01047 
01048   /* evaluate the parameter */
01049   nItem = PARAMETERLIST;
01050   ItemResult = _EVALUATEEXPRESSION_A(CAR(nItem));
01051   ASSERTOKE;
01052 
01053   if( memory_IsUndef(ItemResult) ){
01054     RETURN_FALSE
01055     }
01056   switch( TYPE(ItemResult) ){
01057     case VTYPE_LONG:
01058     case VTYPE_DOUBLE:
01059     case VTYPE_ARRAY:
01060       RETURN_FALSE
01061     case VTYPE_STRING:
01062       RETURN_TRUE
01063     }
01064 
01065 #endif
01066 END
01067 
01076 COMMAND(ISLONG)
01077 #if NOTIMP_ISLONG
01078 NOTIMPLEMENTED;
01079 #else
01080 
01081   VARIABLE ItemResult;
01082   NODE nItem;
01083 
01084   /* this is an operator and not a command, therefore we do not have our own mortal list */
01085   USE_CALLER_MORTALS;
01086 
01087   /* evaluate the parameter */
01088   nItem = PARAMETERLIST;
01089   ItemResult = _EVALUATEEXPRESSION_A(CAR(nItem));
01090   ASSERTOKE;
01091 
01092   if( memory_IsUndef(ItemResult) ){
01093     RETURN_FALSE
01094     }
01095   switch( TYPE(ItemResult) ){
01096     case VTYPE_DOUBLE:
01097     case VTYPE_ARRAY:
01098     case VTYPE_STRING:
01099       RETURN_FALSE
01100     case VTYPE_LONG:
01101       RETURN_TRUE
01102     }
01103 
01104 #endif
01105 END
01106 
01116 COMMAND(ISDOUBLE)
01117 #if NOTIMP_ISDOUBLE
01118 NOTIMPLEMENTED;
01119 #else
01120 
01121   VARIABLE ItemResult;
01122   NODE nItem;
01123 
01124   /* this is an operator and not a command, therefore we do not have our own mortal list */
01125   USE_CALLER_MORTALS;
01126 
01127   /* evaluate the parameter */
01128   nItem = PARAMETERLIST;
01129   ItemResult = _EVALUATEEXPRESSION_A(CAR(nItem));
01130   ASSERTOKE;
01131 
01132   if( memory_IsUndef(ItemResult) ){
01133     RETURN_FALSE
01134     }
01135   switch( TYPE(ItemResult) ){
01136     case VTYPE_ARRAY:
01137     case VTYPE_STRING:
01138     case VTYPE_LONG:
01139       RETURN_FALSE
01140     case VTYPE_DOUBLE:
01141       RETURN_TRUE
01142     }
01143 
01144 #endif
01145 END
01146 
01156 COMMAND(ISNUMERIC)
01157 #if NOTIMP_ISNUMERIC
01158 NOTIMPLEMENTED;
01159 #else
01160 
01161   VARIABLE ItemResult;
01162   NODE nItem;
01163 
01164   /* this is an operator and not a command, therefore we do not have our own mortal list */
01165   USE_CALLER_MORTALS;
01166 
01167   /* evaluate the parameter */
01168   nItem = PARAMETERLIST;
01169   ItemResult = _EVALUATEEXPRESSION_A(CAR(nItem));
01170   ASSERTOKE;
01171 
01172   if( memory_IsUndef(ItemResult) ){
01173     RETURN_FALSE
01174     }
01175   switch( TYPE(ItemResult) ){
01176     case VTYPE_ARRAY:
01177     case VTYPE_STRING:
01178       RETURN_FALSE
01179     case VTYPE_LONG:
01180     case VTYPE_DOUBLE:
01181       RETURN_TRUE
01182     }
01183 #endif
01184 END
01185 
01197 COMMAND(ISDEF)
01198 #if NOTIMP_ISDEF
01199 NOTIMPLEMENTED;
01200 #else
01201 
01202   VARIABLE ItemResult;
01203   NODE nItem;
01204 
01205   /* this is an operator and not a command, therefore we do not have our own mortal list */
01206   USE_CALLER_MORTALS;
01207 
01208   /* evaluate the parameter */
01209   nItem = PARAMETERLIST;
01210   ItemResult = _EVALUATEEXPRESSION_A(CAR(nItem));
01211   ASSERTOKE;
01212 
01213   if( memory_IsUndef(ItemResult) ){
01214     RETURN_FALSE
01215     }
01216   RETURN_TRUE
01217 #endif
01218 END
01219 
01231 COMMAND(ISUNDEF)
01232 #if NOTIMP_ISUNDEF
01233 NOTIMPLEMENTED;
01234 #else
01235 
01236   VARIABLE ItemResult;
01237   NODE nItem;
01238 
01239   /* this is an operator and not a command, therefore we do not have our own mortal list */
01240   USE_CALLER_MORTALS;
01241 
01242   /* evaluate the parameter */
01243   nItem = PARAMETERLIST;
01244   ItemResult = _EVALUATEEXPRESSION_A(CAR(nItem));
01245   ASSERTOKE;
01246 
01247   if( memory_IsUndef(ItemResult) ){
01248     RETURN_TRUE
01249     }
01250   RETURN_FALSE
01251 #endif
01252 END
01253 
01265 COMMAND(ISEMPTY)
01266 #if NOTIMP_ISEMPTY
01267 NOTIMPLEMENTED;
01268 #else
01269 
01270   VARIABLE ItemResult;
01271   NODE nItem;
01272 
01273   /* this is an operator and not a command, therefore we do not have our own mortal list */
01274   USE_CALLER_MORTALS;
01275 
01276   /* evaluate the parameter */
01277   nItem = PARAMETERLIST;
01278   ItemResult = _EVALUATEEXPRESSION_A(CAR(nItem));
01279   ASSERTOKE;
01280 
01281   if( memory_IsUndef(ItemResult) ||
01282      ( TYPE(ItemResult) == VTYPE_STRING && STRLEN(ItemResult) == 0 ) ){
01283     RETURN_TRUE
01284     }
01285   RETURN_FALSE
01286 #endif
01287 END
01288 
01307 COMMAND(TYPE)
01308 #if NOTIMP_TYPE
01309 NOTIMPLEMENTED;
01310 #else
01311 
01312   VARIABLE ItemResult;
01313   NODE nItem;
01314 
01315   /* this is an operator and not a command, therefore we do not have our own mortal list */
01316   USE_CALLER_MORTALS;
01317 
01318   /* evaluate the parameter */
01319   nItem = PARAMETERLIST;
01320   ItemResult = _EVALUATEEXPRESSION_A(CAR(nItem));
01321   ASSERTOKE;
01322 
01323   RESULT = NEWMORTALLONG;
01324   ASSERTNULL(RESULT)
01325 
01326   if( memory_IsUndef(ItemResult) ){
01327     LONGVALUE(RESULT) = 0;
01328     RETURN;
01329     }
01330   switch( TYPE(ItemResult) ){
01331     case VTYPE_LONG:
01332       LONGVALUE(RESULT) = 3;
01333       break;
01334     case VTYPE_DOUBLE:
01335       LONGVALUE(RESULT) = 2;
01336       break;
01337     case VTYPE_STRING:
01338       LONGVALUE(RESULT) = 1;
01339       break;
01340     case VTYPE_ARRAY:
01341       LONGVALUE(RESULT) = 4;
01342       break;
01343     }
01344 #endif
01345 END
01346 
01353 COMMAND(ATN)
01354 #if NOTIMP_ATN
01355 NOTIMPLEMENTED;
01356 #else
01357 NOTIMPLEMENTED;
01358 #endif
01359 END
01360 
01367 COMMAND(ATAN)
01368 #if NOTIMP_ATAN 
01369 NOTIMPLEMENTED;
01370 #else
01371 NOTIMPLEMENTED;
01372 #endif
01373 END
01374 
01381 COMMAND(TAN)
01382 #if NOTIMP_TAN 
01383 NOTIMPLEMENTED;
01384 #else
01385 NOTIMPLEMENTED;
01386 #endif
01387 END
01388 
01389 
01396 COMMAND(TAN2)
01397 #if NOTIMP_TAN2
01398 NOTIMPLEMENTED;
01399 #else
01400 NOTIMPLEMENTED;
01401 #endif
01402 END
01403 
01404 
01411 COMMAND(COTAN)
01412 #if NOTIMP_COTAN 
01413 NOTIMPLEMENTED;
01414 #else
01415 NOTIMPLEMENTED;
01416 #endif
01417 END
01418 
01419 
01426 COMMAND(COTAN2)
01427 #if NOTIMP_COTAN2
01428 NOTIMPLEMENTED;
01429 #else
01430 NOTIMPLEMENTED;
01431 #endif
01432 END
01433 
01434 
01441 COMMAND(ACTAN)
01442 #if NOTIMP_ACTAN 
01443 NOTIMPLEMENTED;
01444 #else
01445 NOTIMPLEMENTED;
01446 #endif
01447 END
01448 
01449 
01456 COMMAND(SECANT)
01457 #if NOTIMP_SECANT 
01458 NOTIMPLEMENTED;
01459 #else
01460 NOTIMPLEMENTED;
01461 #endif
01462 END
01463 
01464 
01471 COMMAND(COSECANT)
01472 #if NOTIMP_COSECANT 
01473 NOTIMPLEMENTED;
01474 #else
01475 NOTIMPLEMENTED;
01476 #endif
01477 END
01478 
01479 
01486 COMMAND(ASECANT)
01487 #if NOTIMP_ASECANT 
01488 NOTIMPLEMENTED;
01489 #else
01490 NOTIMPLEMENTED;
01491 #endif
01492 END
01493 
01494 
01501 COMMAND(ACOSECANT)
01502 #if NOTIMP_ACOSECANT 
01503 NOTIMPLEMENTED;
01504 #else
01505 NOTIMPLEMENTED;
01506 #endif
01507 END
01508 
01509 
01516 COMMAND(HSIN)
01517 #if NOTIMP_HSIN 
01518 NOTIMPLEMENTED;
01519 #else
01520 NOTIMPLEMENTED;
01521 #endif
01522 END
01523 
01524 
01531 COMMAND(HCOS)
01532 #if NOTIMP_HCOS 
01533 NOTIMPLEMENTED;
01534 #else
01535 NOTIMPLEMENTED;
01536 #endif
01537 END
01538 
01539 
01546 COMMAND(HTAN)
01547 #if NOTIMP_HTAN 
01548 NOTIMPLEMENTED;
01549 #else
01550 NOTIMPLEMENTED;
01551 #endif
01552 END
01553 
01554 
01561 COMMAND(HCTAN)
01562 #if NOTIMP_HCTAN 
01563 NOTIMPLEMENTED;
01564 #else
01565 NOTIMPLEMENTED;
01566 #endif
01567 END
01568 
01569 
01576 COMMAND(HSECANT)
01577 #if NOTIMP_HSECANT 
01578 NOTIMPLEMENTED;
01579 #else
01580 NOTIMPLEMENTED;
01581 #endif
01582 END
01583 
01584 
01591 COMMAND(HCOSECANT)
01592 #if NOTIMP_HCOSECANT 
01593 NOTIMPLEMENTED;
01594 #else
01595 NOTIMPLEMENTED;
01596 #endif
01597 END
01598 
01605 COMMAND(MAX)
01606 #if NOTIMP_MAX
01607 NOTIMPLEMENTED;
01608 #else
01609 NOTIMPLEMENTED;
01610 #endif
01611 END
01612 
01619 COMMAND(MIN)
01620 #if NOTIMP_MIN
01621 NOTIMPLEMENTED;
01622 #else
01623 NOTIMPLEMENTED;
01624 #endif
01625 END
01626 
01633 COMMAND(IMAX)
01634 #if NOTIMP_IMAX
01635 NOTIMPLEMENTED;
01636 #else
01637 NOTIMPLEMENTED;
01638 #endif
01639 END
01640 
01647 COMMAND(IMIN)
01648 #if NOTIMP_IMIN
01649 NOTIMPLEMENTED;
01650 #else
01651 NOTIMPLEMENTED;
01652 #endif
01653 END
01654 

Generated on Sun Mar 12 23:56:27 2006 for ScriptBasic by  doxygen 1.4.6-NO