idea/request for string manipulation

Discussion and feedback on Construct 2

Post » Fri Dec 16, 2011 2:33 pm

split string by character " " and set lastdatastring

i know it can be achieved by looping thru characters, but i like to request such a feature because it symplifies alot of overhead events in an way that is both usefull and understandeble for beginners and advanced users

what do you think?

example:
data="level1||param|param|param|level2||param|param|param|"

data split string by "||"

set level1 to lastdatastring "param|param|param|"
set level2 to lastdatastring "param|param|param|"

level1 split string "|"
lastdatastring "param"
lastdatastring "param"
lastdatastring "param"

ImageImage
B
61
S
19
G
6
Posts: 809
Reputation: 9,028

Post » Fri Dec 16, 2011 3:27 pm

I use an array to do this like:
[code]
Set str = "String|String|Test|String"
Set tc = tokencount(str, "|")
Array->SetSizeTo(tc)
For "Loop" from 0 to tc - 1
{
    Array->tokenat(Str, loopindex, "|")
}
[/code]
Now I have an array with all tokens!
Be nice with others and with yourself!
My musics: https://soundcloud.com/vinians
My C2 Forum:
http://nmbr.forumeiros.com/
My Site:
http://www.dicasebytes.com.br
B
21
S
5
G
6
Posts: 166
Reputation: 4,885

Post » Fri Dec 16, 2011 3:52 pm

The tokenat and tokencount expressions already do this.
Scirra Founder
B
359
S
214
G
72
Posts: 22,949
Reputation: 178,544

Post » Fri Dec 16, 2011 4:02 pm

hu, will this give you the full string before or between the seperator

to me it looks not complete, or im missing something that i didnt know
ImageImage
B
61
S
19
G
6
Posts: 809
Reputation: 9,028

Post » Fri Dec 16, 2011 4:03 pm

ow then i must have used a wrong example and its far easyer then i thought

@Vinians thanx for the example, i will try this outvtrix2011-12-16 16:09:35
ImageImage
B
61
S
19
G
6
Posts: 809
Reputation: 9,028


Return to Construct 2 General

Who is online

Users browsing this forum: Ethan and 12 guests