The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 Forum for Origin C
 Buggy string::GetToken() ?
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

additive

Germany
109 Posts

Posted - 04/04/2009 :  12:33:18 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. 8 SR4

Hi,
could you please have a look at this basic string method?
Thanks,
Michael


void AdventurousToken()
{
	string strDate, strDay, strMonth, strYear;
	
	strDate = "20.07.t007"; // works
	strDay    = strDate.GetToken(0,'.');
	strMonth  = strDate.GetToken(1,'.');
	strYear   = strDate.GetToken(2,'.');
	printf("\nDay: %s, Month: %s, Year: %s\n", strDay, strMonth, strYear);

	strDate = "20.07.2007"; // seems not to work
	strDay    = strDate.GetToken(0,'.');
	strMonth  = strDate.GetToken(1,'.');
	strYear   = strDate.GetToken(2,'.');
	printf("Day: %s, Month: %s, Year: %s\n", strDay, strMonth, strYear);
}

additive

Germany
109 Posts

Posted - 04/04/2009 :  12:46:17 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply

strDate = "20.07.2007";
StringArray saTokens;
strDate.GetTokens(saTokens, '.');


doesn't work either.

Go to Top of Page

rlewis

Canada
253 Posts

Posted - 04/04/2009 :  4:32:18 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Also ...

	strDate = "20.07.2007";
	int NumTokens=strDate.GetNumTokens('.');

assigns NumTokens the value 2
Go to Top of Page

additive

Germany
109 Posts

Posted - 04/04/2009 :  5:04:41 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
@rlewis
Thank you for reproducing!
I'm using GetToken() quite often and don't want to know how many dangerous errors it already has produced ...
Although such easy-to-use tokenizers are pretty nice to use and seldom found in other languages one should apply them carefully.
Thus, programming with OriginC remains exciting even during easy tasks

Edited by - additive on 04/04/2009 5:05:32 PM
Go to Top of Page

rlewis

Canada
253 Posts

Posted - 04/04/2009 :  5:15:43 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Here is another interesing quirk .....

int AdventurousToken()
{
	string strDate, strDay, strMonth, strYear;
	strDate = "20.07. 2007"; // Works ... Note the space before 2007
	strDay    = strDate.GetToken(0,'.');
	strMonth  = strDate.GetToken(1,'.');
	strYear   = strDate.GetToken(2,'.');
	printf("Day: %s, Month: %s, Year: %s\n", strDay, strMonth, strYear);
}
Go to Top of Page

cpyang

USA
1406 Posts

Posted - 04/05/2009 :  07:50:30 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks for reporint this, it was reported a long time ago but we somehow didnt fix this earlier.

It is tracker number 5645. We should certainly address this in SR5.

CP
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000