Troubleshooting undefined tag issue in CPT instruction with 5000

Question:

Hello everyone! Recently, I have been paying closer attention to the operands in the CPT instruction in my programming. I noticed an interesting behavior when using expressions like N7[37,1] - N7[35,1]. Upon hovering over N7[37,1], an error message appears: "Invalid Tag Element: N7[37,1] - N7Tag Data Type: DINT[304,3]". However, by adjusting the expression to (N7[37,1]) - N7[35,1], the error message changes to: "Tag Element: N7[37,1] Element Data Type: DINT". This led me to consider the possibility of confusion between NEG and SUB functions in the CPT. For instance, when using 150 - N7[35,1], hovering over 150 displays "Undefined Tag: 150 - N7[35,1]". But when I enclose 150 in parenthesis like this: (150) - N7[35,1], it correctly shows "Value: 150". While I have successfully used similar logic in other programs without any issues, I found this behavior intriguing. Thankfully, there have been no problems with other mathematical operations. I appreciate any insights or advice on this matter. Thank you.

Top Replies

The issue may lie with the code responsible for displaying the tooltip, as it appears to be prioritizing the minus sign over the left bracket. This could be due to the parsing order from left to right. I am encountering this problem while working with Studio 5000 v32.03.

It appears that I have encountered an issue with the program version 34.02 that I am currently working on. Interestingly, when I tested the same process on an older version (32.04), the problem did not occur. Despite having successfully completed previous programs in version 34.02, the issue seems to be specific to the text box object. Adding parentheses to the code results in different output.

Starting from version 34 (or possibly 33), a new feature was introduced where the program would identify the specific elements of an expression that the mouse is hovering over. In version 32, this feature only applied to the entire expression, but in version 34, you can hover over integers, tags, and more. Interestingly, in your case, this feature seems to only be related to the minus operator. I tested other operators in version 34 and encountered no issues. It is possible that there was an error in the rule for the unary minus operator, as handling unary operators in grammars can be complex.

It seems like your program is having trouble parsing the difference between the negative operation (NEG) and the subtraction operation (SUB). Enclosing your constants or expressions in parenthesis often helps in clarifying the operation. While all other mathematical operations might be working fine, subtraction is unique because the same symbol serves two functions: a unary operator (NEG) and a binary operator (SUB). Ensure your parentheses are well placed to signal the intended operation. Also, make sure the integer constants aren't mistakenly identified as tag identifiers, hence why enclosing them in parentheses resolves the "Undefined Tag" error. As per the "Invalid Tag Element" message, check if the array index is within the declared range. I hope this helps!

Interesting observation! In my experience, such anomalies often occur when there is ambiguity in interpreting code syntax. By including parentheses, you seem to have removed a potential ambiguity - it ensures that data or numbers are treated as single entities for operations such as subtraction. Your issue might be due to this peculiarity of syntax interpretation rather than an explicit distinction between NEG and SUB functions. Trial and error is still the best way to discern the rules in such situations. Happy programming!

It seems like you've come across an interesting quirk in how your programming environment processes operands and understands mathematical syntax, specifically subtraction and negation. Encasing numbers or expressions in parentheses likely helps the compiler better discern whether you're intending to subtract or negate. For the instance of 150 - N7[35,1], it could be considering the whole expression as a tag, hence the undefined tag error. When you put 150 in parentheses, it understands it as an integral value, and the subtraction can occur properly. This is some thoughtful analysis on your part, and I'd recommend always using parentheses for clarity to avoid potential syntax confusion in complex expressions.

More Replies →

Streamline Your Asset Management
See How Oxmaint Works!!

✅   Work Order Management

✅   Asset Tracking

✅   Preventive Maintenance

✅   Inspection Report

We have received your information. We will share Schedule Demo details on your Mail Id.

You must be a registered user to add a comment. If you've already registered,
sign in. Otherwise, register and sign in.

Frequently Asked Questions (FAQ)

FAQ: 1. Question: Why do I encounter an "Invalid Tag Element" error message when using expressions like N7[37,1] - N7[35,1] in the CPT instruction?

Answer: Answer: The error message "Invalid Tag Element" appears due to the incorrect format of the expression. By adjusting the expression to (N7[37,1]) - N7[35,1], the error message changes, indicating the correct tag element and data type.

FAQ: 2. Question: What could be causing the "Undefined Tag" error message when using expressions like 150 - N7[35,1] in the CPT instruction?

Answer: Answer: The "Undefined Tag" error message occurs when the expression is not properly formatted. By enclosing 150 in parentheses like this: (150) - N7[35,1], the error is resolved and the correct value is displayed.

FAQ: 3. Question: Is there a difference between using NEG and SUB functions in the CPT instruction that could lead to confusion?

Answer: Answer: Yes, the discussion highlights a potential confusion between NEG and SUB functions in the CPT instruction. Paying attention to the expression format, such as using parentheses when necessary, can help avoid errors and display values correctly.

FAQ: 4. Question: Are there any specific considerations to keep in mind when dealing with mathematical operations in the CPT instruction?

Answer: Answer: While the behavior

Ready to Simplify Maintenance?

Join hundreds of satisfied customers who have transformed their maintenance processes.
Sign up today and start optimizing your workflow.

Request Demo  â†’