Applies To: |
|
Summary: |
What is the difference between doing
'A=PT101' and 'A=TagRead("PT101")' |
Solution: |
When CICODE is compiled, all the tags
directly used in the function are listed internally and on calling
the function are requested from the IOServer. 'A=PT101' would therefore be automatically requested the value when the function starts. 'A=TagRead("PT101")' would not recognise PT101 as a tag and therefore the request would not occur until it gets to that line of code, and the function would wait (block) for the value to return. The thing to be aware of in the 'A=PT101' case is the use of loops (eg : WHILE and FOR). As the tags are read at the start of the function call, if a loop is used, theoretically the tag would never be requested again and any changes would not be seen. To rectify this, simply perform a 'ReRead(0)' within the loop. The main reason TagRead was created was so that it was possible to make generic functions that can discover a tag name at runtime and still get tag access. E.g. INT FUNCTION GetPTValue( sPTNumber = "101" ) RETURN( TagRead( "PT" + sPTNumber ) ); END
|
Keywords: |
Cicode, TagRead, Loop, While, For |
Related Links
Attachments