Special Features
'Text Output' and text {variables}
Instead of simple numbers or variables, you may use equations in any area within any sequence wherever you would like to output or reference values that are based on mathematical relationships between 2 or more variables and/or numbers.
In the following places, you may use equations:
- To 'output' a numeric value following any formatted letter inside any sequence
- As the 'second parameter' in a Set command
- in a File Alias command
Here are some examples (the equations are in bold type):
StartCode
Set [Val2] to [Program#]+53
...
ToolChange
File Alias 1 'SUB' 7999+[Tool] '.NCC'
...
G0 X[H]/2 Y[V] (Note that the equation follows the letter X; the letter X is NOT part of the equation.)
...
LineCode
X[H]*cos([RotAngle]) Y[V] Z[D] (the asterisk * does a 'multiply' function)
end.
Needless to say, there are many things that you can do with equations - the possibilities are endless...
...But you must be careful not to attempt 'impossible' or 'undefined' mathematical operations.
Examples: The following equations would yield an 'undefined' result (and cause an error):
3.1416/[H] (when [H] is zero, this would cause a 'divide by zero' failure.)
atan([V]) (when the value [V] is zero, the 'arc tangent' function fails as well.)
'Text Output' and text {variables}
In addition to any 'hard-coded' text that can be output from within any sequences, text variables (such as {CLName}) can be used for many purposes including commenting and creation of specific files in specific folders.
There are several things that you can do to process or output text. In our context, 'text' means any information that does NOT fall into the strict adherence to the EIA standard of 'a letter followed by a number'. Examples of text are: 'ABC' or 'TOOL DEF' or 'CYCLE83'
There are quite a few different functions of the post that have to do with text...
· You can output text directly by simply placing it within any sequence, enclosed in 'single quotes' or “double quotes”. This is called 'hard-coded' text, or 'direct text' output. (See examples below.)
· You can use text and text variables (see below) to...
- specify file names and
- output comments based on file names and other text information from the CL file.
The following sections discuss some of the possibilities.
Direct ('hard-coded') text output
To include text in your programs, just enclose the desired text in 'single quotes' or “double quotes”. You can use either one, but the starting and ending quotes must match. In other words 'this is bad” because the start quote is a single quote and the end quote is a double quote. Having mismatched quotes in your template will cause problems. (We will discuss this in more detail below.)
Examples
1. If you would like to put your company name at the top of each program, then you could do so like this:
|
Put this in your template... |
...to get NC code output like this: |
|
StartCode |
|
2. If your machine requires a series of characters or 'man-readable' words to start a drilling cycle (for example, “MCALL CYCLE83” instead of “G83”) then you can simply enter the text directly in your sequence like this:
|
Put this in your template... |
...to get NC code output like this: |
|
Peck |
|
To output text that includes quotes (in other words, if you need to output
“quote marks” into your program), see the Notes regarding use of 'quotes'
discussion and examples under “Search and Replace” (section 7.4) below.
Regarding use of 'quotes' (and outputting quotes in your code)
When working with older formats, you may see "double quotes" instead of 'single quotes'. This is OK, PostHaste accepts either type of quote marks. We do this so that you can include quote marks inside the actual text phrases. Just make sure of 2 things:
1. If you use either type of quote character inside the phrase, use the other type of quote at the start and end of the phrase, and
2. that you start and end the phrase with the same type of quote mark!
|
Examples: |
Notes: |
|
"This 'phrase' is legal." |
Single quotes are allowed within a double-quoted phrase. |
|
'So is this.' |
Normal. |
|
"This one won't be a problem, and" |
Use double quotes when you need to have a single quote (like “won't”) in the text. |
|
'this one is "OK", too.' |
Double quotes are OK inside a single-quoted phrase. |
|
"But THIS one is bad,' |
Starts & ends with different quote types. |
|
'this one is BAD also," |
Starts & ends with different quote types. |
|
'and this one won't work either.' |
The word won't includes a single quote (an apostrophe). To fix this problem, use "double quotes" to surround the phrase instead of 'single quotes'. |
Using {text variables}
Text variables are the only variables that do not output numeric data - they output text. You can instantly tell the difference between a text variable and a numeric variable by the type of bracket that is used: Numeric variables have [square brackets] and text variables have {curly brackets}. Since these output text (not numeric values), they cannot be associated with a letter (as numeric variables always are, e.g. “M[Cool]”). Text variables may be simply output as 'free-standing' text (that is, without a letter in front of it). In other words, you would NOT do this:
G{PartNo} << This is NO GOOD!
Examples
1. If you want a comment in your NC program that shows the name of the template file, you may include one of these in your StartCode (or any other) sequence:
|
Sample template lines: |
Sample output: |
|
'(' {TemplateName} ')' |
N20 (Fanuc 6T Generic) |
|
'(' {TemplateName} {TemplateExt} ')' |
N20 (Fanuc 6T Generic.pT2) |
2. Text variables and/or numeric variables can also be used (with or without quoted phrases) to construct file names in the File Alias command like this:
File ALIAS 1 {CLPath} 'YASDA\O' [Sub]+[Val6]
Note that you can use numeric variables (in the above example [Sub] and [Val6]), and you can even use equations ([Sub]+[Val6]) when building the file alias.
See Variables.