7/3/2019 10:24 AM | |
Joined: 10/5/2017 Last visit: 4/25/2025 Posts: 7 Rating:
|
Device: TP700 Comfort Hello everyone I am having a frustrating issue with trying to get this below script to work using the For loops "prdctCount" variable declared as "Dim prdctCount" as the array's index reference as shown.
Simply putting "prdctCount" itself as the index like this: SmartTags("ProductsCopy_DB_Dough_Ball{prdctCount}.Date_Time").Value Does not work. It made sense logically to me to have it this way, because if I put the exact index of the array element I want to access like this: SmartTags("ProductsCopy_DB_Dough_Ball{1}.Date_Time").Value It works. This tag is from a DB that has an array of UDT type with information about each dough ball. In the code snippet, I tried using {" & prdctCount & "} to reference the array index using the tag, however, it still does not work. I have had a look at https://support.industry.siemens.com/cs/ww/en/view/26165877 and I cant make sense of anything. Attached in the error message I get when trying it with the aforementioned code. Kind regards
|
Last edited by: Jen_Moderator at: 07/03/2019 14:00:19Optimized link. Last edited by: BGImmelman at: 07/04/2019 11:23:18hmi, array, indexing, for loop, WinCC, VBScript, datalogging, UDT |
|
7/8/2019 1:08 PM | |
Joined: 10/5/2017 Last visit: 4/25/2025 Posts: 7 Rating:
|
Nobody have any suggestions / ideas? |
7/10/2019 12:41 PM | |
Joined: 7/5/2013 Last visit: 4/25/2025 Posts: 3149 Rating:
|
Hello BGImmelman, I found this discussion about the tag-name-assembly in a script in the German forum. mm76 found that tags with assembled names in scripts work when the tags are used with I/O fields. Finally he created a dummy script (which is not called in the application) where the tags (with the complete names) are assigned with 0. Then also the assembling in the really used script would work. Regards, Frink |
Pi is exactly three! |
|
This contribution was helpful to
1 thankful Users |
7/11/2019 8:51 AM | |
Joined: 10/5/2017 Last visit: 4/25/2025 Posts: 7 Rating:
|
Hey Prof. Frink,
I had a look at that forum as well, and tried to make sense of it myself, along with your summary. I don't understand what "tags with assembled names" implies, and for them to be used with I/O fields. Are you talking about tags declared locally in the script with "Dim whatever" that are then used with an I/O field element on the screen itself? _____________________________________________________________________________ Is my understanding correct in thinking that I have to set the acquisition mode for all tags I would be using (DB Tags too) to "Cyclic Continuous"? In addition to that, as you said, have a separate dummy VBScript which just initializes all the tags linked to the array DB to 0 (and any other internal hmi tags), for example: SmartTags("ProductsCopy_DB_Dough_Ball{1}.Recipe_Number").Value = 0 (For each element?) while still using a locally declared Dim prdctCount variable to access the array's elements through the loop? ______________________________________________________________________________ Or rather use an internal integer type HMI tag and initialize that in a dummy script too, and then link it to the local prdctCount variable. Something like: SmartTags("indexNr") = prdtCount where I then use the internal tag to reference the array's index instead? SmartTags("ProductsCopy_DB_Dough_Ball{" & indexNr & "}.Recipe_Number").Value For prdctCount = 1 To 10 SmartTags("indexNr") = prdtCount 'CREATE DATASET TO POPULATE CSV FILE ROW dataValues = _ SmartTags("ProductsCopy_DB_Dough_Ball{" & indexNr & "}.Date_Time").Value & ";" & _ SmartTags("ProductsCopy_DB_Dough_Ball{" & indexNr & "}.Recipe_Name").Value & ";" & _ SmartTags("ProductsCopy_DB_Dough_Ball{" & indexNr & "}.Recipe_Number").Value & ";" & _ ... ... ... 'FILL CSV FILE ROW WITH DATASET fctl.LinePrint dataValues Next This feels like some sort of massive over-complication for just wanting to run a for loop to index through an array of UDT of whatever size. I apologize if I missed point. Thank you for at least taking the time to reply. Kind regards, BGImmelman |
Follow us on