📄 expfunc.cpp
字号:
// This is for a string - but it doesn't work yet// int i,j;// for(i = 7, j = 0; j < 8; i--, j++ ) // WorkBuf[j] = Date8[i];// WorkBuf[8] = 0x00;// return DayOf( XB_FMT_MONTH, Date8 );}/*************************************************************************///! Short description./*! \param Date8*/xbLong xbExpn::DOW( const char * Date8 ){ return DayOf( XB_FMT_WEEK, Date8 );}/*************************************************************************///! Short description./*! \param Date8*/char * xbExpn::DTOC( const char * Date8 ){ strcpy( WorkBuf, FormatDate( GetDefaultDateFormat(), Date8 )); return WorkBuf;}/*************************************************************************///! Short description./*! \param Date8*/char * xbExpn::DTOS( const char * Date8 ){ strcpy( WorkBuf, FormatDate( "YYYYMMDD", Date8 )); return WorkBuf;}/*************************************************************************///! Short description./*! \param d*/xbDouble xbExpn::EXP( xbDouble d ){ return exp( d );}/*************************************************************************///! Short description./*! \param d*/xbLong xbExpn::INT( xbDouble d ){ return (xbLong) d;}/*************************************************************************///! Short description./*! \param String*/xbLong xbExpn::ISALPHA( const char * String ){ if( isalpha(*String) ) return 1; else return 0;}/*************************************************************************///! Short description./*! \param String*/xbLong xbExpn::ISLOWER( const char * String ){ if( islower(*String) ) return 1; else return 0;}/*************************************************************************///! Short description./*! \param String*/xbLong xbExpn::ISUPPER( const char * String ){ if( isupper(*String) ) return 1; else return 0;}/*************************************************************************///! Short description./*! \param String*/xbLong xbExpn::LEN( const char * String ){ xbLong len; len = strlen( String ); len--; while( len >= 0 && String[len] == 0x20 ) len--; return ++len;}/*************************************************************************///! Short description./*! \param String \param Len*/char * xbExpn::LEFT( const char * String, xbShort Len ){ xbShort i; for( i = 0; i < Len && i < 100; i++ ) WorkBuf[i] = String[i]; WorkBuf[i] = 0x00; return WorkBuf;}/*************************************************************************///! Short description./*! \param String*//* This method removes any leading spaces from String */char * xbExpn::LTRIM( const char *String) { WorkBuf[0] = 0x00; if (!String) return WorkBuf; xbShort i; i = 0; while( *String && *String == 0x20 ) String++; while( *String && i < WorkBufMaxLen ){ WorkBuf[i++] = *String; String++; } WorkBuf[i] = 0x00; return WorkBuf;}/*************************************************************************///! Short description./*! \param d*/xbDouble xbExpn::LOG( xbDouble d ){ return log( d );}/*************************************************************************///! Short description./*! \param String*/char *xbExpn::LOWER( const char *String ) { WorkBuf[0] = 0x00; if (!String) return WorkBuf; xbShort i = 0; while( *String && i < WorkBufMaxLen) { WorkBuf[i++] = tolower( *String ); String++; } WorkBuf[i] = 0x00; return WorkBuf;}/*************************************************************************///! Short description./*! \param d1 \param d2*/xbDouble xbExpn::MAX( xbDouble d1, xbDouble d2 ){ if( d1 > d2 ) return d1; else return d2;}/*************************************************************************///! Short description./*! \param d1 \param d2*/xbDouble xbExpn::MIN( xbDouble d1, xbDouble d2 ){ if( d1 < d2 ) return d1; else return d2;}/*************************************************************************///! Short description./*! \param Date8*/xbLong xbExpn::MONTH( const char * Date8 ){ return MonthOf( Date8 );}/*************************************************************************///! Short description./*! \param d*/xbLong xbExpn::RECNO( xbDbf * d ) { return d->GetCurRecNo();}/*************************************************************************///! Short description./*! \param CurRec*/char * xbExpn::RECNO( xbULong CurRec ) { sprintf( WorkBuf, "%ld%c", CurRec, 0 ); return WorkBuf;}/*************************************************************************///! Short description./*! \param String \param Cnt*/char * xbExpn::REPLICATE( const char * String, xbShort Cnt ){ xbShort len, i; len = strlen( String ); if(( len * Cnt ) > 100 ) return NULL; memset( WorkBuf, 0x00, len+1 ); for( i = 0; i < Cnt; i++ ) strcat( WorkBuf, String ); return WorkBuf;}/*************************************************************************///! Short description./*! \param String \paran cnt*/char * xbExpn::RIGHT( const char * String, xbShort cnt ){ xbShort len; strcpy( WorkBuf, String ); len = strlen( String ); if( len < cnt ) return WorkBuf; len = LEN( String ); if( len < cnt ) return WorkBuf; strcpy( WorkBuf, String + len - cnt ); return WorkBuf;}/*************************************************************************///! Short description./*! \param String*/char * xbExpn::RTRIM( const char * String ){ return TRIM( String );}/*************************************************************************///! Short description./*! \param Cnt*/char * xbExpn::SPACE( xbShort Cnt ){ if( Cnt > 100 ) return NULL; memset( WorkBuf, 0x20, Cnt ); WorkBuf[Cnt] = 0x00; return WorkBuf;} /*************************************************************************///! Short description./*! \param d*/xbDouble xbExpn::SQRT( xbDouble d ){ return sqrt( d );}/*************************************************************************///! Short description./*! \param d \param length \param numDecimals*/char * xbExpn::STR(xbDouble d, xbUShort length, xbShort numDecimals) { // sanity check for length arg if (length > WorkBufMaxLen) { // maybe should generate an error here instead ? length = WorkBufMaxLen; } // check the length required sprintf(WorkBuf, "%.*f", numDecimals, d); if (strlen(WorkBuf) > length) { memset(WorkBuf, '*', length); WorkBuf[length] = 0x00; } else sprintf( WorkBuf, "%*.*f", length, numDecimals, d ); return WorkBuf;}/*************************************************************************///! Short description./*! \param d \param length*/char * xbExpn::STR( xbDouble d, xbShort length ){ return STR( d, length, 0 );}/*************************************************************************///! Short description./*! \param d*/char * xbExpn::STR( xbDouble d ){ return STR( d, 10, 0 );}/*************************************************************************///! Short description./*! \param String \param length \param*/char * xbExpn::STR( const char * String, xbShort length, xbShort ){ xbShort len, i; len = strlen( String ); strcpy( WorkBuf, String ); for( i = len; i < length; i++ ) WorkBuf[i] = 0x20; WorkBuf[i] = 0x00; return WorkBuf;}/*************************************************************************///! Short description./*! \param String \param length*/char * xbExpn::STR( const char *String, xbShort length ){ return STR( String, length, 0 );}/*************************************************************************///! Short description./*! \param String*/char * xbExpn::STR( const char * String ){ return STR( String, 10, 0 );}/*************************************************************************///! Short description./*! \param d \param length \param */char * xbExpn::STRZERO( xbDouble d, xbShort length, xbShort ){ xbShort len,i; sprintf(WorkBuf, "%*.*g", length, length, d);// gcvt( d, length, WorkBuf ); len = strlen( WorkBuf ); if( len > length ) strcpy( WorkBuf, "**********" ); else if( len < length ) { for( i = len; i < length; i++ ) WorkBuf[i] = 0x30; WorkBuf[i] = 0x00; } return WorkBuf;}/*************************************************************************///! Short description./*! \param d \param length*/char * xbExpn::STRZERO( xbDouble d, xbShort length ){ return STRZERO( d, length, 0 );}/*************************************************************************///! Short description./*! \param d*/char * xbExpn::STRZERO( xbDouble d ){ return STRZERO( d, 10, 0 );}/*************************************************************************///! Short description./*! \param String \param length \param*/char * xbExpn::STRZERO( const char * String, xbShort length, xbShort ){ xbShort i, len ; while( *String == ' ' ) String++; len = strlen(String); for( i = 0; i < abs( length-len); i++ ) WorkBuf[i] = 0x30; WorkBuf[i] = 0x00; strcat( WorkBuf, String ); return WorkBuf;}/*************************************************************************///! Short description./*! \param String \param length*/char * xbExpn::STRZERO( const char * String, xbShort length ){ return STRZERO( String, length, 0 );}/*************************************************************************///! Short description./*! \param String*/char * xbExpn::STRZERO( const char * String ){ return STRZERO( String, 10, 0 );}/*************************************************************************///! Short description./*! \param String \param StartPos \param Len*/char * xbExpn::SUBSTR( const char * String, xbShort StartPos, xbShort Len ){ xbShort i; if( StartPos < 1 ) return NULL; String += (StartPos - 1); for( i = 0; i < Len; i++ ) WorkBuf[i] = *String++; WorkBuf[i] = 0x00; return WorkBuf;}/*************************************************************************///! Short description./*!*/char * xbExpn::DATE(){ xbDate d; strcpy( WorkBuf, d.Sysdate()); return WorkBuf;}/*************************************************************************///! Short description./*! \param String*/char * xbExpn::TRIM( const char * String ){ WorkBuf[0] = 0x00; if( !String ) return WorkBuf; char *sp; xbShort len; len = strlen( String ); if( len < WorkBufMaxLen ) { strcpy( WorkBuf, String ); } else { strncpy( WorkBuf, String, WorkBufMaxLen ); WorkBuf[ WorkBufMaxLen ] = 0x00; len = WorkBufMaxLen; } sp = WorkBuf + len - 1; while( *sp == 0x20 && sp >= WorkBuf ) { *sp = 0x00; sp--; } return WorkBuf;}/*************************************************************************///! Short description./*! \param String*/char *xbExpn::UPPER( const char *String ){ WorkBuf[0] = 0x00; if (!String) return WorkBuf; xbShort i; i = 0; while(*String && i < WorkBufMaxLen) { WorkBuf[i++] = toupper(*String); String++; } WorkBuf[i] = 0x00; return WorkBuf;}/*************************************************************************///! Short description./*! \param String*/xbLong xbExpn::VAL( const char * String ){ if( String ) return (xbLong) *String; else return 0;}/*************************************************************************///! Short description./*! \param Date8*/xbLong xbExpn::YEAR( const char * Date8 ){ return YearOf( Date8 );}/*************************************************************************/#endif // XB_EXPRESSIONS
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -