Array Cell Number by Alpha?

Get help using Construct 2

Post » Tue Jul 30, 2013 6:55 pm

Hi! This may be a totally obvious thing but I can't seem to figure it out.

I have an array filled with object names:

0 "Alpha01"
1 "Alpha02"
2 "Beta01"
3 "Beta02"
4 "Beta03"
5 "Delta01"
6 "Delta02"
7 "Delta03"
8 "Delta04"
9 "Epsilon01"

I would like to scan each cell for first letter and return the cell value of the first cell to contain that value.

Looking for "A" would return 0.
Looking for "D" would return 5.
Bonus: Looking for "C" would return 5 or the next closest letter in line.

Basically I am trying to create an alphabet index to jump around the long list in my array to make access quicker...

I think I am just lacking a way to look at only the first letter of each cell and not the whole cell itself.

I will try and make a simpler capx to post... this is one small part of a much larger project, I should have done a prototype in a standalone capx first!

Thanks!goblynn932013-07-30 18:55:27
B
10
S
4
G
2
Posts: 133
Reputation: 2,667

Post » Wed Jul 31, 2013 1:28 am

I've figured out how to use IndexOf() and it works great as long as my string is exactly the same as my IndexOf(str).

I am guessing there is a way to add in Left (text, count) to get the rest of this done...

*edit
Looking farther it doesn't seem there is an easy/elegant way to do this.

IndexOf("B"wildcard) would be ideal.

Without that option I have to pull each cell value individually, ForEach, truncate it, check it vs my conditions, reject or accept it, set a variable with its cell number, and move on.

That's a lot to do... No Wildcard??

No way to do like command line style "DIR B*.exe"?goblynn932013-07-31 01:49:24
B
10
S
4
G
2
Posts: 133
Reputation: 2,667

Post » Wed Jul 31, 2013 3:27 am

Try a dictionary object.
B
22
S
4
G
1
Posts: 100
Reputation: 2,150


Return to How do I....?

Who is online

Users browsing this forum: cb130felix, dop2000, Kermad, Lancifer, piddlyPoo and 7 guests