String findTokens:?

Jimmie Houchin jhouchin at texoma.net
Tue Apr 22 21:02:56 UTC 2003


Joshua 'Schwa' Gargus wrote:
> Hi Jimmie,
> On Tue, Apr 22, 2003 at 03:08:08PM -0500, Jimmie Houchin wrote:

Hello Joshua, thanks for the reply.

>>First here's my code from a workspace.
>>
>>| file fc ft t1 t2 oc |
>>t1 _ '#EXTINF:'.
>>t2 _ ',Alexander Scourby - '.
>>oc _ OrderedCollection Collection new.
>>file _ FileList2 modalFileSelector.
>>fc _ file contentsOfEntireFile.
>>file close.
>>
>>ft _ fc findTokens: t1.
>>ft inspect.
>>
>>
>>Yes, I know, t2 and oc currently are unused.
>>
>>1. I am creating a variable for the file contents and then discarding 
>>(closing) the file. Is that good form? Or would it be just as 
>>appropriate to assign the file contents into the file variable?
> 
> You're doing the right thing.  Otherwise how would the file get closed?

That's what I was thinking. I just didn't know if it would automatically 
get garbage collected. I keep writing that way then. :)

>>2. The statement ft _ fc findTokens: t1.  isn't doing what I want.
>>It is however, doing what it claims. :)
> 
> Yes, it is doing what it claims.  If you look at the code for findTokens:
> you see that the argument is suggestively named "delimiters": this is a
> collection of characters that are looked for to break up the input.  I'm
> guessing that you want to break up the input whereever whitespace is seen,
> not whenever one of the characters #, E, X, T, I, N, F, : are seen.
> So, try
> 	ft _ fc findTokens: Character separators.

Yes, as I said, it is doing what it claims. I just didn't know if there 
was a way to make it use the string only, instead of the string and the 
characters. Someway of making that string appear as single unit.

It works great on my playlist for the first 50 tokens.
Genesis 1-50. Gives me exactly what I want.

When it hits 'Exodus' the 'E' causes problems and its downhill from there.

ft _ fc substrings.

Does similarly to your code. It gives me array with 13875 substrings.
I'm shooting for a collection with 1189 items.

Thanks for the information.

I keep trying.

Jimmie Houchin



> Hope this helps,
> Joshua
> 
> 
> 
>>I only want the exact string '#EXTINF:' as a token. I do not want it 
>>broken down into characters as tokens.
>>
>>   Is there a way to do such?
>>   I have tried a variety of things including 'asSymbol' unsuccessfully.
[snip]



More information about the Squeak-dev mailing list