0
Started

Undefined Qcode variable without error

Pierre Fagrell 5 months ago in IQANdesign updated 2 months ago 9

IQANdesign 6.00

I have a function group that I have copied from an MC42 to MD4.

Everything looks ok and project check shows no errors but simulator behaves weird so I start to investigate.

As soon as I click on the digital channel "reset 10k pulses mx" it turns red and I notice one variable in the Qcode is undefined:

Now if I do a project check I also get the error message "Undefined Reference"

Under review

Do you have another channel with the exact same name that is also in scope?

What you describe, with the error not showing until you click on the channel sounds a lot like the behavior when there is a duplicate name.

If you make a change that creates another channel with identical name that is also in scope (e.g. by making the channel with the same name public scope), you will have this situation.

The old Qcode expression will be intact and refer to the original channel, but when you click on it IQANdesign goes through it again and can no longer resolve the expression.   

But if this is the issue here, I would have expected a different error message. If it is the problem with duplicate names then the old name should have been in the expression, and the tool tip should have shown "component name not unique"

On a side note, this is an alternative way of implementing what you have that is slightly more efficient:

Hello Gustav

I do not have anything with the same name in scope.

If I start to type in a new variable in this function the following three variables are displayed as alternatives:

  • Mixingscrew new
  • Mixingscrew REAL
  • Mixingscrews Prod. Manual

If I actually check the project source (while the error is still invisible). I can see that it shows Undefined:

To reiterate what I did:

  • I had a project with MD4+MC42
  • Add XC42
  • Copy function group from MC42 to XC42
  • Change some function names in the group to make them more unique while reassigning new inputs from XC42
  • Delete MC42 from project

RE side note: Thanks. There is a lot in this inherited project that can be improved, All suggestions are appreciated, I am working on it slowly :)

Thanks. I tried reproducing in different ways, so far without success. 


-copy or move? (when moving the channels keep their component ID:s)

-do you remember at what point you assigned the DPCNT to the XC42? 

I restored some old versions of the project and I can see that I did copy the function.

Then I renamed these channels because in the original MC42 function there are five channels with the same name "reset 10k pulses".

After that I probably clicked the DPCNT in the copied function and clicked "Replace channel"


If you need I can ofcourse send you the project via email.

Thanks Pierre! I managed to reproduce the bug, the problem came with the Replace channel operation. 

This problem also happens if you copy a function group containing an arraychannel referencing itself.

Everything looks fine and check project gives no errors until you actually click on the array channel inside the new function group.

Undefined[ArrayIndex] := Input value (FGI)

Thanks. I checked and the array copy does refer to itself as intended, but as you say, when selecting it, the Qcode parser flags it up as an an error. 


The issue in the original post was solved in 6.01 (case 49327), this one will have to be fixed in a later release, probably 6.02.


On a related topic, in a post here, there is an idea about introducing a  "this" or "self" keyword. We don't have it at the moment, but I think it would give a nicer way of writing the code. 

That is a very good idea! It would make it easier to make reusable functions and copy between applications.