kedi Posted August 5, 2021 Share Posted August 5, 2021 Have channel group T. Want to clear the history of the whole group. Is there a one step command? Or do I need to loop? Quote Link to comment Share on other sites More sharing options...
AzeoTech Posted August 5, 2021 Share Posted August 5, 2021 You would need a loop. Use channel.listall() to get a list of all the channels in the group, then loop through them, using execute() to call clearHistory() on each one. Quote Link to comment Share on other sites More sharing options...
kedi Posted August 6, 2021 Author Share Posted August 6, 2021 private string clist = channel.listAll("T1") for (private i = 0, i < numrows(clist), i++) execute("ClearHistory" + clist + ) endfor This throws an error. C1070 Not enough parameters for the given operator: Discharge Line 3 - Uncaught error in sequence Discharge I missed something here. Is is because it is a channel group? I need to use a different command parameter? Quote Link to comment Share on other sites More sharing options...
AzeoTech Posted August 6, 2021 Share Posted August 6, 2021 When using execute() or evaluate() and things don't go as planned, I recommend adding a ? statement before it so you can see what the string you are building becomes. In your case, you have to fix a more fundamental error first, the trailing + sign. Then it would read: ? "ClearHistory" + clist execute("ClearHistory" + clist) The next problem is that clist is an array, and you aren't subsetting. Since string concatenation with + only supports scalars, DAQFactory will ignore the array and just use the first element ([0]). Well, that isn't what you want. You need to add after clist to get each channel in the list as you iterate. Finally, once you fix all the syntax errors: ? "ClearHistory" + clist execute("ClearHistory" + clist) You'll see that the string you are building makes no sense. ClearHistory is a function of individual channels. So, to clear the history of myChannel you would do: myChannel.clearHistory() In your case, if clist has "myChannel", you'd get: ClearHistoryMyChannel which will do nothing but probably generate another error. The ? statement would show you this problem. So, you need to modify your string build up to create the correct string. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.