GetTokenPosX

GetTokenPosX
int GetTokenPosX(string teststr, string tokens, int pos, int start)

Documentation

Finds the string position at which the occurance of a certain token offset happens. Useful with the also vaulted functions TokenLeft() and TokenRight().

Example Usage

int GetTokenPosX(string teststr, string tokens, int pos, int start)
// Pass: string to be tokenized, token delimiters, token number, starting position in the string.
// Return: Position of token within the string.
{
	int i, t;
	int count = 0;
	int length = len(teststr);
	int numtoks = len(tokens);
	if (pos == 0) return 0;
	for (i = start; i < length; i++)
	{
		for (t = 0; t < numtoks; t++)
		{
			if (!strcmp(mid(teststr, i, 1), mid(tokens, t, 1)))
			{
				count++;
				if (count == pos) return i;
				t = numtoks;
			}
		}
	}
	return i;
}
Talkback

There are no talkbacks on this documentation page yet. Post the first?

Post a new comment?

Doc Nav

Your docs
View All Docs

If you log in, you can edit the documentation, or create your own documents and tutorials!

Ben McGraw's lovingly crafted this website from scratch for years.
It's a lot prettier this go around because of Jon Wofford.
Verge-rpg.com is a member of the lunarnet irc network, and would like to take this opportunity to remind you that regardless how babies taste, it is wrong to eat them.