Placeholders
Placeholders give you the ability to enter variables or special characters in fields enclosed in hashtags (# #) that will be updated with calculated or entered values. A placeholder can be updated only once since the placeholder is replaced with the value.
Variables as placeholders
Variable placeholders can be used in areas of COSMO Discrete Manufacturing that allow text with the condition that the variable exists in the Variable/Attribute Types page.
Where | What | Example |
---|---|---|
Items | Placeholders in descriptions | The #POWER# placeholder is entered in the Description field and transfers to a master BOM, document BOM, construction BOM, checklist line, or sales line when added. |
Master BOM lines | Variables in formulas, placeholders in descriptions | The POWER variable is used in the Formula Valid field on multiple lines to determine which motor is used in the configuration. NOTE: If not already added to items, placeholders can be manually added to Description fields. |
Checklist lines | Variables in formulas | In the related checklist template, the POWER variable is assigned to the Variable for Dynamic BOM field on a line. In the document checklist, you enter 50 for the power configuration. |
Document BOM / Construction BOM | Variables in formulas, placeholders in descriptions | When the Request BOM function is run in the document BOM or construction BOM, the variable is updated and stored, and the placeholder #POWER# is changed to 50. |
Sales line | Placeholders in descriptions | An item with a placeholder of #POWER# in the Description field is added to a sales line. When the Request BOM function is run in the document BOM or construction BOM, the placeholder #POWER# is changed to 50. NOTE: If not already added to items, placeholders can be manually added to the Description field. |
Counting variable "i" as placeholder
A counting variable placeholder is entered as #i# in master BOMs and checklist lines. This is used when you want to use a placeholder to show a counted/calculated value. For example, the Recalculate field is added to a master BOM line, which means the line will be copied to the Document BOM/Construction BOM as many times as was entered/calculated in the Exp. Quantity field; the document BOM line will have an Exp. Quantity = 1. The number of created document BOM lines will be the quantity entered in the Input field of the checklist that has a sub-checklist. The #i# placeholder is added in the Description, Formula Quantity, and Formula Setup Time fields. If 3 is entered in the checklist, then the Document BOM will have three entries, and the placeholders will be replaced with 01 in the first entry, 02 in the second entry, and 03 in the third entry.
For more information about using the #i# placeholder, see Sub-checklists.
Calculate counting variable "i"
The counting variable "i" can also be calculated within formulas in Dynamic Sub-Checklists or in Master BOMs used in combination with the Recalculate field. This provides the ability to create more complex calculations.
To calculate this variable within a formula, the term between the hashtags "# #" must start with "#(i", otherwise the string cannot be interpreted as an index. When using IF statements, the "i" within the parentheses must be entered as "#i#". The following table shows valid and invalid formulas using example variables in the calculation.
Formula | Valid Syntax | Invalid Reason |
---|---|---|
MYVAR#(i + 4)# | ✓ | |
MYVAR#(i * 2)# | ✓ | |
IF(#i# < IMAX; MYVAR#(i + 1)#; MYVAR#i#) | ✓ | |
MYVAR#(2 + i)# | ✗ | The "i" must follow directly behind the left parenthesis "(" |
MYVAR#i + 2# | ✗ | The parentheses "( )" are missing |
IF(i < IMAX; MYVAR#(I + 1)#; MYVAR#I#) | ✗ | When using IF statements, the "i" must be enclosed in hashtags "# #" |
Example
This example shows how the "i" counting variable is used in simple and complex formulas. It uses the following variable values to explain the results of the calculations:
- MYVAR01 = 100
- MYVAR02 = 200
- MYVAR03 = 300
- MYVAR04 = 400
In a Master BOM or sub-checklist line, the following formulas have been entered:
"i" value | Type | Formula | Result |
---|---|---|---|
2 | Simple | MYVAR#i# * 5 | In the first step, the #i# gets replaced by the value of the index: MYVAR02 * 5 In the second step, the calculation is done: 200 * 5 = 1000 |
2 | Complex | MYVAR#(i + 2)# * 5 | In the first step, the term (i + 2) gets calculated and replaced by the value of the index: MYVAR(#2 + 2#) * 5 = MYVAR04 * 5 In the second step, the calculation is done: 400 * 5 = 2000 |
Zero or negative results
If the result of the term is zero or negative, no index will be added so the main variable will be the result.
Example
This example shows how indexing is used with a negative and positive result. It uses the following variable values to explain the results of the calculations:
- MYVAR = 50
- MYVAR01 = 100
- MYVAR02 = 200
- MYVAR03 = 300
- MYVAR04 = 400
The following table uses different formulas in a sub-checklist line and explains which calculated counting variable is used and why along with the calculated result.
"i" value | Formula | Calculated Counting Variable | Reason | Variable Calculation Used | Result |
---|---|---|---|---|---|
2 | MYVAR#(i - 3)# * 5 | MYVAR#-1# * 5 | The counting variable "i" is replaced with 2, which subtracted by 3 = -1; therefore, no index is added. | MYVAR * 5 | 50 * 5 = 250 |
4 | MYVAR#(i - 3)# * 5 | MYVAR#1# * 5 | The counting variable "i" is replaced with 4, which subtracted by 3 = 1; therefore, the index of 01 is added. | MYVAR01 * 5 | 100 * 5 = 500 |
IF statements
If the result of the term is outside of the available range of the indexed variable, it cannot be calculated. Therefore, an IF statement can determine which formula is used.
Example
This example shows how the "i" counting variable is used with IF statements, which states if the "i" value is lower than the maximum value, then a calculation formula using the "i" value can be used; otherwise, the "i" value is used directly as the index value. It uses the following variable values to explain the results of the calculations:
- MYVAR01 = 100
- MYVAR02 = 200
- MYVAR03 = 300
- MYVAR04 = 400
- IMAX = 4
The following table uses different formulas in a Master BOM or sub-checklist line and explains which formula is used based on the result of the IF statement.
"i" value | Formula | IF statement | Reason | Variable Calculation | Result |
---|---|---|---|---|---|
2 | IF(#i# < IMAX; MYVAR#(i + 1)# * 2; MYVAR#I# * 2) | true | "i" (2) is lower than "IMAX" (4) so the true part of the IF statement is calculated because then the highest result of the term can be 3 + 1 = 4, and the variable MYVAR04 exists. | MYVAR#(i + 1)# = MYVAR03 | 300 * 2 = 600 |
4 | IF(#i# < IMAX; MYVAR#(i + 1)# * 2; MYVAR#I# * 2) | false | "i" (4) is the same as, not lower than, "IMAX" (4), so the false part of the IF statement gets calculated. | MYVAR#i# = MYVAR04 | 400 * 2 = 800 |
See Also
Dynamic Master BOM
Dynamic Checklist
Feedback
Submit feedback for this page .