Received this question in my inbox and posting it here so that others can also chip in:
It's been a while since I used the FSC now, but from memory you search argument can only check one variable. But you can check one variable and then manually check the others. Assume a UDT with members Year, Month, Day and Data. Assume an array of this UDT called MyUdtArray which contains your data. Assume an FSC with a Control tag called MyFSC. Assume a single instance of your UDT called SearchDate which contains the date you want to search for. Your expression would look something like:
Then when the .FD (found) bit comes on, you manually check to see if the month and day also match, and if not, clear the .IN (inhibit) and .FD (found) bits and let the FSC continue along to the next index.
There are all sorts of ways you could "enhance" this. You could:
- Concatenate the date into a string as you suggest and store that in the UDT each time you add an entry, then do the same with the operator-entered date
- Use math on the operator-entered date to turn it into an integer that LOOKS like a string representation of the date:
...then use the FSC expression:
...so today's date (24th of March 2023) becomes the integer 20,230,324 and then the FSC does the same math on each member of your UDT array to see if it gets the same result
I'm sure others will have more ideas - plenty of ways to remove the hide from this feline.
I need to track data in a 5380 and then need it recallable from the HMI by searching by date. My thought was to use the FSC to search through the array that I will create where all of this data will be stored, elements within the array will be a UDT I’ll create for this specific project. There will be more then three elements within the UDT but for this question let’s just say I’ll have DINTs of, Day, Month, Year. My challenge that I’m mentally wrestling with here is that if the end user puts in the day, month and year from the HMI then wants to search the array using an FSC, am I able to use 3 different variables within the expression for searching the array? And if so, I actually would need to use those 3 variables and they would need to match 3 separate tags within the UDT. I hope that makes sense.
With that said, I wonder if it’s simpler for me to take the date information, which will be in DINT data type, then go DINT to STRING, then concatenate the STRINGS so when I need to search the array, it will be searching for one STRING tag that matches and not 3 separate DINT tags
It's been a while since I used the FSC now, but from memory you search argument can only check one variable. But you can check one variable and then manually check the others. Assume a UDT with members Year, Month, Day and Data. Assume an array of this UDT called MyUdtArray which contains your data. Assume an FSC with a Control tag called MyFSC. Assume a single instance of your UDT called SearchDate which contains the date you want to search for. Your expression would look something like:
Code:
MyUdtArray.Year[MyFSC.POS] = SearchDate.Year
Then when the .FD (found) bit comes on, you manually check to see if the month and day also match, and if not, clear the .IN (inhibit) and .FD (found) bits and let the FSC continue along to the next index.
There are all sorts of ways you could "enhance" this. You could:
- Concatenate the date into a string as you suggest and store that in the UDT each time you add an entry, then do the same with the operator-entered date
- Use math on the operator-entered date to turn it into an integer that LOOKS like a string representation of the date:
Code:
SearchValue = (SearchDate.Year * 10000) + (SearchDate.Month * 100) + SearchDate.Day
Code:
(MyUdtArray[MyFSC.POS].Year * 10000) + (MyUdtArray[MyFSC.POS].Month * 100) + MyUdtArray[MyFSC.POS].Day = SearchValue
I'm sure others will have more ideas - plenty of ways to remove the hide from this feline.