Home page  
Help >
DDL Command CALC
Version 7.11
DDL Command CALC CALC

Compute a value. The formula is any mathematical formula and can involve data field names, literals, functions, and other variables. Several standard math functions are supported. A function may be used as any term in a formula.

Notation standards Variables Options Answers

Syntax:
CALC %variable = formula


Options:
X -Suppress the command response
Y -Do not alter the command answer cells

Answers:
Ctl.Ans1 =The integer portion of the value of the result
Ctl.Ans2 =Zero
Ctl.Ans3 =Zero (JDATE function only: =1 means bad input date)

The %answer cell from CALC contains the integer portion of the result. You can use this instead of the result if you are not interested in the fractional part of the result, or, if you are only interested in the fractional part of the result you can quickly obtain it by the calculation %result - %answer.

Notes:
The following command
calc %nn = 1

defines the variable %nn, establishes it as a numeric variable, and assigns it the value 1.0000. %nn is global and may be used in other commands, calculations, and reports.

FORMULA OPERATORS
--------------------------
+ addition
- subtraction
* multiplication
/ division
^ exponentiation
() used for grouping terms

Functions

A function consists of a function name, followed immediately by its arguments, which are enclosed in parentheses. For example,
      calc %num = sqrt(9) + 1
SQRT is the square root function; and the square root of 9 is 3; and 3+1 is 4.

As shown below, if a function has more than one argument they are separated by either a semicolon or a comma (no spaces), and the entire argument string is enclosed in parenthesis.

Each argument may itself be a formula that includes data fieldnames, literals, variables, and other functions. Functions supported by CALC are:

Arithmetic Functions
abs(arg) Absolute value of arg
exp(arg) The mathematical constant e (2.718281...) to the power arg
log(arg) The natural log of arg
log10(arg) The base 10 log of arg
sqrt(arg) The square root of arg
mod(arg1;arg2) The modulus (remainder) of arg1 divided by arg2
min(arg1;arg2) The minimum of arg1 and arg2
max(arg1;arg2) The maximum of arg1 and arg2
int(arg) The smallest integer <= arg
round(arg1;arg2) arg1 rounded to arg2 digits
numval(StringArg) The numeric value of string StringArg
strlen(StringArg) The number of characters in string StringArg
rand(arg) uniform random number between 0 and 1; if arg is non-zero, it becomes new seed
nurand(arg;x;y) non-uniform random number between x and y; arg is variability parameter


Trigonometric Functions
sin(angle) sine function of angle
cos(angle) cosine function of angle
tan(angle) tangent function of angle
asin(arg) arcsine function of arg
acos(arg) arccosine function of arg
atan(arg) arctangent function of arg
atan2(x;y) arctangent function of two sides x and y


Financial Functions
fv1(pmt;int;np) Future value for periodic payment (pmt), interest (int) and number of periods (np)
fv2(pv;int;np) Future value for present value (pv), periodic interest (int) and number of periods (np)
pv1(pmt;int;np) Present value for periodic payment (pmt), interest (int) and number of periods (np)
pv2(fv;int;np) Present value for future value (fv), periodic interest (int) and number of periods (np)
pmt1(int;np;pv) Payment amount for periodic interest (int), number of periods (np) and present value (pv)
pmt2(int;np;fv) Payment amount for periodic interest (int), number of periods (np) and future value (fv)
rate1(fv;pv;np) Periodic interest rate for future value (fv), present value (pv) and number of periods (np)
rate2(fv;pmt;np) Periodic interest rate for future value (fv), payment (pmt) and number of periods (np)
rate3(pv;pmt;np) Periodic interest rate for present value (pv), payment (pmt) and number of periods (np)
term1(pv;int;fv) Number of periods for present value (pv), periodic interest (int) and future value (fv)
term2(pmt;int;fv) Number of periods for periodic payment (pmt), periodic interest (int) and future value (fv)
term3(pmt;int;pv) Number of periods for periodic payment (pmt), periodic interest (int) and present value (fv)


Date and Time Functions
jdate(DateString;TemplateString) Numerical date of DateString per TemplateString
yrinc(NumDate;Delta;DOM) Increment base date (NumDate) by number of years (Delta); if DOM exceeds last DOM, use last DOM
moinc(NumDate;Delta;DOM) Increment base date (NumDate) by number of months (Delta); if DOM exceeds last DOM, use last DOM
dyinc(NumDate;Delta) Increment base date (NumDate) by number of days (Delta)
timediff(StartString;EndString) Time difference in seconds


Miscellaneous Functions
strmatch(Template;Subject;Control) Count one for each character in string Subject that matches the corresponding character in string Template and is in string Control
_storage(DriveLetter) Calculate the free file storage on drive DriveLetter
_absrecno(TableNameString) The absolute record number of the current record
_recno(TableNameString) The table-relative record number of the current record


Why did we use semicolons instead of commas in the above prototypes?

Descriptions and Examples:

Arithmetic Functions

Financial Functions
Date Functions
Counting Functions
Trigonometric Functions
Time Functions
Random Functions

Copyright © 2019 , WhamTech, Inc.  All rights reserved. This document is provided for information purposes only and the contents hereof are subject to change without notice. Names may be trademarks of their respective owners.