Download as pdf or txt
Download as pdf or txt
You are on page 1of 108

Volume 3 Chapter 3 Formulas

3 Formulas

This chapter provides detailed descriptions of the formulas in the MP language. For a discussion of
how formulas are used in the MP language and the rules for their usage, please see Formulas in
Volume 1 of the MP Post Processor Reference Guide.

Formulas are applied to the two MP language statement types that allow formulas:
the formula statement
the conditional branching statement
Both of these statement types use the same syntax in the argument portion of the statement. The major
difference between the two types are the Boolean statement, which evaluates for zero or non-zero in the
result of the formula, and the formula statement, which makes an assignment to the variable that is the
target of the formula.

Difference between formulas and functions


Formulas refer to math operators and math formulas described in this chapter. The term function is
used to describe the unique mechanisms in the MP language that support the string select feature,
lookup table features, buffer files, and the user prompt feature. These function mechanisms rely on a
declaration in the post customization file for the feature and a formula as the calling method.
See Volume 1, Post Functions for more information.

MP post formula types


Formulas can be divided into categories as represented here. (When reading this document online, you
can use the links to jump to the specific operators or functions in each category. A link is provided in
the category to the specific operator or function to see a detailed description of the item.)
Basic math functions –Math operators that perform the basic math functions (the assignment operator
(=), addition, subtraction, multiplication, division, etc.).
Logic operators – Logical operators for Boolean evaluation. Operators to test for equal, greater than,
less than, and, or, etc.
Advanced math functions – Math functions including square root, logarithms, absolute values,
rounding and others.
Trigonometric functions – Standard trigonometric functions for sine, cosine and tangent of an angle.
An extremely useful function atan2 returns the solution of the arc tangent within the 360 degree range.

November 2002 Mastercam Version 9.1 MP Post Processor Reference Guide 3--1
Chapter 3 Formulas Volume 3

2D vector math – Single plane functions for vector addition and subtraction, and scaling. Even when
working in a single plane, it is recommended that you describe numeric variables as 3D positions. 2D
vector math functions are used less frequently because the 3D vector math functions are more
powerful.
3D vector math – 3D functions for vector addition and subtraction. Functions to rotate vectors and
points about an axis are also provided in this category.
Matrix math – Matrix functions allow for mapping within the matrix that defines a Cartesian coordinate
system. Other matrix manipulation functions such as matrix transpose are also available.
Special MP functions– Calls to the lookup table functions and buffer file function. Other unique
formulas to determine the negative, zero, or positive of a numeric variable are provided here.
Intersection functions – Planar intersection routines for line-line, arc-line and arc-arc.
String functions – String manipulation functions. String variables can be broken, values scanned from
a string, case changed, etc.
Conversion functions – Formulas to convert strings to numeric variables.
File functions – Powerful file manipulation functions to rename and remove files. File functions also
allow launching another program or Mastercam C-Hook.
Precedence functions – Parentheses are used to control the precedence in an assignment formula or a
Boolean formula.
Binary functions – Bit-wise functions.

Post formulas by type


Basic math functions
-
- (unary)
*
/
^
+
=

Logic operators
&
|
<
<=
<>
=
>
>=
3-2 Mastercam Version 9.1 MP Post Processor Reference Guide November 2002
Volume 3 Chapter 3 Formulas

not

Advanced math functions


abs
fmtrnd
frac
int
log
log10
round
sqrt

Trigonometric functions
acos
atan
atan2
cos
sin
tan

2D vector math
axb
dot
lng
rot
vad
veq
vlh
vnr
vrh
vsa
vsb
vsc

3D vector math
dot3
lng3
rotp
rotv
vadd
vaxb
vequ
vnrm
vsca
vscl
vsub
November 2002 Mastercam Version 9.1 MP Post Processor Reference Guide 3--3
Chapter 3 Formulas Volume 3

Matrix math
matt
mmap
mmul
mteq
vmap

Special MP functions
finc
flook
fprm
frange
fsg1
fsg2
fsg3
updgbl
rbuf
rpar
slin
slout
vlin
vlout
wbuf

Intersection functions
xaa
xla
xll

String functions
brksps
lcase
nwadrs
scan
strlen
strstr
ucase
updstr

Conversion functions
newfs
no2asc
no2str
plcval

3-4 Mastercam Version 9.1 MP Post Processor Reference Guide November 2002
Volume 3 Chapter 3 Formulas

File functions
dll
fclose
fexist
launch
mprint
remove
rename

Precedence functions
(
)

Binary functions
and
ger
good
ior
xor

November 2002 Mastercam Version 9.1 MP Post Processor Reference Guide 3--5
Chapter 3 Formulas Volume 3

Formula descriptions
= (assignment)
Formula Type Basic math functions
Description Assignment
Form result assignment argument
result assignment function argument
result assignment argument operator argument
Return Type Depends on formula
Formula Code Ex. x=y
x=y+z
c = atan2(x, y)
Boolean Code Ex. Not interpreted in conditional branching statement

Notes These are the basic assignment forms. They may be combined as
required.

3-6 Mastercam Version 9.1 MP Post Processor Reference Guide November 2002
Volume 3 Chapter 3 Formulas

+
Formula Type Basic math functions
Description Addition
Form argument operator argument
First Argument numeric variable, value (scalar)
string variable
Second Argument numeric variable, value (scalar)
string variable
Return Type numeric variable (scalar)
string variable
Formula Code Ex. x=y–z
string1 = string2 + string3
Boolean Code Ex. if (x + y) = 2, p_action
if (string1 + string2) = string3, p_action
Notes Argument types must match. A maximum of 10 string variables may
be added (concatenated) in a single formula.

November 2002 Mastercam Version 9.1 MP Post Processor Reference Guide 3--7
Chapter 3 Formulas Volume 3

-
Formula Type Basic math functions
Description Subtraction
Form argument operator argument
First Argument numeric variable, value (scalar)
Second Argument numeric variable, value (scalar)
Return Type numeric variable (scalar)
Formula Code Ex. x=y–z

Boolean Code Ex. if (x – y) = 2, p_action

Notes

3-8 Mastercam Version 9.1 MP Post Processor Reference Guide November 2002
Volume 3 Chapter 3 Formulas

– (unary)
Formula Type Basic math functions
Description Unary minus
Form operator argument
First Argument numeric variable (scalar)
Second Argument numeric variable (scalar)
Return Type numeric variable (scalar)
Formula Code Ex. x = –y
x = y * (–z)
Boolean Code Ex. if -x = 2, p_action

Notes Do not use multiple unary operators, for example, – – –x.

November 2002 Mastercam Version 9.1 MP Post Processor Reference Guide 3--9
Chapter 3 Formulas Volume 3

*
Formula Type Basic math functions
Description Multiplication
Form argument operator argument
First Argument numeric variable, value (scalar)
Second Argument numeric variable, value (scalar)
Return Type numeric variable (scalar)
Formula Code Ex. x=y*z

Boolean Code Ex. if (x * y) = 2, p_action

Notes

3-10 Mastercam Version 9.1 MP Post Processor Reference Guide November 2002
Volume 3 Chapter 3 Formulas

/
Formula Type Basic math functions
Description Division
Form argument operator argument
First Argument numeric variable, value (scalar)
Second Argument numeric variable, value (scalar)
Return Type numeric variable (scalar)
Formula Code Ex. x=y/z

Boolean Code Ex. if (x / y) = 2, p_action

Notes Avoid having a denominator of 0. This condition generates a fatal


error.

November 2002 Mastercam Version 9.1 MP Post Processor Reference Guide 3--11
Chapter 3 Formulas Volume 3

^
Formula Type Basic math functions
Description Power. Raises the first argument to the power of the second argument.
Form argument operator argument
First Argument numeric variable, value (scalar)
Second Argument numeric variable, value (scalar)
Return Type numeric variable (scalar)
Formula Code Ex. x=y^z

Boolean Code Ex. if (x^ y) = 25, p_action

Notes

3-12 Mastercam Version 9.1 MP Post Processor Reference Guide November 2002
Volume 3 Chapter 3 Formulas

= (Boolean)
Formula Type Logic operators
Description Logical comparison. True if values are equal.
Form argument operator argument
First Argumentnumeric variable, value (scalar)
string variable
Second Argument numeric variable, value (scalar)
string variable
Return Type numeric variable (Boolean result)
string variable
Formula Code Ex. real_result = x = y
real_result = string1 = string2
Boolean Code Ex. if x = y, p_action
if string1 = string2, p_action
Notes Argument types must match. The return is 0 if false and 1 if true.
Nested return values are stored internally to the post executable.

November 2002 Mastercam Version 9.1 MP Post Processor Reference Guide 3--13
Chapter 3 Formulas Volume 3

<
Formula Type Logic operators
DescriptionLogical comparison. True if first argument is less than second
argument.
Form argument operator argument
First Argument numeric variable, value (scalar)
Second Argument numeric variable, value (scalar)
Return Type numeric variable (Boolean result)
Formula Code Ex. real_result = x < y

Boolean Code Ex. if x < y, p_action

Notes The return is 0 if false and 1 if true. Nested return values are stored
internally to the post executable.

3-14 Mastercam Version 9.1 MP Post Processor Reference Guide November 2002
Volume 3 Chapter 3 Formulas

>
Formula Type Logic operators
DescriptionLogical comparison. True if first argument is greater than second
argument.
Form argument operator argument
First Argument numeric variable, value (scalar)
Second Argument numeric variable, value (scalar)
Return Type numeric variable (Boolean result)
Formula Code Ex. real_result = x > y

Boolean Code Ex. if x > y, p_action

Notes The return is 0 if false and 1 if true. Nested return values are stored
internally to the post executable.

November 2002 Mastercam Version 9.1 MP Post Processor Reference Guide 3--15
Chapter 3 Formulas Volume 3

<=
Formula Type Logic operators
DescriptionLogical comparison. True if first argument is less than or equal to the
second argument.
Form argument operator argument
First Argument numeric variable, value (scalar)
Second Argument numeric variable, value (scalar)
Return Type numeric variable (Boolean result)
Formula Code Ex. real_result = x <= y

Boolean Code Ex. if x <= y, p_action

Notes The return is 0 if false and 1 if true. Nested return values are stored
internally to the post executable.

3-16 Mastercam Version 9.1 MP Post Processor Reference Guide November 2002
Volume 3 Chapter 3 Formulas

>=
Formula Type Logic operators
DescriptionLogical comparison. True if first argument is greater than or equal to
the second argument.
Form argument operator argument
First Argument numeric variable, value (scalar)
Second Argument numeric variable, value (scalar)
Return Type numeric variable (Boolean result)
Formula Code Ex. real_result = x >= y

Boolean Code Ex. if x >= y, p_action

Notes The return is 0 if false and 1 if true. Nested return values are stored
internally to the post executable.

November 2002 Mastercam Version 9.1 MP Post Processor Reference Guide 3--17
Chapter 3 Formulas Volume 3

<>
Formula Type Logic operators
Description Logical comparison. True if values are not equal.
Form argument operator argument
First Argument numeric variable, value (scalar)
string variable
Second Argument numeric variable, value (scalar)
string variable
Return Type numeric variable (Boolean result)
Formula Code Ex. real_result = x <> y
real_result = string1 <>string2
Boolean Code Ex. if x <> y, p_action
if string1 <> string2, p_action
Notes Argument types must match. The return is 0 if false and 1 if true.
Nested return values are stored internally to the post executable.

3-18 Mastercam Version 9.1 MP Post Processor Reference Guide November 2002
Volume 3 Chapter 3 Formulas

&
Formula Type Logic operators
Description Logical “and”.
Arg1 Arg2 Result
1 1 1
1 0 0
0 1 0
0 0 0
Form argument operator argument
First Argument numeric variable, value (scalar)
Second Argument numeric variable, value (scalar)
Return Type numeric variable (Boolean result)
Formula Code Ex. real_result = x & y

Boolean Code Ex. if x & y, p_action

Notes The return is 0 if false and 1 if true. Nested return values are stored
internally to the post executable.

November 2002 Mastercam Version 9.1 MP Post Processor Reference Guide 3--19
Chapter 3 Formulas Volume 3

|
Formula Type Logic operators
Description Logical “or”.

Arg1 Arg2 Result


1 1 1
1 0 1
0 1 1
0 0 0
Form argument operator argument
First Argument numeric variable, value (scalar)
Second Argument numeric variable, value (scalar)
Return Type numeric variable (Boolean result)
Formula Code Ex. real_result = x | y

Boolean Code Ex. if x | y, p_action

Notes The return is 0 if false and 1 if true. This character is the pipe character
(ASCII decimal equivalent 124). Nested return values are stored
internally to the post executable.

3-20 Mastercam Version 9.1 MP Post Processor Reference Guide November 2002
Volume 3 Chapter 3 Formulas

(, )
Formula Type Precedence function
Description Open and close parentheses are used to control the precedence of
operation. Depending on the nesting levels, the formulas nested
deepest are evaluated first.
Form operator argument operator
Formula Code Ex. real_result = (x * (2 + y)) ^ z / (x – y)

Boolean Code Ex. if (x > 2 & x <> 3) | (fmtrnd(y) & fmtrnd(z)), p_action

Notes Nesting parentheses must always match the open parenthesis to the
closing parenthesis. Do not confuse the parentheses used in the
formula functions (for example, abs(x)) with those used for precedence
nesting.

November 2002 Mastercam Version 9.1 MP Post Processor Reference Guide 3--21
Chapter 3 Formulas Volume 3

abs
Formula Type Advanced Math Functions
Description Returns the absolute value of the argument.
Form function argument
Argument numeric variable, value (scalar)
Return Type numeric variable (scalar) as a positive value
Formula Code Ex. real_result = abs(x)

Boolean Code Ex. if abs(x) < mtol, “THIS IS A SMALL NUMBER”

Notes Nested return values are stored internally to the post executable.

3-22 Mastercam Version 9.1 MP Post Processor Reference Guide November 2002
Volume 3 Chapter 3 Formulas

acos
Formula Type Trigonometric function
DescriptionArc cosine. Returns the ratio of the adjacent angle to the hypotenuse of
a right triangle.
Form function argument
Argument numeric variable, value (scalar)
Return Type numeric variable (angle)
Formula Code Ex. real_result = acos(x/y)

Boolean Code Ex. if acos(x/y) > 45, p_action

Notes Nested return values are stored internally to the post executable.

November 2002 Mastercam Version 9.1 MP Post Processor Reference Guide 3--23
Chapter 3 Formulas Volume 3

and
Formula Type Binary function
Description Bitwise and operation. Converts the two arguments to binary and then
performs the “and” comparison on the individual bits.
Bit Bit Result
1 1 1
1 0 0
0 1 0
0 0 0

The return value is the resulting value.


Form function argument, argument
First Argument numeric variable, value (scalar)
Second Argument numeric variable, value (scalar)
Return Type numeric variable (scalar)
Formula Code Ex. real_result = and(real_var1, real_var2)

Boolean Code Ex. if and(real_var1, real_var2) = 2, p_action

Notes Integer values are expected. Nested return values are stored internally
to the post executable. This form of “and” is rarely used.

3-24 Mastercam Version 9.1 MP Post Processor Reference Guide November 2002
Volume 3 Chapter 3 Formulas

asin
Formula Type Trigonometric function
DescriptionArc sine. Returns the ratio of the opposite angle to the hypotenuse of a
right triangle.
Form function argument
Argument numeric variable, value (scalar)
Return Type numeric variable (angle)
Formula Code Ex. real_result = asin(x/y)

Boolean Code Ex. if asin(x/y) > 45, p_action

Notes Nested return values are stored internally to the post executable.

November 2002 Mastercam Version 9.1 MP Post Processor Reference Guide 3--25
Chapter 3 Formulas Volume 3

atan
Formula Type Trigonometric function
DescriptionArc tangent. Returns the ratio of the opposite angle to the adjacent
angel of a right triangle.
Form function argument
Argument numeric variable, value (scalar)
Return Type numeric variable (angle)
Formula Code Ex. real_result = atan(x/y)

Boolean Code Ex. if atan(x/y) > 45, p_action

Notes Nested return values are stored internally to the post executable.

3-26 Mastercam Version 9.1 MP Post Processor Reference Guide November 2002
Volume 3 Chapter 3 Formulas

atan2
Formula Type Trigonometric function
Description Arc tangent (two argument). Returns the angle (0 to 360 degrees) of the
arguments passed to the formula. The second argument axis indicates
the axis for the zero angle position. The first argument axis indicates
the direction from the second argument axis (which defines the zero
angle) is in the positive angle direction. These arguments are signed to
indicate
choice.

Form function argument, argument


First Argument numeric variable, value (scalar), represents positive direction
Second Argument numeric variable, value (scalar), represents zero angle
Return Type numeric variable (angle)
Formula Code Ex. real_result = atan2(x, y)

Boolean Code Ex. if atan2(x, y) >180, p_action

Notes Nested return values are stored internally to the post executable.

November 2002 Mastercam Version 9.1 MP Post Processor Reference Guide 3--27
Chapter 3 Formulas Volume 3

axb
Formula Type 2D vector math function
DescriptionPlanar cross product. The formula takes the product of the arguments
(unitized vectors) and returns the sine of the angle between them.
Form function argument, argument
First Argument numeric variable (3D vector, unitized)
Second Argument numeric variable (3D vector, unitized)
Return Type numeric variable (scalar)
Formula Code Ex. real_result = axb(v3_x1, v3_x2)

Boolean Code Ex. Not allowed as a Boolean statement

Notes This is a 2D function. It is recommended that 3D vectors be used and


the last element in the implied array remain 0.

3-28 Mastercam Version 9.1 MP Post Processor Reference Guide November 2002
Volume 3 Chapter 3 Formulas

brksps
Formula Type String function
DescriptionBreaks a string variable before the index position (one-based) specified
by the value in the first argument. The original string variable (second
argument) holds the start of the broken string and the return string
variable holds the remainder of the string.
Form function argument, argument
First Argument numeric variable, value (scalar)
Second Argument string variable
Return Type string variable
Formula Code Ex. real_var1 : 8
string1 "one two three four"
string2

pblock # A postblock
string2 = brksps (real_var1, string1)

In this example, string1 = "one two" and string2 = " three four".
Boolean Code Ex. Not allowed as a Boolean statement

Notes

November 2002 Mastercam Version 9.1 MP Post Processor Reference Guide 3--29
Chapter 3 Formulas Volume 3

cos
Formula Type Trigonometric function
DescriptionCosine. Returns the ratio of the adjacent angle to the hypotenuse of a
right triangle.
Form function argument
Argument numeric variable, value (angle)
Return Type numeric variable (scalar)
Formula Code Ex. real_result = cos(angle)

Boolean Code Ex. if cos(angle) > .7071, p_action

Notes Nested return values are stored internally to the post executable.

3-30 Mastercam Version 9.1 MP Post Processor Reference Guide November 2002
Volume 3 Chapter 3 Formulas

dll
Formula Type File function
DescriptionLaunches a Mastercam C-Hook (DLL) from the post executable. This
function is only available in the DLL versions of the post executable.
The first argument is the DLL to be executed, the second argument is a
string that can pass up to three arguments to the C-Hook. These
arguments are passed to Mastercam using the exported string variable,
post_args[0], post_args[1] and post_args[2]. Refer to the C-Hook
development documentation.
Form function argument, argument
First Argument string variable
Second Argument string variable
Return Type numeric variable (scalar), always returns 1
Formula Code Ex. string1 "c:\mcam81\adll.dll"
string2 ' "first" "second" "third" '

pblock # A postblock
real_result = dll(string1, string2)
Boolean Code Ex. Not allowed as a Boolean statement

Notes The second argument is parsed on the sets of double quotes. (Follow
the example when passing the parameters.) Do not attempt to launch
the post executable DLL from itself.

November 2002 Mastercam Version 9.1 MP Post Processor Reference Guide 3--31
Chapter 3 Formulas Volume 3

dot
Formula Type 2D vector math function
DescriptionPlanar dot product. The formula takes the product of the arguments
(unitized vectors) and returns the cosine of the angle between them.
Form function argument, argument
First Argument numeric variable (3D vector, unitized)
Second Argument numeric variable (3D vector, unitized)
Return Type numeric variable (scalar)
Formula Code Ex. real_result = dot(v3_x1, v3_x2)

Boolean Code Ex. Not allowed as a Boolean statement

Notes This is a 2D function. It is recommended that 3D vectors be used and


the last element in the implied array remain 0.

3-32 Mastercam Version 9.1 MP Post Processor Reference Guide November 2002
Volume 3 Chapter 3 Formulas

dot3
Formula Type 3D vector math function
DescriptionDot product. The formula takes the product of the arguments (unitized
vectors) and returns the cosine of the angle between them.
Form function argument, argument
First Argument numeric variable (3D vector, unitized)
Second Argument numeric variable (3D vector, unitized)
Return Type numeric variable (scalar)
Formula Code Ex. real_result = dot3(v3_x1, v3_x2)

Boolean Code Ex. Not allowed as a Boolean statement

Notes

November 2002 Mastercam Version 9.1 MP Post Processor Reference Guide 3--33
Chapter 3 Formulas Volume 3

fclose
Formula Type File function
DescriptionCloses the NC output file, the alternate files (.sub, .aux, .ext), or the
buffer files. If the argument passed is a string variable that is the file
name and extension of the NC file or one of the alternate files, the file
with the matching name is closed. Passing a numeric variable or value
that is 1 to 10 to represent a buffer number will close the appropriate
buffer file. The returned value is 0 if the file was closed successfully or
1 if the function failed.
Form function argument
Argument numeric variable
string variable
Return Type numeric variable (Boolean result)
Formula Code Ex. string1 "file.sub"

pblock # A postblock
real_result = fclose (string1) # Close the matching filename
real_result = fclose (1) # Close buffer no. 1
Boolean Code Ex. pblock # A postblock
if fclose (string1), “FILE FAILED TO CLOSE”
Notes Use this formula when it is necessary to close a buffer file and reopen it
with a new name.

3-34 Mastercam Version 9.1 MP Post Processor Reference Guide November 2002
Volume 3 Chapter 3 Formulas

fexist
Formula Type File function
DescriptionDetermine if the file name exists. The argument is the full path name
of the file to check. The return value is 0 if the file was not found or 1
if the file is found.
Form function argument
Argument string variable
Return Type numeric variable (Boolean result)
Formula Code Ex. string1 "c:\mcam81\file.txt"

pblock # A postblock
real_result = fexist (string1)
Boolean Code Ex. pblock # A postblock
if fexist (string1), “FILE FOUND”
Notes

November 2002 Mastercam Version 9.1 MP Post Processor Reference Guide 3--35
Chapter 3 Formulas Volume 3

finc
Formula Type Special MP function
DescriptionLookup table function to increment the count of the matching values
on each call to the table. The count is initialized in the lookup table in
the first column to the corresponding match value in column two. The
first argument in the formula is the table number (flktbl) to compare the
value in. The second argument is the value to match to the value in the
second column in the lookup table. The returned value is the current
count of the matched value.
Form function argument, argument
First Argument numeric variable, value (scalar)
Second Argument numeric variable, value (scalar)
Return Type numeric variable (scalar)
Formula Code Ex. flktbl 1 3 # Lookup table 1 with 3 entries for tool usage
0 1 # Tool number
0 2
0 3
pblock # A postblock
real_var = finc (1, t)
Boolean Code Ex. Not allowed as a Boolean statement

Notes This formula is the calling mechanism to the lookup table.


See Volume 1, Post Functions for more information.

3-36 Mastercam Version 9.1 MP Post Processor Reference Guide November 2002
Volume 3 Chapter 3 Formulas

flook
Formula Type Special MP function
DescriptionLookup table function to return the value in the first column of the
lookup table based on the closest match to the value in column two and
the value passed in the second argument of the formula. The first
argument in the formula is the table number (flktbl). The second
argument is the value to obtain the closest match to the value in the
second column in the lookup table. The returned value is the
corresponding value in column one.
Form function argument, argument
First Argument numeric variable, value (scalar)
Second Argument numeric variable, value (scalar)
Return Type numeric variable (scalar)
Formula Code Ex. real_var2 : 175
flktbl 1 3 # Lookup table 1 with 3 entries
10 100
20 200
30 300
pblock # A postblock
real_var = flook (1, real_var2)

In this example, real_var = 20


Boolean Code Ex. Not allowed as a Boolean statement

Notes This formula is the calling mechanism to the lookup table.


See Volume 1, Post Functions for more information.

November 2002 Mastercam Version 9.1 MP Post Processor Reference Guide 3--37
Chapter 3 Formulas Volume 3

fmtrnd
Formula Type Advanced Math Functions
DescriptionReturns the rounded value of the argument. The format statement (fs)
for the variable is used for rounding. If no format assignment was
given, the format statement one (fs 1) is used. This does not modify the
internal state of the argument value.
Form function argument
Argument numeric variable, value (scalar)
Return Type numeric variable (scalar)
Formula Code Ex. real_result = fmtrnd(x)

Boolean Code Ex. if fmtrnd(x) <> prv_x, “CURRENT VALUE DOES NOT EQUAL PREVIOUS”

Notes Nested return values are stored internally to the post executable. This
formula is normally used to compare rounded values (updated variable)
to un-rounded values without disturbing the internal value of the un-
rounded value.

3-38 Mastercam Version 9.1 MP Post Processor Reference Guide November 2002
Volume 3 Chapter 3 Formulas

fprm
Formula Type Special MP function
DescriptionThis formula provides access to a lookup table function (fprmtbl) to
provide a simpler method of capturing parameters passed from the NCI
file or operation parameter (.OPS) file. The first column of the lookup
table defines the parameter NCI Gcode 10000s prmcode to match. The
second column in the lookup table lists the target variables to place the
contents of the NCI Gcode parameter string sparameter in. The lookup
table number is normally defined as the operation code opcode for the
operation parameter set to capture. The argument passed in the
formula is the lookup table number. The returned value is 0 if the
lookup table was not found or 1 if the table is found.
Form function argument
Argument numeric variable, value (scalar)
Return Type numeric variable (Boolean result)
Helper Variables prmcode, sparameter
Formula Code Ex. flktbl 1 3 # Lookup table 1 with 3 entries
10000 string1
10001 string2
10005 real_var

pblock # A postblock
real_result = fprm (1)
Boolean Code Ex. Not allowed as a Boolean statement

Notes This formula is the calling mechanism to the lookup table.


See Volume 1, Post Functions and Volume 2, Parameter information
for more information.

November 2002 Mastercam Version 9.1 MP Post Processor Reference Guide 3--39
Chapter 3 Formulas Volume 3

frac
Formula Type Advanced Math Functions
Description Returns the fractional part of a value.
Form function argument
Argument numeric variable, value (scalar)
Return Type numeric variable (scalar)
Formula Code Ex. real_var : 1.23

pblock # A postblock
real_result = frac(real_var)

In this example, real_result holds .23


Boolean Code Ex. if frac(x), “FRACTION IN VALUE”

Notes Nested return values are stored internally to the post executable.

3-40 Mastercam Version 9.1 MP Post Processor Reference Guide November 2002
Volume 3 Chapter 3 Formulas

frange
Formula Type Special MP function
DescriptionLookup table function to return the value in the first column of the
lookup table based on the matching value in column two that is equal
or less than the value passed in the second argument of the formula.
The first argument in the formula is the table number (flktbl). The
second argument is the value to obtain the match to the value in the
second column in the lookup table. The returned value is the
corresponding value in column one.
Form function argument, argument
First Argument numeric variable, value (scalar)
Second Argument numeric variable, value (scalar)
Return Type numeric variable (scalar)
Formula Code Ex. real_var2 : 175
flktbl 1 3 # Lookup table
10 100
20 200
30 300
pblock # A postblock
real_var = frange (1, real_var2)

In this example, real_var = 10


Boolean Code Ex. Not allowed as a Boolean statement

Notes This formula is the calling mechanism to the lookup table.


See Volume 1, Post Functions for more information.

November 2002 Mastercam Version 9.1 MP Post Processor Reference Guide 3--41
Chapter 3 Formulas Volume 3

fsg1
Formula Type Advanced Math Functions
DescriptionReturns 0 for values less than 0, or 1 for values greater than or equal to
0.
Form function argument
Argument numeric variable, value (scalar)
Return Type numeric variable (scalar)
Formula Code Ex. real_result = fsg1(x)

Boolean Code Ex. if fsg1(x), “THE VALUE IS LESS THAN ZERO”

Notes Nested return values are stored internally to the post executable.

3-42 Mastercam Version 9.1 MP Post Processor Reference Guide November 2002
Volume 3 Chapter 3 Formulas

fsg2
Formula Type Advanced Math Functions
Description Return s0 for values equal to 0, of 1 for values not equal to 0.
Form function argument
Argument numeric variable, value (scalar)
Return Type numeric variable (scalar)
Formula Code Ex. real_result = fsg2(x)

Boolean Code Ex. if fsg2(x), “THE VALUE IS NOT ZERO”

Notes Nested return values are stored internally to the post executable.

November 2002 Mastercam Version 9.1 MP Post Processor Reference Guide 3--43
Chapter 3 Formulas Volume 3

fsg3
Formula Type Advanced Math Functions
Description Returns 0 for negative values, 1 for zero, or 2 for positive values.
Form function argument
Argument numeric variable, value (scalar)
Return Type numeric variable (scalar)
Formula Code Ex. real_result = fsg3(x)

Boolean Code Ex. if fsg3(x) = 2, “THE VALUE IS POSITIVE”

Notes This formula is useful with the string select function. Nested return
values are stored internally to the post executable.

3-44 Mastercam Version 9.1 MP Post Processor Reference Guide November 2002
Volume 3 Chapter 3 Formulas

ger
Formula Type Binary function
DescriptionReturns the SIM version, level information from the C-Hook function
get_sim_ver_lev. This is a 12-element array, so each element must be
accessed with a separate call. The argument is offset by 6, so you must
add 6 to the desired element. (The array is zero-based.) This function
is only available in the DLL versions of the post executable.
Form function argument
Argument numeric variable, value (scalar)
Return Type numeric variable (scalar)
Formula Code Ex. real_result = ger(7)

Boolean Code Ex. if ger(7) = 6, “YOU HAVE MILL LEVEL 3”

Notes Refer to the C-hook development documentation on the function


get_sim_ver_lev. Nested return values are stored internally to the post
executable.

November 2002 Mastercam Version 9.1 MP Post Processor Reference Guide 3--45
Chapter 3 Formulas Volume 3

good
Formula Type Binary function
Description Returns the argument.
Form function argument
Argument numeric variable, value (scalar)
Return Type numeric variable (scalar)
Formula Code Ex. real_result = good(20)

Boolean Code Ex. if good(20) = 20, “THIS IS ALWAYS GOING TO BE TRUE”

Notes This is a pointless formula. Nested return values are stored internally
to the post executable.

3-46 Mastercam Version 9.1 MP Post Processor Reference Guide November 2002
Volume 3 Chapter 3 Formulas

int
Formula Type Advanced Math Functions
DescriptionReturns the integer (whole number) portion of a value. The return
integer is the truncated integer from the argument.
Form function argument
Argument numeric variable, value (scalar)
Return Type numeric variable (scalar)
Formula Code Ex. real_var : 1.56

pblock # A postblock
real_result = int(real_var)

In this example, real_ result equals 1.


Boolean Code Ex. if int(x) <> 0, “THE VALUE IS -1 OR LESS, 1 OR GREATER”

Notes Nested return values are stored internally to the post executable.

November 2002 Mastercam Version 9.1 MP Post Processor Reference Guide 3--47
Chapter 3 Formulas Volume 3

ior
Formula Type Binary function
Description Bitwise inclusive or operation. Converts the two arguments to binary,
and then performs the “inclusive or” comparison on the individual bits.

Bit Bit Result


1 1 1
1 0 1
0 1 1
0 0 0

The return value is the resulting value.


Form function argument, argument
First Argument numeric variable, value (scalar)
Second Argument numeric variable, value (scalar)
Return Type numeric variable (scalar)
Formula Code Ex. real_result = ior(real_var1, real_var2)

Boolean Code Ex. if ior(real_var1, real_var2) = 2, p_action

Notes Integer values are expected. Nested return values are stored internally
to the post executable.

3-48 Mastercam Version 9.1 MP Post Processor Reference Guide November 2002
Volume 3 Chapter 3 Formulas

launch
Formula Type File function
DescriptionLaunches an executable file (.exe) from the post executable. The first
argument is the file name of the executable to be launched. The second
argument is a string that can pass parameters to the executable to be
launched. The post executable stops processing and waits for the
launched executable to finish. The return value is 0 if successful, or -1
if unsuccessful.
Form function argument, argument
First Argument string variable
Second Argument string variable
Return Type numeric variable (Boolean result)
Formula Code Ex. string1 "c:\aprogram.exe"
string2 ' "first" "second" "third" '

pblock # A postblock
real_result = launch(string1, string2)
Boolean Code Ex. Not allowed as a Boolean statement

Notes The second argument is normally parsed on the sets of double quotes,
but this depends on the program being launched.

November 2002 Mastercam Version 9.1 MP Post Processor Reference Guide 3--49
Chapter 3 Formulas Volume 3

lcase
Formula Type String function
Description Converts all characters in the argument to lower case.
Form function argument
Argument string variable
Return Type string variable
Formula Code Ex. string2 = lcase (string1)

Boolean Code Ex. if lcase (string1) = lcase (string2), “THE STRINGS MATCH LOWER CASE”

Notes Nested return values are stored internally to the post executable.

3-50 Mastercam Version 9.1 MP Post Processor Reference Guide November 2002
Volume 3 Chapter 3 Formulas

lng
Formula Type 2D vector math function
Description Returns the length of the argument (vector).
Form function argument
Argument numeric variable (3D vector)
Return Type numeric variable (scalar)
Formula Code Ex. real_result = lng(v3_x1)

Boolean Code Ex. Not allowed as a Boolean statement

Notes This is a 2D function. It is recommended that 3D vectors be used and


the last element in the implied array remain 0.

November 2002 Mastercam Version 9.1 MP Post Processor Reference Guide 3--51
Chapter 3 Formulas Volume 3

lng3
Formula Type 3D vector math function
Description Returns the length of the argument (vector).
Form function argument
Argument numeric variable (3D vector)
Return Type numeric variable (scalar)
Formula Code Ex. real_result = lng3(v3_x1)

Boolean Code Ex. Not allowed as a Boolean statement

Notes

3-52 Mastercam Version 9.1 MP Post Processor Reference Guide November 2002
Volume 3 Chapter 3 Formulas

log
Formula Type Advanced Math Functions
DescriptionReturns the natural log (base e) of the argument. The argument must be
greater than 0.
Form function argument
Argument numeric variable, value (scalar)
Return Type numeric variable (scalar)
Formula Code Ex. real_result = log(x)

Boolean Code Ex. if log(x) > 1 – vtol & log(x) < 1 + vtol, “X MUST BE ABOUT 2.7183”

Notes Nested return values are stored internally to the post executable.

November 2002 Mastercam Version 9.1 MP Post Processor Reference Guide 3--53
Chapter 3 Formulas Volume 3

log10
Formula Type Advanced Math Functions
DescriptionReturns the base 10 log of the argument. The argument must be greater
than 0.
Form function argument
Argument numeric variable, value (scalar)
Return Type numeric variable (scalar)
Formula Code Ex. real_result = log10(x)

Boolean Code Ex. if log10(x) = 1, “X MUST EQUAL 10”

Notes Nested return values are stored internally to the post executable.

3-54 Mastercam Version 9.1 MP Post Processor Reference Guide November 2002
Volume 3 Chapter 3 Formulas

matt
Formula Type Matrix math
Description Transposes a matrix. The transposed matrix is returned.
Form function argument
Argument numeric variable (matrix)
Return Type numeric variable (matrix)
Formula Code Ex. m9_xx1 : 1 # Matrix definition
m9_xy1 : 0
m9_xz1 : 0
m9_yx1 : 0
m9_yy1 : 1
m9_yz1 : 0
m9_zx1 : 0
m9_zy1 : 0
m9_zz1 : 1

m9_resxx : 0
m9_resxy : 0
m9_resxz : 0
m9_resyx : 0
m9_resyy : 0
m9_resyz : 0
m9_reszx : 0
m9_reszy : 0
m9_reszz : 0

pblock # A postblock
m9_resxx = matt(m9_xx1)
Boolean Code Ex. Not allowed as a Boolean statement

Notes

November 2002 Mastercam Version 9.1 MP Post Processor Reference Guide 3--55
Chapter 3 Formulas Volume 3

mmap
Formula Type Matrix math
Notes This function is not completed.

3-56 Mastercam Version 9.1 MP Post Processor Reference Guide November 2002
Volume 3 Chapter 3 Formulas

mmul
Formula Type Matrix math
DescriptionMultiplies a matrix by a second matrix. The resulting matrix is
returned.
Form function argument, argument
First Argument numeric variable (matrix)
Second Argument numeric variable (matrix)
Return Type numeric variable (matrix)
Formula Code Ex. m9_xx1 : 0 # Matrix definition
m9_xy1 : 1
m9_xz1 : 0
m9_yx1 : 0
m9_yy1 : 0
m9_yz1 : 1
m9_zx1 : 1
m9_zy1 : 0
m9_zz1 : 0

m9_xx2 : 0 # Matrix definition


m9_xy2 : 1
m9_xz2 : 0
m9_yx2 : 0
m9_yy2 : 0
m9_yz2 : 1
m9_zx2 : 1
m9_zy2 : 0
m9_zz2 : 0

m9_resxx : 0
m9_resxy : 0
m9_resxz : 0
m9_resyx : 0
m9_resyy : 0
m9_resyz : 0
m9_reszx : 0
m9_reszy : 0
m9_reszz : 0

pblock # A postblock
m9_resxx = mmul(m9_xx1, m9_xx2)
Boolean Code Ex. Not allowed as a Boolean statement

Notes

November 2002 Mastercam Version 9.1 MP Post Processor Reference Guide 3--57
Chapter 3 Formulas Volume 3

mprint
Formula Type File function
DescriptionDisplays a message to the screen. The output message is not written to
the NC output. The return value is 0 if a numeric variable was passed,
or 1 if a string variable was passed to the function.
Form function argument
Argument numeric variable, value
string variable
Return Type numeric variable (scalar)
Formula Code Ex. string1 “ERROR FOUND”
real_var : 100

pblock # A postblock
real_result = mprint (string1)
real_result = mprint (real_var)

In this example, “ERROR FOUND” is displayed first, and then “100.”


Boolean Code Ex. if mprint (string1) = 0, “DISPLAY A STRING”
if mprint (real_var) = 1, “DISPLAY A VALUE”
Notes The user must press [Enter] in Mastercam to continue post processing.
Starting with Version 9, mprint is able to take two parameters. The
second parameter, if present and not zero, pops up a message box.
For example:
result = mprint (stringmsg, 2)
The possible second arguments are:
1 = MB_OK The message box contains one pushbutton: OK.
2 = MB_OKCANCEL Message box with: OK and Cancel buttons.
3 = MB_ABORTRETRYIGNORE Three buttons: Abort, Retry, and
Ignore.
4 = MB_YESNOCANCEL Three buttons: Yes, No, and Cancel.
5 = MB_YESNO Two buttons: Yes and No.
6 = MB_RETRYCANCEL Two buttons: Retry and Cancel.
If this message box format is used, mprint returns a number:
1 = IDOK The OK button was selected.
2 = IDCANCEL The Cancel button was selected.
3 = IDABORT The Abort button was selected.
4 = IDRETRY The Retry button was selected.
5 = IDIGNORE The Ignore button was selected.
6 = IDYES The Yes button was selected.
7 = IDNO The No button was selected.

3-58 Mastercam Version 9.1 MP Post Processor Reference Guide November 2002
Volume 3 Chapter 3 Formulas

mteq
Formula Type Matrix math
DescriptionCopies a matrix. Copies the argument (matrix) to the result (matrix).
The term used for this formula is matrix equate.
Form function argument
Argument numeric variable (matrix)
Return Type numeric variable (matrix)
Formula Code Ex. m9_xx1 : 1 # Matrix definition
m9_xy1 : 0
m9_xz1 : 0
m9_yx1 : 0
m9_yy1 : 1
m9_yz1 : 0
m9_zx1 : 0
m9_zy1 : 0
m9_zz1 : 1

m9_resxx : 0
m9_resxy : 0
m9_resxz : 0
m9_resyx : 0
m9_resyy : 0
m9_resyz : 0
m9_reszx : 0
m9_reszy : 0
m9_reszz : 0

pblock # A postblock
m9_resxx = mteq(m9_xx1)
Boolean Code Ex. Not allowed as a Boolean statement

Notes The assignment operator (=) copies only the single variables in the
statement. This formula copies all the elements in the implied array.

November 2002 Mastercam Version 9.1 MP Post Processor Reference Guide 3--59
Chapter 3 Formulas Volume 3

newfs
Formula Type Conversion function
DescriptionReassigns a format statement. The first argument is the number of the
new format statement to be assigned The second argument is the
numeric variable to modify. The formula returns a 0 on failure or 1 on
success.
See Volume 3, Numeric Variables for more information.
Form function argument, argument
First Argument numeric variable, value (scalar)
Second Argument numeric variable
Return Type numeric variable (Boolean result)
Formula Code Ex. fs2 1 3.3 3.3l # 3.3 format with leading zeros
fs2 2 3.3 3.3t # 3.3 format with trailing zeros
fmt X 1 real_var
real_var : 1.2
pblock # A postblock
*real_var, e
real_result = newfs (2, real_var) # ssign ‘fs2’ formatting to ‘real_var’
*real_var, e
In this example, the first output is X001.2 and after reassignment is
X1.200.
Boolean Code Ex. if newfs (2, real_var) = 0, “THE NEW FORMAT WAS NOT APPLIED”

Notes

3-60 Mastercam Version 9.1 MP Post Processor Reference Guide November 2002
Volume 3 Chapter 3 Formulas

no2asc
Formula Type Conversion function
DescriptionConverts the ASCII decimal equivalent (1-255) into the ASCII
character.
Form function argument
Argument numeric variable, value (scalar)
Return Type string variable
Formula Code Ex. string1 = no2asc(35)

In this example, string1 holds the pound “#” character.


Boolean Code Ex. if no2asc(32) = string2, “STRING2 IS A SPACE”

Notes For ASCII code information, see http://www.asciitable.com.

November 2002 Mastercam Version 9.1 MP Post Processor Reference Guide 3--61
Chapter 3 Formulas Volume 3

no2str
Formula Type Conversion function
DescriptionConverts the value of a numeric variable and returns it to the result
string variable. The result string variable holds the result of the
numeric variable rounded to the format statement assigned to the
numeric variable. By default, format statement number 1 is used.
Form function argument
Argument numeric variable, value (scalar)
Return Type string variable
Formula Code Ex. string1 = no2str(real_var)

Boolean Code Ex. if no2str(real_var) = string2, p_action

Notes Nested return values are stored internally to the post executable.

3-62 Mastercam Version 9.1 MP Post Processor Reference Guide November 2002
Volume 3 Chapter 3 Formulas

not
Formula Type Logic operators
DescriptionReturns the opposite result of conditional branching statement. If the
logical result of a statement was 0, then the return is 1. If the result is 1,
the return is 0.
Form function argument
Argument numeric variable, value (scalar)
Return Type numeric variable (Boolean result)
Formula Code Ex. real_result = not(x=y)

Boolean Code Ex. if not(0), “CONVERTS THIS TO A TRUE STATEMENT”

Notes Nested return values are stored internally to the post executable.

November 2002 Mastercam Version 9.1 MP Post Processor Reference Guide 3--63
Chapter 3 Formulas Volume 3

nwadrs
Formula Type String function
DescriptionChanges the prefix string assigned with a format statement for a
numeric variable. The first argument is a string variable with the new
prefix. The second argument is the numeric variable to modify. The
formula returns 0 if the prefix string was truncated to 15 characters
(maximum characters for a prefix string), or 1 if not truncated.
Form function argument, argument
First Argument string variable
Second Argument numeric variable
Return Type numeric variable (Boolean result)
Formula Code Ex. real_var1 : 0
string1 "NEWFS"

pblock # A postblock
real_result = nwadrs(string1, real_var1)

In this example, real_var1 is output as NEWFS0.


Boolean Code Ex. if nwadrs(string1, real_var1) = 0, “THE NEW PREFIX WAS TRUNCATED”

Notes

3-64 Mastercam Version 9.1 MP Post Processor Reference Guide November 2002
Volume 3 Chapter 3 Formulas

plcval
Formula Type Conversion function
DescriptionExtracts a value from a string variable that contains numbers. Based
on the position relative to the decimal location or the implied decimal
location, extracts the single place value integer. Positive positions are
from the decimal position to the left. Negative positions are to the right.
If the string variable is signed, the sign is applied to the leftmost digit
only when it is extracted. The first argument is the string variable
containing a number string. The second argument is the index position,
relative to the decimal position, of the place value to extract. A
position selected out of range returns 9999 to the result numeric
variable; otherwise the return value is the extracted integer.
Form function argument, argument
First Argument string variable
Second Argument numeric variable, value (scalar)
Return Type numeric variable (scalar)
Formula Code Ex. string1 : 123.4567

pblock # A postblock
real_var = plcval (string1, 2)
real_var = plcval (string1, -2)
In this example, the first result is 2 and the second is 5.
Boolean Code Ex.
Notes Nested return values are stored internally to the post executable.

November 2002 Mastercam Version 9.1 MP Post Processor Reference Guide 3--65
Chapter 3 Formulas Volume 3

rbuf
Formula Type Special MP function
Description Reads a record from a buffer file. This formula allows access to the
buffer file function fbuf to read records that are stored from a buffer
write function wbuf, or read from a file and stored in a buffer. The first
argument defines the buffer number (1 through 10). The second
number is the record number to be read. The returned variable is an
array that is filled in order, starting with the variable position of the
return variable name. If the buffer is a string buffer, only one element
is allowed.
Form function argument, argument
First Argument numeric variable, value (scalar)
Second Argument numeric variable (scalar)
Return Type numeric variable (array)
string variable
Formula Code Ex. rc1 : 1
real_var1 : 0 #User-defined numeric variables
real_var2 : 0
fbuf 1 0 2 0 # Create a buffer of real numbers
pblock # A postblock
real_var1 = rbuf(1, rc1)
Boolean Code Ex. Not allowed as a Boolean statement

Notes The second argument is automatically incremented every time a buffer


read is performed. Do not use a constant value in this argument
position.
See Volume 2, How Buffer Files Work for more information.

3-66 Mastercam Version 9.1 MP Post Processor Reference Guide November 2002
Volume 3 Chapter 3 Formulas

remove
Formula Type File function
DescriptionRemoves (deletes) the file. The argument is the full path name of the
file to remove. The returned value is 0 if the file was removed, or -1 if
the formula failed.
Form function argument
Argument string variable
Return Type numeric variable (Boolean result)
Formula Code Ex. string1 "c:\mcam81\file.txt"

pblock # A postblock
real_result = remove (string1)
Boolean Code Ex. pblock # A postblock
if remove (string1) = -1, “THE FILE COULD NOT BE REMOVED”
Notes The files must be closed before they can be removed.

November 2002 Mastercam Version 9.1 MP Post Processor Reference Guide 3--67
Chapter 3 Formulas Volume 3

rename
Formula Type File function
DescriptionRenames a file. The first argument is the full path name of the file to
be renamed. The second argument is the full path name of the new file
name. The returned value is 0 if the file was renamed, or -1 if the
formula failed.
Form function argument, argument
First Argument string variable
Second Argument string variable
Return Type numeric variable (Boolean result)
Formula Code Ex. string1 "c:\mcam81\old.nc"
string2 "c:\mcam81\new.nc"

pblock # A postblock
real_result = rename (string1, string2)
Boolean Code Ex. pblock # A postblock
if rename (string1, string2) = -1, “THE FILE COULD NOT BE RENAMED”
Notes The files must be closed before they can be renamed.

3-68 Mastercam Version 9.1 MP Post Processor Reference Guide November 2002
Volume 3 Chapter 3 Formulas

rot
Formula Type 2D vector math function
DescriptionRotates a planar vector by a specified angle. Rotates the second
argument (vector) about the origin (0,0,0) by the specified angle in
degrees of the first argument. The resulting vector is returned.
Form function argument, argument
First Argument numeric variable (angle)
Second Argument numeric variable (3D vector)
Return Type numeric variable (3D vector)
Formula Code Ex. v3_resx = rot(real_var, v3_x1)

Boolean Code Ex. Not allowed as a Boolean statement

Notes This is a 2D function. It is recommended that 3D vectors be used and


that the last element in the implied array remain 0.

November 2002 Mastercam Version 9.1 MP Post Processor Reference Guide 3--69
Chapter 3 Formulas Volume 3

rotp
Formula Type 3D vector math function
DescriptionRotates a point (defined as a 3D vector) by a specified angle about an
axis and a pivot point. Rotates the second argument (point) about the
pivot point defined by ptfixx, ptfixy, ptfixz and an axis defined by a vector
axisx, axisy, axisz. The first argument is the rotation angle specified in
degrees. The resulting vector is returned.
Form function argument, argument
First Argument numeric variable (angle)
Second Argument numeric variable (3D vector)
Return Type numeric variable (3D vector)
Helper Variables ptfixx, ptfixy, ptfixz, axisx, axisy, axisz
Formula Code Ex. caxisx : 0
caxisy : 0
caxisz : 1

pblock # A postblock
axisx = vequ (caxisx)
v3_resx = rotp(real_var, v3_x1)
Boolean Code Ex. Not allowed as a Boolean statement

Notes You must set the vector axisx, axisy, axisz before you use this formula.
ptfixx, ptfixy, ptfixz is the origin by default.

3-70 Mastercam Version 9.1 MP Post Processor Reference Guide November 2002
Volume 3 Chapter 3 Formulas

rotv
Formula Type 3D vector math function
DescriptionRotates a vector by a specified angle about an axis. Rotates the second
argument (point) about the origin (0,0,0) and an axis defined by a
vector axisx, axisy, axisz. The first argument is the rotation angle
specified in degrees. The resulting vector is returned.
Form function argument, argument
First Argument numeric variable (angle)
Second Argument numeric variable (3D vector)
Return Type numeric variable (3D vector)
Helper Variables axisx, axisy, axisz
Formula Code Ex. caxisx : 0
caxisx : 0
caxisx : 1

pblock # A postblock
axisx = vequ (caxisx)
v3_resx = rotv(real_var, v3_x1)
Boolean Code Ex. Not allowed as a Boolean statement

Notes You must set the vector axisx, axisy, axisz before you use this formula.

November 2002 Mastercam Version 9.1 MP Post Processor Reference Guide 3--71
Chapter 3 Formulas Volume 3

round
Formula Type Advanced Math Functions
DescriptionReturns the rounded integer (whole number) portion of a value.
The returned integer is the rounded value of the argument.
Form function argument
Argument numeric variable, value (scalar)
Return Type numeric variable (scalar)
Formula Code Ex. real_var : 1.56

pblock # A postblock
real_result = round (real_var)

In this example, real_ result equals 2


Boolean Code Ex. if round(x) <> 0, p_action

Notes Nested returned values are stored internally to the post executable.

3-72 Mastercam Version 9.1 MP Post Processor Reference Guide November 2002
Volume 3 Chapter 3 Formulas

rpar
Formula Type Special MP function
DescriptionExtracts the numeric variables from a space-delimited string variable.
The first argument is a string variable with space-delimited values.
The second argument is the number of elements to be read from the
string. The string is converted and the result array is filled in order,
starting with the numeric variable position of the result numeric
variable name.
Form function argument, argument
First Argument string variable
Second Argument numeric variable, value (scalar)
Return Type numeric variable (array)
Formula Code Ex. real_var1 : 0 #User-defined numeric variables
real_var2 : 0
real_var3 : 0
real_var4 : 0
real_var5 : 0
string1 “1.1 2.2 3.3 4.4 5.5”
pblock # A postblock
real_var1 = rpar(string1, 5)
In this example, real_ var1 = 1.1, real_var2 = 2.2, real_var3 = 3.3,
real_var4 = 4.4 and real_var5 = 5.5.
Boolean Code Ex. Not allowed as a Boolean statement

Notes This routine can be used to convert a string variable with a single
number in it to a numeric variable. Set the number of elements to read
to 1.
See Volume 2, Parameter Information for more information.

November 2002 Mastercam Version 9.1 MP Post Processor Reference Guide 3--73
Chapter 3 Formulas Volume 3

scan
Formula Type String function
Description Determines if one string is a sub string of a second string, and if the
sub string is found, scans for a number starting immediately after the
location where the sub string was matched. The second argument is
compared to the first argument to determine if the second argument is
a sub string of the first argument. The returned value is the number
scanned from the first argument, or -9999 if no sub string or no
number is found. The helper variables return the start index in st_str_ix
where the sub string match begins. The first character after the
scanned number is placed in end_str_ix.
Form function argument, argument
First Argument string variable
Second Argument string variable
Return Type numeric variable (scalar)
Helper Variables st_str_ix, end_str_ix
Formula Code Ex. string1 “aluminum 0.625”
string2 “aluminum”

pblock # A postblock
real_var = scan (string2, string1)

In this example, real_var equals 0.625, st_str_ix equals 1, and


end_str_ix would equal 15.
Boolean Code Ex. pblock # A postblock
if scan(string1, string2) =-9999, “A NUMBER WAS NOT FOUND”
Notes Nested return values are stored internally to the post executable.

3-74 Mastercam Version 9.1 MP Post Processor Reference Guide November 2002
Volume 3 Chapter 3 Formulas

sin
Formula Type Trigonometric function
DescriptionSine. Returns the ratio of the opposite angle to the hypotenuse of a right
triangle.
Form function argument
Argument numeric variable, value (angle)
Return Type numeric variable (scalar)
Formula Code Ex. real_result = sin(angle)

Boolean Code Ex. if sin(angle) > .7071, p_action

Notes Nested return values are stored internally to the post executable.

November 2002 Mastercam Version 9.1 MP Post Processor Reference Guide 3--75
Chapter 3 Formulas Volume 3

slin
Formula Type Special MP function
DescriptionWrites a string to a string variable that is a specified offset from the
string variable passed as the second argument. The first parameter
indicates the position to offset from the base position, represented by
the second argument, relative to the database order of the string
variables.
Note the usual direction of this function. String1 is on the left side of
the equation (the “= “), but it is really the input string. The output of
this function is loaded into the string whose address is derived from the
address of string2 plus the offset (1 in the example below). The string
represented by the return variable is passed to the offset of the second
argument.
Form function argument, argument
First Argument numeric variable, value (scalar)
Second Argument string variable
Return Type string variable
Formula Code Ex. string1 “HELLO” #User-defined string variables
string2 0
string3 0

pblock # A postblock
string1 = slin(1, string2)
In this example, string3 is offset by 1 from string2 so string3 would
receive the string “HELLO” from string1.
Boolean Code Ex. Not allowed as a Boolean statement

Notes This function can be used in a “while” loop to assign a string to an


implied array or any database ordered variables.

3-76 Mastercam Version 9.1 MP Post Processor Reference Guide November 2002
Volume 3 Chapter 3 Formulas

slout
Formula Type Special MP function
DescriptionReads a string from a string variable located at a specified offset from
the string variable passed as the second argument. The first parameter
indicates the position to offset from the base position, represented by
the second argument, relative to the database order of the string
variables. The contents of the string variable at the offset from the
second argument is passed to the return variable.
Form function argument, argument
First Argument numeric variable, value (scalar)
Second Argument string variable
Return Type string variable
Formula Code Ex. string1 0 #User-defined string variables
string2 0
string3 “HELLO”

pblock # A postblock
string1 = slout(1, string2)
In this example, string1 would receive the string “HELLO” from
string3.
Boolean Code Ex. Not allowed as a Boolean statement

Notes This function can be used in a “while” loop to assign a string from the
database ordered variables.

November 2002 Mastercam Version 9.1 MP Post Processor Reference Guide 3--77
Chapter 3 Formulas Volume 3

sqrt
Formula Type Advanced Math Functions
Description Returns the square root of the argument.
Form function argument
Argument numeric variable, value (scalar)
Return Type numeric variable (scalar)
Formula Code Ex. real_result = sqrt(x)

Boolean Code Ex. if sqrt(x) = 2, “X MUST BE 4”

Notes Nested return values are stored internally to the post executable.

3-78 Mastercam Version 9.1 MP Post Processor Reference Guide November 2002
Volume 3 Chapter 3 Formulas

strlen
Formula Type String function
Description Gets the number of characters in a string variable.
Form function argument
Argument string variable
Return Type numeric variable (scalar)
Formula Code Ex. real_result = strlen(string1)

Boolean Code Ex. if strlen (string1) > 50, “THE STRING IS TOO LONG FOR THE CONTROL”

Notes Nested return values are stored internally to the post executable.

November 2002 Mastercam Version 9.1 MP Post Processor Reference Guide 3--79
Chapter 3 Formulas Volume 3

strstr
Formula Type String function
Description Determines if one string is a sub string of a second string. The first
argument is compared to the second argument to determine if the first
argument is a sub string of the second argument. The return value is
the start index of the first string variable in the second string variable,
or 0 if no match is found. The helper variables return the start index in
st_str_ix, and the first character after the sub string match in end_str_ix.
Form function argument, argument
First Argument string variable
Second Argument string variable
Return Type numeric variable (scalar)
Helper Variables st_str_ix, end_str_ix
Formula Code Ex. string1 “M320”
string2 “Fanuc M320ABC”

pblock # A postblock
real_result = strstr(string1, string2)

In this example, st_str_ix would equal 7, and end_str_ix would equal


11.
Boolean Code Ex. pblock # A postblock
if strstr(string1, string2) = 0, “STRING1 WAS NOT A SUBSTRING”
Notes Nested return values are stored internally to the post executable.

3-80 Mastercam Version 9.1 MP Post Processor Reference Guide November 2002
Volume 3 Chapter 3 Formulas

tan
Formula Type Trigonometric function
DescriptionTangent. Returns the ratio of the opposite angle to the adjacent of a
right triangle.
Form function argument
Argument numeric variable, value (angle)
Return Type numeric variable (scalar)
Formula Code Ex. real_result = tan(angle)

Boolean Code Ex. if tan(angle) > .7071, p_action

November 2002 Mastercam Version 9.1 MP Post Processor Reference Guide 3--81
Chapter 3 Formulas Volume 3

ucase
Formula Type String function
Description Converts all characters in the argument to upper case.
Form function argument
Argument string variable
Return Type string variable
Formula Code Ex. string2 = ucase (string1)

Boolean Code Ex. if ucase (string1) = ucase (string2), “THE STRINGS MATCH UPPER CASE”

Notes Nested return values are stored internally to the post executable.

3-82 Mastercam Version 9.1 MP Post Processor Reference Guide November 2002
Volume 3 Chapter 3 Formulas

updgbl
Formula Type Special function
DescriptionUpdates simple global variables. A simple global variable is a variable
set equal to variable or variable set equal to variable with unary minus
updgbl changes the argument variable and/or unary minu.
Form function argument
Argument string variable
Return Type numeric variable (scalar)
Formula Code Ex. These global variable definitions:
global1 = x
global2 = -y

postblock #A postblock
result = updgbl (global1, y)
result = updgbl (global2, -x)

# The function now changes the global variables to behave as if they were
# originally defined as:
global1 = y
global2 = -x

Boolean Code Ex. if updgbl (global1, y), “THE GLOBAL FORMULA HAS CHANGED”

Notes These is an advanced functions and error checking is very limited.


Be certain to use only with a simple global formula.

November 2002 Mastercam Version 9.1 MP Post Processor Reference Guide 3--83
Chapter 3 Formulas Volume 3

updstr
Formula Type String function
DescriptionUpdates the target string variable in a string select function. Based on
the current value of the numeric variable selector in the string select
function, the target string variable is updated so that it holds the correct
string for the numeric variable selector. The argument is the target
string variable in the string select function. The result is 1 if the current
and previous of the numeric variable selector are not equal, or 0 if they
are equal.
Form function argument
Argument string variable
Return Type numeric variable (scalar)
Formula Code Ex. real_result = updstr(string1)

Boolean Code Ex. if updstr(string1), “THE STRING HAS CHANGED”

Notes Nested return values are stored internally to the post executable.

3-84 Mastercam Version 9.1 MP Post Processor Reference Guide November 2002
Volume 3 Chapter 3 Formulas

vad
Formula Type 2D vector math function
Description Adds two planar vectors.
Form function argument, argument
First Argument numeric variable (3D vector)
Second Argument numeric variable (3D vector)
Return Type numeric variable (3D vector)
Formula Code Ex. v3_resx = vad(v3_x1, v3_x2)

Boolean Code Ex. Not allowed as a Boolean statement

Notes This is a 2D function. It is recommended that 3D vectors be used and


the last element in the implied array remain 0.

November 2002 Mastercam Version 9.1 MP Post Processor Reference Guide 3--85
Chapter 3 Formulas Volume 3

vadd
Formula Type 3D vector math function
Description Adds two vectors.
Form function argument, argument
First Argument numeric variable (3D vector)
Second Argument numeric variable (3D vector)
Return Type numeric variable (3D vector)
Formula Code Ex. v3_resx = vad(v3_x1, v3_x2)

Boolean Code Ex. Not allowed as a Boolean statement

Notes

3-86 Mastercam Version 9.1 MP Post Processor Reference Guide November 2002
Volume 3 Chapter 3 Formulas

vaxb
Formula Type 3D vector math function
DescriptionCross product. Takes the product of the arguments (which are unitized
vectors) and returns a 3D vector whose direction is perpendicular to the
arguments, and whose magnitude is the sine of the angle between the
arguments. See “Right hand rule” in Volume 1, Formulas.
Form function argument, argument
First Argument numeric variable (3D vector, unitized)
Second Argument numeric variable (3D vector, unitized)
Return Type numeric variable (3D vector)
Formula Code Ex. v3_resx = vaxb(v3_x1, v3_x2)

Boolean Code Ex. Not allowed as a Boolean statement

Notes

November 2002 Mastercam Version 9.1 MP Post Processor Reference Guide 3--87
Chapter 3 Formulas Volume 3

veq
Formula Type 2D vector math function
DescriptionCopies a planar vector. Copies the argument (vector) to the result
(vector). The term used for this formula is vector equate.
Form function argument
Argument numeric variable (3D vector)
Return Type numeric variable (3D vector)
Formula Code Ex. v3_resx = veq(v3_x1)

Boolean Code Ex. Not allowed as a Boolean statement

Notes Whereas the assignment operator (=) copies only the single variables in
the statement, this formula copies all the elements in the implied array.
This is a 2D function. It is recommended that 3D vectors be used and
the last element in the implied array remain 0.

3-88 Mastercam Version 9.1 MP Post Processor Reference Guide November 2002
Volume 3 Chapter 3 Formulas

vequ
Formula Type 3D vector math function
DescriptionCopies a vector. Copies the argument (vector) to the result (vector).
The term used for this formula is vector equate.
Form function argument
Argument numeric variable (3D vector)
Return Type numeric variable (3D vector)
Formula Code Ex. v3_resx = vequ(v3_x1)

Boolean Code Ex. Not allowed as a Boolean statement

Notes Whereas the assignment operator (=) copies only the single variables in
the statement, this formula copies all the elements in the implied array.

November 2002 Mastercam Version 9.1 MP Post Processor Reference Guide 3--89
Chapter 3 Formulas Volume 3

vlh
Formula Type 2D vector math function
DescriptionRotates a planar vector 90 degrees counterclockwise (LH). Rotates the
argument (vector) 90 degrees counterclockwise about the tail of the
vector (0,0,0). The resulting vector is returned.
Form function argument
Argument numeric variable (3D vector)
Return Type numeric variable (3D vector)
Formula Code Ex. v3_resx = vrh(v3_x1)

Boolean Code Ex. Not allowed as a Boolean statement

Notes This is a 2D function. It is recommended that 3D vectors be used and


the last element in the implied array remain 0.

3-90 Mastercam Version 9.1 MP Post Processor Reference Guide November 2002
Volume 3 Chapter 3 Formulas

vlin
Formula Type Special MP function
DescriptionWrites a value to a numeric variable at specified offset from the
numeric variable passed as the second argument. The first parameter
indicates the position to offset from the base position, represented by
the second argument, relative to the database order of the numeric
variables.
Note the usual direction of this function. Real_va1 is on the left side of
the equation (the “=” sign), but it is really the input variable. The output
of this function is loaded into the numeric variable whose address is
derived from the address of real_var2 plus the offset (1 in the example
below). The numeric variable represented by what would normally be
considered the return variable is passed to the offset of the second
argument. .
Form function argument, argument
First Argument numeric variable, value (scalar)
Second Argument numeric variable
Return Type numeric variable
Formula Code Ex. real_var1 : 1 #User-defined numeric variables
real_var2 : 0
real_var3 : 0

pblock # A postblock
real_var1 = vlin(1, real_var2)
In this example, real_ var3 would receive the value 1 from real_var1.
Boolean Code Ex. Not allowed as a Boolean statement

Notes This function can be used in a “while” loop to assign a value to an


implied array or any database ordered variables.

November 2002 Mastercam Version 9.1 MP Post Processor Reference Guide 3--91
Chapter 3 Formulas Volume 3

vlout
Formula Type Special MP function
DescriptionReads a value from a numeric variable located at a specified offset
from the numeric variable passed as the second argument. The first
parameter indicates the position to offset from the base position,
represented by the second argument, relative to the database order of
the numeric variables. The contents of the numeric variable at the
offset from the second argument is passed to the return variable
Form function argument, argument
First Argument numeric variable, value (scalar)
Second Argument numeric variable
Return Type numeric variable
Formula Code Ex. real_var1 : 0 #User-defined numeric variables
real_var2 : 0
real_var3 : 1

pblock # A postblock
real_var1 = vlout(1, real_var2)
In this example, real_ var1 would receive the value 1 from real_var3.
Boolean Code Ex. Not allowed as a Boolean statement

Notes This function can be used in a “while” loop to assign a values from the
database ordered variables.

3-92 Mastercam Version 9.1 MP Post Processor Reference Guide November 2002
Volume 3 Chapter 3 Formulas

vmap
Formula Type Matrix math
DescriptionMaps a point (vector) relative to the top view matrix to the specified
matrix. The resulting point (vector) is returned.
Form function argument, argument
First Argument numeric variable (3D vector)
Second Argument numeric variable (matrix)
Return Type numeric variable (3D vector)
Formula Code Ex. m9_xx1 : 0 # Matrix definition
m9_xy1 : 1
m9_xz1 : 0
m9_yx1 : 0
m9_yy1 : 0
m9_yz1 : 1
m9_zx1 : 1
m9_zy1 : 0
m9_zz1 : 0

v3_x1 : 1 # Vector definition


v3_y1 : 0
v3_z1 : 0

v3_resx : 0 # Vector definition


v3_resy : 0
v3_resz : 0

pblock # A postblock
v3_resx = vmap (v3_x1, m9_xx1)
Boolean Code Ex. Not allowed as a Boolean statement

Notes

November 2002 Mastercam Version 9.1 MP Post Processor Reference Guide 3--93
Chapter 3 Formulas Volume 3

vnr
Formula Type 2D vector math function
DescriptionUnitizes a planar vector (that is, sets the length to 1 or unit length). The
planar vector is the argument. The return is the unitized vector.
Form function argument
Argument numeric variable (3D vector)
Return Type numeric variable (3D vector)
Formula Code Ex. v3_resx = vnr(v3_x1)

Boolean Code Ex. Not allowed as a Boolean statement

Notes This is a 2D function. It is recommended that 3D vectors be used and


the last element in the implied array remain 0.

3-94 Mastercam Version 9.1 MP Post Processor Reference Guide November 2002
Volume 3 Chapter 3 Formulas

vnrm
Formula Type 3D vector math function
DescriptionUnitize (set the length to 1 or unit length) a vector. Unitize the
argument. The return is the unitized vector.
Form function argument
Argument numeric variable (3D vector)
Return Type numeric variable (3D vector)
Formula Code Ex. v3_resx = vnrm(v3_x1)

Boolean Code Ex. Not allowed as a Boolean statement

Notes

November 2002 Mastercam Version 9.1 MP Post Processor Reference Guide 3--95
Chapter 3 Formulas Volume 3

vrh
Formula Type 2D vector math function
DescriptionRotates a planar vector 90 degrees clockwise (right hand) by rotating
the argument (vector) 90 degrees clockwise about the tail of the vector
(0,0,0). The resulting vector is returned.
Form function argument
Argument numeric variable (3D vector)
Return Type numeric variable (3D vector)
Formula Code Ex. v3_resx = vrh(v3_x1)

Boolean Code Ex. Not allowed as a Boolean statement

Notes This is a 2D function. It is recommended that 3D vectors be used and


the last element in the implied array remain 0.

3-96 Mastercam Version 9.1 MP Post Processor Reference Guide November 2002
Volume 3 Chapter 3 Formulas

vsa
Formula Type 2D vector math function
DescriptionUnitizes and scales a planar vector (that is, sets the length to 1 or unit
length then multiplies it). The first argument that is the scale factor.
The second argument is the planar vector. The return is the unitized
and scaled vector.
Form function argument, argument
First Argument numeric variable, value (scalar)
Second Argument numeric variable (3D vector)
Return Type numeric variable (3D vector)
Formula Code Ex. v3_resx = vsa(real_var, v3_x1)

Boolean Code Ex. Not allowed as a Boolean statement

Notes This is a 2D function. It is recommended that 3D vectors be used and


the last element in the implied array remain 0.

November 2002 Mastercam Version 9.1 MP Post Processor Reference Guide 3--97
Chapter 3 Formulas Volume 3

vsb
Formula Type 2D vector math function
DescriptionSubtracts two planar vectors. The elements in the implied array are
subtracted: argument one – argument two.
Form function argument, argument
First Argument numeric variable (3D vector)
Second Argument numeric variable (3D vector)
Return Type numeric variable (3D vector)
Formula Code Ex. v3_resx = vsb(v3_x1, v3_x2)

Boolean Code Ex. Not allowed as a Boolean statement

Notes This is a 2D function. It is recommended that 3D vectors are used and


the last element in the implied array remain 0.

3-98 Mastercam Version 9.1 MP Post Processor Reference Guide November 2002
Volume 3 Chapter 3 Formulas

vsc
Formula Type 2D vector math function
DescriptionScales a planar vector. Scales (multiplies) the second argument (which
is the vector) by the first argument (which is the scale factor). The
return is the scaled vector.
Form function argument, argument
First Argument numeric variable, value (scalar)
Second Argument numeric variable (3D vector)
Return Type numeric variable (3D vector)
Formula Code Ex. v3_resx = vsc(real_var, v3_x1)

Boolean Code Ex. Not allowed as a Boolean statement

Notes This is a 2D function. It is recommended that 3D vectors are used and


the last element in the implied array remain 0.

November 2002 Mastercam Version 9.1 MP Post Processor Reference Guide 3--99
Chapter 3 Formulas Volume 3

vsca
Formula Type 3D vector math function
DescriptionUnitizes (that is, sets the length to 1 or unit length) and scales
(multiples) a vector. The second argument is the vector. The first
argument is the scale factor. The return is the unitized and scaled
vector.
Form function argument, argument
First Argument numeric variable, value (scalar)
Second Argument numeric variable (3D vector)
Return Type numeric variable (3D vector)
Formula Code Ex. v3_resx = vsca(real_var, v3_x1)

Boolean Code Ex. Not allowed as a Boolean statement

Notes

3-100 Mastercam Version 9.1 MP Post Processor Reference Guide November 2002
Volume 3 Chapter 3 Formulas

vscl
Formula Type 3D vector math function
DescriptionScales (multiplies) a vector. The second argument is the vector. The
first argument is the scale factor. The return is the scaled vector.
Form function argument, argument
First Argument numeric variable, value (scalar)
Second Argument numeric variable (3D vector)
Return Type numeric variable (3D vector)
Formula Code Ex. v3_resx = vscl(real_var, v3_x1)

Boolean Code Ex. Not allowed as a Boolean statement

Notes

November 2002 Mastercam Version 9.1 MP Post Processor Reference Guide 3--101
Chapter 3 Formulas Volume 3

vsub
Formula Type 3D vector math function
DescriptionSubtracts two vectors. The elements in the implied array are
subtracted: argument one – argument two.
Form function argument, argument
First Argument numeric variable (3D vector)
Second Argument numeric variable (3D vector)
Return Type numeric variable (3D vector)
Formula Code Ex. v3_resx = vsub(v3_x1, v3_x2)

Boolean Code Ex. Not allowed as a Boolean statement

Notes

3-102 Mastercam Version 9.1 MP Post Processor Reference Guide November 2002
Volume 3 Chapter 3 Formulas

wbuf
Formula Type Special MP function
Description Writes a record to a buffer file. Allows access to the buffer file
function fbuf to write records into a buffer. The first argument defines
the buffer number (1 through 10). The second number is the record
number to be write. The returned variable is an array of variables that
are read in order starting with the variable position of the return
variable name and flushed to the buffer file. If the buffer is a string
buffer, only one element (a string variable) is allowed.
Records need not be written in order. If a record is skipped, a blank
record is automatically inserted.
This function call reverses the directionin which return values are
passed. The values represented by the returned variable are passed to
the buffer file.
Form function argument, argument
First Argument numeric variable, value (scalar)
Second Argument numeric variable (scalar)
Return Type numeric variable (array)
string variable
Formula Code Ex. wc1 : 1
real_var1 : 10 #User-defined numeric variables
real_var2 : 20
fbuf 1 0 2 0 # Create a buffer of real numbers
pblock # A postblock
real_var1 = wbuf(1, wc1)
In this example, 10, 20 are written to the buffer file as a complete
record.
Boolean Code Ex. Not allowed as a Boolean statement

Notes The second argument is automatically incremented every time a buffer


read is performed. Do not use a constant variable in this argument
because it will be incremented.
See Volume 2, How Buffer Files Work for more information.

November 2002 Mastercam Version 9.1 MP Post Processor Reference Guide 3--103
Chapter 3 Formulas Volume 3

xaa
Formula Type Intersection function
DescriptionFinds the intersection of two planar arcs. The result is the two possible
intersection points (vector).
Form function argument, argument
First Argument numeric variable (arc)
Second Argument numeric variable (arc)
Return Type numeric variable (two consecutive 3D vectors)
Helper Variables xresult, t1, t2, ptnearx, ptneary, ptnearz, xtol

Formula Code Ex. v3_resx1 = xaa(arc_x1, arc_x2)

Boolean Code Ex. Not allowed as a Boolean statement

Notes This is a 2D function.


See Volume 2, Intersection Function for more information.

3-104 Mastercam Version 9.1 MP Post Processor Reference Guide November 2002
Volume 3 Chapter 3 Formulas

xla
Formula Type Intersection function
DescriptionFinds the intersection of a line and an arc in a plane. The result is the
two possible intersection points (vector).
Form function argument, argument
First Argument numeric variable (line)
Second Argument numeric variable (arc)
Return Type numeric variable (two consecutive 3D vectors)
Helper Variables xresult, t1, t2, ptnearx, ptneary, ptnearz, xtol

Formula Code Ex. v3_resx1 = xla(line_p1_x, arc_x)

Boolean Code Ex. Not allowed as a Boolean statement

Notes This is a 2D function.


See Volume 2, Intersection Function for more information.

November 2002 Mastercam Version 9.1 MP Post Processor Reference Guide 3--105
Chapter 3 Formulas Volume 3

xll
Formula Type Intersection function
DescriptionFinds the intersection of two planar lines. The result is the intersection
point (vector). The result is copied to the second intersection result
(required for xaa and xla).
Form function argument, argument
First Argument numeric variable (line)
Second Argument numeric variable (line)
Return Type numeric variable (two consecutive 3D vectors)
Helper Variables xresult, t1, t2, ptnearx, ptneary, ptnearz, xtol

Formula Code Ex. v3_resx1 = vll(line_p1_x1, (line_p1_x2)

Boolean Code Ex. Not allowed as a Boolean statement

3-106 Mastercam Version 9.1 MP Post Processor Reference Guide November 2002
Volume 3 Chapter 3 Formulas

xor
Formula Type Binary function
Description Bitwise exclusive or operation. Converts the two arguments to binary
and then performs an “exclusive or” comparison on the individual bits.

Bit Bit Result


1 1 0
1 0 1
0 1 1
0 0 0

The returned value is the resulting value.


Form function argument, argument
First Argument numeric variable, value (scalar)
Second Argument numeric variable, value (scalar)
Return Type numeric variable (scalar)
Formula Code Ex. real_result = xor(real_var1, real_var2)

Boolean Code Ex. if xor(real_var1, real_var2) = 2, p_action

Notes Integer values are expected. Nested return values are stored internally
to the post executable.

November 2002 Mastercam Version 9.1 MP Post Processor Reference Guide 3--107
Chapter 3 Formulas Volume 3

3-108 Mastercam Version 9.1 MP Post Processor Reference Guide November 2002

You might also like