EA1 Posted December 13, 2012 Share Posted December 13, 2012 I have a series of valves that are each activated by a sequence call. I would like to create a simple way to re-order the valve sequences without creating a new script each time. Basically, I'd like to enter the numeric valve order somewhere on a control page, and have these values be used to call the correct sequence in the correct order. Any suggestions? Thanks. Link to comment Share on other sites More sharing options...
AzeoTech Posted December 13, 2012 Share Posted December 13, 2012 Should be pretty easy if you name your sequences sequentially, say "Valve1", "Valve2", etc. Then, let's say you have a global string variable called "order". If you run this sequence, it will call those sequences inthat order: for (private i = 0, i < getLength(order), i++) try execute("valve" + mid(order,i,1) + "()") catch() ? strLastError // don't stop if there's a typo endcatchendfor[/CODE] Link to comment Share on other sites More sharing options...
EA1 Posted December 14, 2012 Author Share Posted December 14, 2012 Thanks very much! This works as you said. 2 more questions, though: 1) for more than 9 valves, I could substitute letters for single digits and address an alphabet's worth of valves, but how would your code work if there was a 2 digit number for each valve sequence....e.g., up to valve99. 2) Is there a way to do something similar with string arrays, if the sequences are named without the same string format? Link to comment Share on other sites More sharing options...
AzeoTech Posted December 14, 2012 Share Posted December 14, 2012 There are lots of ways of doing it. If you wanted more than 9 valves, I'd probably start with the alphabet before moving to two digits. Since DF is not case sensitive, you can only go through it once, but that would get you 36 valves. If you wanted two digits, you just have to change the script a little, making i++ to i+=2, and the 1 inside the mid() to a 2. Using a string array would work if you didn't want to name the scripts valve1, valve2. Just create the array: private seqList = {"valve1seq", "anotherValve"} then change the execute line to: execute(seqList[strToDouble(mid(order,i,1))]) change the 1 to 2 for 2 digit specifications. Note that you have to use numbers in this case, and 0 is the first one. Link to comment Share on other sites More sharing options...
EA1 Posted December 14, 2012 Author Share Posted December 14, 2012 Thanks again! As I am (obviously) a novice at this, could you explain how the string variable "order" (and its length) is related to the seqList array elements? I am confused about this....I tried the sequence with an array set up with the original valve1, valve2, etc., sequence names but the array technique didn't seem to work the same way as your first suggestion. The sequence ran, but didn't return info that the valve sequences were activated. Link to comment Share on other sites More sharing options...
AzeoTech Posted December 17, 2012 Share Posted December 17, 2012 Order is a global string that you enter to specify the order to execute. So if order = "10" it would, in my example, do anotherValve sequence first, then valve1seq. Link to comment Share on other sites More sharing options...
jyoti Posted January 4, 2013 Share Posted January 4, 2013 hello guru , Can u tell me which language u are using for coding in DAQ factory? Link to comment Share on other sites More sharing options...
AzeoTech Posted January 8, 2013 Share Posted January 8, 2013 For scripting? Its our own language, optimized for data acquisition. Its modeled loosely on C, VB and Javascript. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.