In Java there is a class called StringTokenizer that splits a String in
to pieces, breaking on a set of specified delimiters. I need to do the same thing in ST, splitting the search path on semicolons. Here's what I ended up doing: oc := OrderedCollection new. path := SessionManager current getenv: #path. rs := path readStream. [rs atEnd] whileFalse: [oc add: (rs upTo: $;)]. While this works, I can't help thinking there's a better way. I looked at the String class but didn't see anything that looked like what I wanted. Is this what everyone does, or is there a better way? Joey -----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- http://www.newsfeeds.com - The #1 Newsgroup Service in the World! -----== Over 80,000 Newsgroups - 16 Different Servers! =----- |
Hi, Joey
"Joey Gibson" <[hidden email]> wrote in message news:[hidden email]... > In Java there is a class called StringTokenizer that splits a String in > to pieces, breaking on a set of specified delimiters. I need to do the > same thing in ST, splitting the search path on semicolons. Here's what I > ended up doing: > > oc := OrderedCollection new. > path := SessionManager current getenv: #path. > rs := path readStream. > [rs atEnd] whileFalse: [oc add: (rs upTo: $;)]. Try it: path := SessionManager current getenv: #path. oc := path subStrings: ';'. Sincerely, Dmitry |
In article <9gt1p2$eat$[hidden email]>,
[hidden email] says... > path := SessionManager current getenv: #path. > oc := path subStrings: ';'. Good grief. How did I miss that? Thanks, that's exactly what I needed... Joey -----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- http://www.newsfeeds.com - The #1 Newsgroup Service in the World! -----== Over 80,000 Newsgroups - 16 Different Servers! =----- |
In reply to this post by Joey Gibson-2
Joey,
I have written a little class <StringTokenizer>, which might be useful, since it is somewhat more flexible, than the built in method. It also has a subclass <ArithmeticTokenizer>, which scans *very* simple arithmetic expressions. This is restricted to 1 character wide terminal symbols. So a*(b+c)/d works, while x == y doesn't. The latter results in #('x' '=' '=' 'y'). bye Ingo "Joey Gibson" <[hidden email]> schrieb im Newsbeitrag news:[hidden email]... > In Java there is a class called StringTokenizer that splits a String in > to pieces, breaking on a set of specified delimiters. I need to do the > same thing in ST, splitting the search path on semicolons. Here's what I > ended up doing: > > oc := OrderedCollection new. > path := SessionManager current getenv: #path. > rs := path readStream. > [rs atEnd] whileFalse: [oc add: (rs upTo: $;)]. > > While this works, I can't help thinking there's a better way. I looked > at the String class but didn't see anything that looked like what I > wanted. Is this what everyone does, or is there a better way? > > Joey > > > -----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- > http://www.newsfeeds.com - The #1 Newsgroup Service in the World! > -----== Over 80,000 Newsgroups - 16 Different Servers! =----- begin 666 StringTokenizer.pac M?"!P86-K86=E('P-"G!A8VMA9V4@.CT@4&%C:V%G92!N86UE.B G4W1R:6YG M5&]K96YI>F5R)RX-"G!A8VMA9V4@<&%X5F5R<VEO;CH@,#L-"@EB87-I8T-O M;6UE;G0Z("<G+@T*#0IP86-K86=E(&)A<VEC4&%C:V%G959E<G-I;VXZ("<G M+@T*#0HB061D('1H92!P86-K86=E('-C<FEP=',B#0H-"B)!9&0@=&AE(&-L M87-S(&YA;65S+"!L;V]S92!M971H;V0@;F%M97,L(&=L;V)A;"!N86UE<RP@ M<F5S;W5R8V4@;F%M97,B#0IP86-K86=E(&-L87-S3F%M97,-"@EA9&0Z("-! M<FET:&UE=&EC5&]K96YI>F5R.PT*"6%D9#H@(T-H87)3970[#0H)861D.B C M4W1R:6YG5&]K96YI>F5R.PT*"7EO=7)S96QF+@T*#0IP86-K86=E(&UE=&AO M9$YA;65S#0H)>6]U<G-E;&8N#0H-"G!A8VMA9V4@9VQO8F%L3F%M97,-"@EY M;W5R<V5L9BX-"@T*<&%C:V%G92!R97-O=7)C94YA;65S#0H)>6]U<G-E;&8N M#0H-"B)":6YA<GD@1VQO8F%L($YA;65S(@T*<&%C:V%G92!B:6YA<GE';&]B M86Q.86UE<SH@*%-E="!N97<-"@EY;W5R<V5L9BDN#0HB4F5S;W5R8V4@3F%M M97,B#0IP86-K86=E(&%L;%)E<V]U<F-E3F%M97,Z("A3970@;F5W#0H)>6]U M<G-E;&8I+@T*#0HB061D('1H92!P<F5R97%U:7-I=&4@;F%M97,B#0IP86-K M86=E('-E=%!R97)E<75I<VET97,Z("A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;&EM<PT*"2)0<FEV871E("T@06YS M=V5R('1H92!V86QU92!O9B!T:&4@<F5C96EV97(G<R G)V1E;&EM<R<G(&EN M<W1A;F-E('9A<FEA8FQE+B(-"F1E;&EM<R!I<TYI;"!I9E1R=64Z6PT*"7-E M;&8@9&5L:6US.B!S96QF(&-L87-S(&1E9F%U;'1$96QI;7-=+@T*"5YD96QI M;7,A#0H-"F1E;&EM<SH@86Y/8FIE8W0-"@DB4')I=F%T92 M(%-E="!T:&4@ M=F%L=64@;V8@=&AE(')E8V5I=F5R)W,@)R=D96QI;7,G)R!I;G-T86YC92!V M87)I86)L92!T;R!T:&4@87)G=6UE;G0L(&%N3V)J96-T+B(-"@T*"61E;&EM M<R Z/2!A;D]B:F5C="$-"@T*:V5E<',-"@DB4')I=F%T92 M($%N<W=E<B!T M:&4@=F%L=64@;V8@=&AE(')E8V5I=F5R)W,@)R=K965P<R<G(&EN<W1A;F-E M('9A<FEA8FQE+B(-"FME97!S(&ES3FEL(&EF5')U93I;#0H)<V5L9B!K965P M<SH@<V5L9B!C;&%S<R!D969A=6QT2V5E<'-=+@T*#0H)7FME97!S(0T*#0IK M965P<SH@86Y/8FIE8W0-"@DB4')I=F%T92 M(%-E="!T:&4@=F%L=64@;V8@ M=&AE(')E8V5I=F5R)W,@)R=K965P<R<G(&EN<W1A;F-E('9A<FEA8FQE('1O M('1H92!A<F=U;65N="P@86Y/8FIE8W0N(@T*#0H):V5E<',@.CT@86Y/8FIE M8W0A#0H-"G-T<FEN9PT*"2)0<FEV871E("T@06YS=V5R('1H92!V86QU92!O M9B!T:&4@<F5C96EV97(G<R G)W-T<FEN9R<G(&EN<W1A;F-E('9A<FEA8FQE M+B(-"G-T<FEN9R!I<TYI;"!I9E1R=64Z6PT*"7-E;&8@<W1R:6YG.B G)UTN M#0H)7G-T<FEN9R$-"@T*<W1R:6YG.B!A;D]B:F5C= T*"2)0<FEV871E("T@ M4V5T('1H92!V86QU92!O9B!T:&4@<F5C96EV97(G<R G)W-T<FEN9R<G(&EN M<W1A;F-E('9A<FEA8FQE('1O('1H92!A<F=U;65N="P@86Y/8FIE8W0N(@T* M#0H)<W1R:6YG(#H](&%N3V)J96-T(0T*#0IT;VME;G,-"GP@;&5N('!O<R!T M;VL@=&UP('P-"@T*;&5N(#H]('-E;&8@<W1R:6YG('-I>F4N#0IP;W,@.CT@ M,2X-"G1O:R Z/2!/<F1E<F5D0V]L;&5C=&EO;B!N97<N#0IT;7 @.CT@5W)I M=&53=')E86T@;VXZ(%-T<FEN9R!N97<N#0H-"EMP;W,@/#T@;&5N72!W:&EL M951R=64Z6PT*"7P@8R!\#0H)#0H)8R Z/2!S96QF('-T<FEN9R!A=#H@<&]S M+@T*"2AS96QF(&1E;&EM<R!I;F-L=61E<SH@8RD@:694<G5E.EL-"@D)*'-E M;&8@:V5E<',@:6YC;'5D97,Z(&,I(&EF5')U93I;#0H)"0ET;[hidden email]!T M;7 @8V]N=&5N=',N#0H)"2 @(" @=&UP(#H](%=R:71E4W1R96%M(&]N.B!3 M=')I;F<@;F5W+@T*"0D)=&UP(&YE>'10=70Z(&-=+@T*"0ET;[hidden email]!T M;7 @8V]N=&5N=',N#0H)"71M<" Z/2!7<FET95-T<F5A;2!O;CH@4W1R:6YG M(&YE=PT*"0E=#0H@(" @(" @(" @(" @(" @(" @(" @(" @(" @(" @:69& M86QS93I;#0H)"0ET;7 @;F5X=%!U=#H@8PT*"0E=+@T*"7!O<R Z/2!P;W,@ M*R Q+@T*"5TN#0H-"@ET;[hidden email]!T;7 @8V]N=&5N=',N#0H-"EXH=&]K M('-E;&5C=#H@6SIE86-H?"!E86-H('-I>F4@/B P72D@87-!<G)A>0T*"0D- M"B$@(0T*(5-T<FEN9U1O:V5N:7IE<B!C871E9V]R:65S1F]R.B C9&5L:6US M(6%C8V5S<VEN9R%P<FEV871E(2 A#0HA4W1R:6YG5&]K96YI>F5R(&-A=&5G M;W)I97-&;W(Z("-D96QI;7,Z(6%C8V5S<VEN9R%P<FEV871E(2 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+RTK)PT* M(2 A#0HA07)I=&AM971I8U1O:V5N:7IE<B!C;&%S<R!C871E9V]R:65S1F]R M.B C9&5F875L=$1E;&EM<R$J+75N8VQA<W-I9FEE9"%P<FEV871E(2 A#0HA M07)I=&AM971I8U1O:V5N:7IE<B!C;&%S<R!C871E9V]R:65S1F]R.B C9&5F M875L=$ME97!S(2HM=6YC;&%S<VEF:65D(7!R:79A=&4A("$-"@T*( T*(D)I B;F%R>2!';&]B86QS(B$-"@T*(E)E<V]U<F-E<R(A#0H-"@`` ` end |
In reply to this post by Joey Gibson-2
Have a look at File>>splitPath: aString
Bye, Ernest |
Free forum by Nabble | Edit this page |