Comparing value vs array - can't get middle values

Get help using Construct 2

Post » Tue Aug 20, 2013 6:31 am

I have two arrays, one small one big.

The user picks a Name from the big array. The system compares that name against the Names in the small array. If the Name is in the small array it returns a value of 1, if its not it returns a value of 2.

Or at least its supposed to...

I have set this up two different ways.

#1 using an Array loop
#2 using a System.For loop.

Setup #1 will return a value of 1 only on the -last- X item from the small array. All other items that match do not return a proper value. I've tried both with and without the TriggerOnce sub shown in the image.



Setup #2 will return a value of 1 only on the -first- item from the small array. All other items that match do not return a proper value.



Example:

ListA:
Crazy
Silly
Sassy

ListB:
Crazy
Funny
Silly
Sassy
Manly
Scared

User selects from ListB:
Manly - return value 2
Silly - return value 1
Scared - return value 2
Sassy - return value 1

Currently I can get a value of 1 on Sassy or Crazy but not Silly... any cell between the first and last I can't get a proper value returned!goblynn932013-08-20 06:42:10
B
10
S
4
G
2
Posts: 133
Reputation: 2,667

Post » Tue Aug 20, 2013 7:09 am

Setup #1 won't work because Stop loop is a System action, not an Array action. It won't actually stop.

Setup #2 won't work because you need to index the array with loopindex, not CurValue/CurX.
ImageImageImage
B
71
S
22
G
249
Posts: 3,762
Reputation: 138,575

Post » Tue Aug 20, 2013 7:14 am

@blackhornet Setup 1 is actually built off a CAPX you helped me with! I had some other help and realized about the Stop Loop but the CAPX you made worked... I'm assuming because it only searched out one value and I have need of multiple. Either way you've saved my day both times!! This is the main thing that's been stopping me from finishing tonight :D That definitely worked by the way. I'm getting proper values all the time now!goblynn932013-08-20 07:16:06
B
10
S
4
G
2
Posts: 133
Reputation: 2,667

Post » Tue Aug 20, 2013 7:21 am

Simpler way to do this might be using IndexOf expression. No need to iterate through arrays. :)vee412013-08-20 07:22:11
B
24
S
9
G
7
Posts: 756
Reputation: 7,312


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 21 guests