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
 All Forums
 Origin Forum for Programming
 Forum for Origin C
 Buggy string::GetToken() ?

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
additive Posted - 04/04/2009 : 12:33:18 PM
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);
}
5   L A T E S T    R E P L I E S    (Newest First)
cpyang Posted - 04/05/2009 : 07:50:30 AM
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
rlewis Posted - 04/04/2009 : 5:15:43 PM
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);
}
additive Posted - 04/04/2009 : 5:04:41 PM
@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
rlewis Posted - 04/04/2009 : 4:32:18 PM
Also ...

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

assigns NumTokens the value 2
additive Posted - 04/04/2009 : 12:46:17 PM

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


doesn't work either.


The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000