FSC - Expression Help

JosephMont

Member
Join Date
Oct 2014
Location
Yakima
Posts
67
RSL5K, V30, L85

Utilizing an FSC to find a value less than 1116, and greater than 1100. I canT seem to figure out how the expression is supposed to be formatted.

It is searching through a single dimension array[50] that is utilizing a UDT.

The one on the bottom find everything less than 1116, but includes the zero's from an array that are not utilized.
 
After carefully reading the expression rules for the CMP instruction, one would think the following is acceptable:

(Array[zFSC.POS].Lane > 1100) AND (Array[zFSC.POS].Lane <1116)

But no, apparently the AND operator in this context will not accept inequalities as operands; only tag references seem to work.

One approach to using FSC in this situation would be the expression

((Array[zFSC.POS].Lane - 1100) * (1116 - Array[zFSC.POS].Lane)) > 0

You could also do a two-step process to FSC greater than 1100, and then test each found element against 1116.

Or loop through the array with a FOR and test in a subroutine.
 
Last edited:
Array[FSC.POS] MOD 1116>1100

I Tried this expression and it finds numbers 1101 to 1115 only.
 
Last edited:
Strictly speaking, the MOD method will only work for array values less than 2217. Probably reasonable in this case.
 
trial and error with the MOD instruction. Found that any number less than MOD would return that number.

Capture1026_1.jpg
 
Strictly speaking, the MOD method will only work for array values less than 2217. Probably reasonable in this case.

It seems to work. Could you explain why in would not. I could not find anything in the help file about it.

Capture1026.jpg
 
It seems to work. Could you explain why in would not. I could not find anything in the help file about it.

Using MOD to test whether a value is between 1100 and 1116 works fine if the range of values under test is less than or equal to (1116 + 1100).

But the MOD 1116 operation will start to return 1, 2, 3, ... 1100, 1101, ... for test values 1117, 1118, 1119, ... 2216, 2217, ... and so on. Therefore. it will start evaluating true again at 2217 through 2231, and then again at 3333 through 3347, and so on.

The expression could be made a bit more complex and work by forcing the array value to be less than 1116. It seems that MOD always returns zero for negative numbers, meaning that it would only be a little more complex.
 
Last edited:
Mispeld, I see what you mean now. 2217-1116=1101. So the MOD expression would find it. Thanks for clearing that up.

JoesphMont,
Mispeld expression is the best approach. If all search ranges are in the same array.

It would require multiple FSC instructions to find different ranges with each expression being adjusted to meet your requirements.
 
For comparing a range of Dints, subtract the highest number that you want to find (1115) from 2147483647 (2147482532), then subtract the span (1115-1101+1=15) from 2147483647 (2177483632) and use that for your comparison. Thus your expression would be

(B_Group_1_Found_Array[zFSC.POS].Lane+2147482532)>2177483632
 

Similar Topics

Hello, Trying to use an FSC instruction to search an array for part number. Hardware - 5069-L306erms C-More Headless HMI Software -...
Replies
2
Views
1,099
Hello, does anybody know if it is possible to replace a table name within a FSC expression with a variable that updates the table name based off...
Replies
1
Views
1,283
Hello all, I'm trying to use the FSC function in Studio 5000, but i keep getting the error "Invalid Expression". I am hoping one of you might be...
Replies
12
Views
2,502
Maybe this is just not possible, or maybe I am doing something wrong. Background; I have a data array of over 1500 products. For sorting I...
Replies
6
Views
765
I am trying to use the FSC to count how many numbers in my real array are less than a certain value but not sure why I cant for the life of me get...
Replies
11
Views
386
Back
Top Bottom