Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / GetStringToken but with full delimiter chars search instead of individual

Author
Message
Chmava
10
Years of Service
User Offline
Joined: 20th Jun 2013
Location:
Posted: 13th Mar 2019 13:07 Edited at: 13th Mar 2019 13:10
GetStringToken but with full delimiter chars search instead of individual

What the title said...
Does this need to be requested?

basically it is like php explode as delimited string is pretty sensitive.
It is stupid agk does not have this and return a split for every single char in delimiter field.

It is also possible to use findstringreverse to manually split it with mid, but this is kind of stupid?
Bengismo
6
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 13th Mar 2019 14:35 Edited at: 13th Mar 2019 14:37
Im not really sure what you mean? You can use multiple delimeter characters with the GetStringToken function.

Also, GetStringToken2() might be what you want instead if you want to get zero length strings.

Neither function returns just a single character - they will both return full strings.

Can you elaborate on what you want?
Chmava
10
Years of Service
User Offline
Joined: 20th Jun 2013
Location:
Posted: 13th Mar 2019 16:40 Edited at: 13th Mar 2019 16:44
I mean if I have a sting like this: 1:;2;3

and i use GetStringToken ("1:;2;3", ":;", 2), I expect the answer "2;3"
Instead, I get, "" instead

When converted to an array, it end up looking like this:

array[1] = 1
array[2] =
array[3] = 2
array[4] = 3

Instead of this:

array[1] = 1
array[2] = 2;3

I can't use getstringtoken2 because of this.
Perhaps there is a way to request for there to be a GetStringToken3()
Bengismo
6
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 13th Mar 2019 17:25 Edited at: 13th Mar 2019 17:26
You could just use GetStringToken2() and a function



This function gives you an array of strings back and appears to do what you want..... ? (It does what you asked for above at least)
Santman
12
Years of Service
User Offline
Joined: 15th Sep 2011
Location: Inverness
Posted: 13th Mar 2019 18:11
I actually think your code should be working, that does look like it should return the text your expect. Will try it for myself soon.
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 13th Mar 2019 20:52
I think Chmava wants the delimiter to be two bytes long rather than one. I don't think either StringToken function supports that
puzzler2018
User Banned
Posted: 13th Mar 2019 20:57
Could make own like similar to Bengismo's
Tier 1 Developer
Santman
12
Years of Service
User Offline
Joined: 15th Sep 2011
Location: Inverness
Posted: 13th Mar 2019 21:08
For the normal get string token, the help file specifically says it can be multiple characters though does it not?
puzzler2018
User Banned
Posted: 13th Mar 2019 21:11
Allows multiple characters but maybe it uses it like:-

Delimeter = :;

So the : is a deliimeter
and the ; is also a delimater

and not the full ;:

Thats how it seems to be working for me too
Tier 1 Developer
puzzler2018
User Banned
Posted: 13th Mar 2019 21:23
Where is my C#. We can do this in a heartbeat surely with commands and create a plug-in if Paul doesnt have time, using the string() commands

.Substring
.IndexOf
.Remove

But that is really for another day.
Tier 1 Developer
Santman
12
Years of Service
User Offline
Joined: 15th Sep 2011
Location: Inverness
Posted: 13th Mar 2019 22:20
Ah no, I see it now....I;ve never outright tried that kind of seperation, but I read the help file differently, and would assume putting ":;" as the delimiter would make it look for that specific combination as the delimiter.
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 13th Mar 2019 22:24
Using ":;" as a delimiter will make ":" or ";" delimiters
Bengismo
6
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 13th Mar 2019 22:57 Edited at: 13th Mar 2019 22:59
Ahhh.... so he wants to split the string by using another string as the delimiter...and store all the results



^^This code does that ....the explode function breaks a long string into substrings separated by a delimiter string. Its not a complicated function really

Sometimes just finding what people want is the hard part.
puzzler2018
User Banned
Posted: 13th Mar 2019 23:02
We got there in the end lol

Thanks Bengismo - awesome code as ever to acheive the results
Tier 1 Developer
Chmava
10
Years of Service
User Offline
Joined: 20th Jun 2013
Location:
Posted: 14th Mar 2019 03:48
I mean dynamically?
And pretty much any length?

Like $array = explode(!@#$%^&*()_+", $string);
Like $array = explode"<div>", $string);

And yes, I did use a function with find string to do the same.
This post is more of a request for a more direct function in agk...
Perhaps someone could send a request to the actual development team?
Bengismo
6
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 14th Mar 2019 09:10 Edited at: 14th Mar 2019 17:17
chmava wrote: "I mean dynamically?
And pretty much any length?"


The function I posted above doesnt really have any length limits and will take any delimiter so it does what you ask for

chmava wrote: "Like $array = explode(!@#$%^&*()_+", $string);
Like $array = explode"<div>", $string);"

Thats exactly what i wrote
function Explode(text as string,delimiter as string)
which passes back an array

If you want it as a function inside of AppGameKit then there is a requests thread here:
https://forum.thegamecreators.com/thread/212232

but since its possible to do it easily without the function built into agk, im not sure why anyone would bother adding it. Its simple text manipulation. Good luck

Login to post a reply

Server time is: 2024-04-25 16:17:26
Your offset time is: 2024-04-25 16:17:26