How do I edit a random string

Get help using Construct 2

Post » Wed Aug 26, 2015 12:47 pm

Hi everyone,

I have an array full of string objects. My code chooses one of those objects and then writes it to a global variable.

The catch is, each string has extra characters that I don't want.

For example,

in 0,0 the string is A.object
in 0,1 the string is B.object
ect

How can I remove the "object" part of the string before writing it to the global variable (The result is ends up being just the initial letter in the global variable). Is it even possible?

Thanks!
B
13
S
6
Posts: 130
Reputation: 1,553

Post » Wed Aug 26, 2015 12:57 pm

Maybe set the variable using the 'Left' expression?
If your vision so exceeds your ability, then look to something closer.
Moderator
B
134
S
30
G
86
Posts: 5,422
Reputation: 59,530

Post » Wed Aug 26, 2015 3:30 pm

zenox98 wrote:Maybe set the variable using the 'Left' expression?



Hi Zenox98,

not exactly what I was expecting but I can make it work!

Thank you very much for your help :).
B
13
S
6
Posts: 130
Reputation: 1,553

Post » Wed Aug 26, 2015 6:01 pm

@TMAJA using Left would require knowing how many characters to the left of the decimal you have (which may work fine if you are just working with the alphabet or know you will only have one digit names). If your string objects potentially have names longer than one digit, then you could use TokenAt

eg: global variable = TokenAt(string,0,".")
B
98
S
34
G
20
Posts: 438
Reputation: 17,815


Return to How do I....?

Who is online

Users browsing this forum: brunopalermo, Jackriduk, kiki4construct and 26 guests