From bfa452a375ea0a0a3f95304a69186936567e5263 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Mon, 14 Aug 2023 19:45:36 +0200 Subject: New upstream version 4.1.4 --- docs/html/xbc4.html | 81 ----------------------------------------------------- 1 file changed, 81 deletions(-) delete mode 100755 docs/html/xbc4.html (limited to 'docs/html/xbc4.html') diff --git a/docs/html/xbc4.html b/docs/html/xbc4.html deleted file mode 100755 index a0275ed..0000000 --- a/docs/html/xbc4.html +++ /dev/null @@ -1,81 +0,0 @@ - - -Xbase DBMS Chapter 4 - -

Date Processing

-

Chapter Updated 12/09/22


- -The objective of this chapter is to provide information regarding -the basic concepts of date arithmetic and supply generic -C/C++ date methods.

- -

Leap Years

- -Due to the fact that it actually takes about 365 1/4 days for -the earth to circle the sun, every fourth year and every fourth -century have an extra day added to the end of February and the year -is called a leap year. Leap years have 366 days, non leap years -have 365 days. The following code segment describes how to -determine if a given year is a leap year. - -A leap year is a year having 366 days, which can be evenly -divisible by 4 and not by 100 or divisible by 400. - -There are also leap centuries. Leap centuries are years which -are evenly divisible by 400. - -To calculate a leap year, the following code segment can be used - - - int year; - - if(( year % 4 == 0 && year % 100 != 0 ) || year % 400 = 0 ) - LEAP_YEAR = TRUE; - else - LEAP_YEAR = FALSE - - - -

Julian Dates

- -Around the time of Jesus Christ, a fellow with the name of Julias Ceasar -established the Julian calendar. The Julian calendar established every -fourth year as a leap year with 366 days and all other years having 365 days. -The months were set up the same as they are with a Gregorian calendar, which -is what we use today. A Julian date is defined as as the number of days from the -first day of the year; February 1 would have a Julian day of 32.

- -From a programmer's perspective, Julian dates are useful for doing date -arithmetic, determining the difference between two dates or calculating -a future or past date.

- -To determine the difference between two dates, convert both dates to a -Julian date and subtract one from the other.

- -To calculate a future or past date, convert the base date to a Julian date, -add (or subtract) the number of days necessary to (from) it and convert the -julian date back to a Gregorian date.

- -The Julian date routines use a base date of 01/01/0001. DBase julian Dates have an offset of 1721425L, reason unknown. -

- -

Gregorian Dates

- -In 1582, Pope Gregor XIII introduced a corrected form of the Julian calendar. -Every 4th year still has 366 days except for century years. Century years -were added as leap years if evenly divisible by 400. The year 2000 is a leap century. -

- -The methods supplied with this software are based on gregorian dates with -the format of CCYYMMDD for century, year, month and day.

- - -

Date Formats

- -All dates are stored in the .DBF files with format CCYYMMDD.

-All date routines work with dates formated with the same CCYYMMDD format.

- -
-



- - -- cgit v1.2.3 From c894a7cdd8686ea695602a23a511a3f1b0d047be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Mon, 14 Aug 2023 21:07:46 +0200 Subject: New upstream version 4.1.4 --- docs/html/xbc4.html | 208 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 208 insertions(+) create mode 100755 docs/html/xbc4.html (limited to 'docs/html/xbc4.html') diff --git a/docs/html/xbc4.html b/docs/html/xbc4.html new file mode 100755 index 0000000..f8a48d9 --- /dev/null +++ b/docs/html/xbc4.html @@ -0,0 +1,208 @@ + + +Xbase DBMS Chapter 4 + +

Expression Handling

+

Chapter Updated 04/28/23


+ +

Overview

+ +The main objective of this chapter is to provide information regarding the +basic concepts of using the Xbase64 Expression module.

+ +The Xbase64 library includes an expression parsing routine which assists +application programmers by providing a high level data manipulation tool and +also allows for building complex index keys. + +The functions included were derived from dBASE III Plus, dBASE IV and Clipper. +

+Expressions are primarily used for index key definitions and filter criteria, but +can also be used for other tasks as well. +

+ +

Internal fuctioning

+The expression module works in two phases. Firstly, method +ParseExpression is called and builds an expression tree from +all the components of the expression. The tree is made up of individual +nodes. The expression is checked for valid field names, literals, +operands and functions. Any field references are resolved. If fields +are used in an expression and the database name for the field is not +included in the name with the -> operand, the routines assume the +associated database has been successfully opened. +

+Secondly, method ProcessExpression is called to process the +expression tree created by ParseExpression(). The routine parses each +node in the expression tree, executing functions, processing operands +and manipulating data to produce the desired result.

+ +If an expression will be processed repeatedly, it is best to pre-parse the +tree using ParseExpression, then for each new call to the expression, +execute method ProcessExpression which processes the tree. + +

Expression Return Types

+Expressions will return a type of CHAR, NUMERIC, DATE or LOGICAL.

+ +An expression return type can be determined with method +GetExpressionResultType after parsing it.

+ +Expressions returning a return type of CHAR are limited to a 200 byte internal +buffer. There is also a 100 byte limit for NDX and MDX index key support. If +the 200 byte limit is not large enough for your application, adjust field +enum { WorkBufMaxLen = 200 }; in file exp.h. + +

+ + + + + + +
Return TypeXBase Type
CHARxbString
NUMERICxbDouble
DATExbDate
LOGICALxbBool
+ +

+Date routines return an xbDate result. In addition, the date value can be +extracted using GetStringResult() which returns YYYYMMDD or GetDoubleResult() +which returns a julian value. + +

+

Expression Functions

+Each expression function also has a corresponding C++ function. It is +slightly more efficient to call the C++ functions directly, rather than +execute the expression parsing routines.

+ +To add a new function, find a function that is similar to what you need, copy +the code and modify xbxbase.h, xbfuncs.cpp, xbexp.cpp and xb_test_expression.cpp.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Function NameReturn TypeDescription
ABSNCalculate absolute value of numeric expression
ALLTRIMCTrim leading andtrailing whitespace from a string
ASCNReturn ASCII code for first character in a string
ATNReturn starting position of a string within a string
CDOWCRetun character weekday name for a date
CHRCConvert numeric expression to a character
CMONTHCReturn month name for a date
CTODDReturn date from a character date input
DATEDReturn system date
DAYNReturn the day of the month from a date
DELCReturn record deletion status for a record
DELETEDLReturn record deletion status for a record<
DESCEND1Clipper DESCEND function
DOWNReturn number of day of week
DTOCCReturn character date from input date
DTOSCReturn character CCYYMMDD date from input date
EXPNReturn exponent value
IIFCImmediate If
INTNConvert number to integer, truncate any decimals
ISALPHALCheck if string begins with alpha character
ISLOWERLCheck if string begins with lower case alpha character
ISUPPERLCheck if string begins with upper case character
LEFTCReturn left characters from a string
LENNReturn lenght of string
LOGNCalculate logarithm
LOWERCConvert upper case to lower case
LTRIMCTrim left side of a string
MAXNReturn higher of two values
MINNReturn lesser of two values
MONTHNReturn number of month for a given date
RECNONReturn current rec number for a given table
RECCOUNTNReturn number of records in a given table
REPLICATECRepeat character expression N times
RIGHTCReturn right characters from as tring
RTRIMCTrim right side of string
SPACECGenerate a string of N spaces
SQRTNCalculate square root
STODDConvert 8 byte CCYYMMDD date to date
STRCConvert number to character string
STRZEROCConvert number to character string with leading zeroes. Clipper Function.
SUBSTRCExtract portion oif one string from another string
TRIMCTrim left and right sides of a string
UPPERCConver lower case to upper case
VALNConvert numeric characters to number
YEARNReturn year for a given date
+ +

+

Expression Components

+Expressions are made up of one or more tokens. A token is one of literal, +database field, operand or function. Literals are either numeric or character. +Character literals are enclosed in 'single' or "double" quotes. numeric +literals are a series of one or more contiguous numerals, ".", "+" or "-'". +

+A field is simply a field name in the default database, or is in the form +of database->fieldname. + + +

+

Expression Literals

+ + + + + + +
TypeExample
CHAR"literal" or 'literal'
NUMERIC+99999.99
DATE{10/07/60} or {02/09/1989}
+ +

+

Expression Operators

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
TypeOperatorPrecedenceResultNotes
Parens()12
Numeric Operator+ (unary)11N
Numeric Operator- (unary)11N
Numeric Operator--X10N
Numeric Operator++X10N
Numeric Operator**9N
Numeric Operator^9N
Numeric Operator%8N
Numeric Operator*8N
Numeric Operator/8N
Numeric Operator+ Addition7N
Numeric Operator- Subtraction7N
Numeric OperatorX--6N
Numeric OperatorX++6N
String Operator+5CConcatonate 1
String Operator-5CConcatonate 2
Relational Operator=4LN,C,D
Relational Operator#, <>, !=4N,C,D
Relational Operator<4LN,C,D
Relational Operator>4LN,C,D
Relational Operator<=4LN,C,D
Relational Operator>=4LN,C,D
Relational Operator$4LN,C,D
Relational Operator==Clipper operator, not implemented yet
Logical OperatorNOT3LEvaluated after all math and relational operators
Logical Operator.NOT.3LEvaluated after all math and relational operators
Logical OperatorAND2LEvaluated after all math and relational operators
Logical Operator.AND.2LEvaluated after all math and relational operators
Logical OperatorOR1LEvaluated after all math and relational operators
Logical Operator.OR.1LEvaluated after all math and relational operators
+ +

+

Example Expressions

+
  • CUSTOMERS->LNAME + ", " + CUSTOMERS->FNAME +
  • LNAME + ", " + FNAME +
  • STARTDT + 90 +
  • DATE() - 7 +
  • YEAR( TODAY() ) +
  • IIF( "A" = "N", "true result", "false result" ) +
  • IIF( "A" = "N" .OR. 2 > 1 , "true result", "false result" ) +
  • IIF( .NOT. "A" = "N", "true result", "false result" ) +
  • .NOT. DELETED() +

    + + +

    Example program

    +For an example on how to use the expression logic, see program +src/examples/xb_ex_expression.cpp. +

    + +
    +



    + + -- cgit v1.2.3