Hi Louis,
<br/><br/>This is not a school project. I was looking for a local tutor but could find none. So this is me doing this instead of working crossword puzzles or sudukos.
<br/><br/>So your advice would be:
<br/><br/>(f atEnd) whileFalse: [
<br/> line := f nextLine
<br/><br/> (line size < 2) ifFalse: [ “process line”].
<br/><br/>].
<br/><br/><br/>Sincerely,
<br/><br/>Joe.
<br/><br/><br/><br/><br/><div class='shrinkable-quote'><br/>> On Apr 25, 2016, at 10:06 AM, Louis LaBrunda [via Smalltalk] <<a href="/user/SendEmail.jtp?type=node&node=4891963&i=0" target="_top" rel="nofollow" link="external">[hidden email]</a>> wrote:
<br/>>
<br/>> Hi Joe,
<br/>>
<br/>> Better than checking for #nextLine answering nil, I think you can send the file stream #atEnd
<br/>> to see if there is any more data. You would then use a #whileFalse: and move the #nextLine
<br/>> call into the second block of the whileFalse:. Then test for empty lines with something like:
<br/>> (line size < 2) ifFalse: [...putting all the code that does the work on a line with data in
<br/>> here...].
<br/>>
<br/>> Lou
<br/>>
<br/>> PS. If this is not a school project, we can be of more help, we just don't like doing
<br/>> students projects for them as they learn more with just a few hints and not real code.
<br/>>
<br/>> On Mon, 25 Apr 2016 10:16:33 -0500, Joseph Alotta <[hidden email]> wrote:
<br/>>
<br/>> >Greetings,
<br/>> >
<br/>> >I have this code:
<br/>> >
<br/>> >******
<br/>> >
<br/>> >read
<br/>> >        "read the category file into the dictionary
<br/>> >        the first item is the category, the rest of the line are payees
<br/>> >        
<br/>> >        office expense|home depot|staples|costco
<br/>> >        groceries|natures best|jewel|trader joes|fresh thyme
<br/>> >        "
<br/>> >
<br/>> >| f line |
<br/>> >f := FileStream oldFileNamed: myfile.
<br/>> >
<br/>> >[(line := f nextLine) notNil] whileTrue: [ | array cat payees |
<br/>> >        
<br/>> >         array := line findTokens: $| escapedBy: Character tab .
<br/>> >
<br/>> >        cat := array first.
<br/>> >        payees := array reject: [ :i | i = cat ]. "rest of the line"
<br/>> >        
<br/>> >        payees do: [ :p | mydict at: (p withBlanksCondensed) put: (cat withBlanksCondensed)].
<br/>> >         ].
<br/>> >
<br/>> >
<br/>> >f close.
<br/>> >
<br/>> >*********
<br/>> >
<br/>> >I am getting some blank lines in the data file. Lines with just a Character cr. I was wondering how to handle that. In other languages, there is a break for the loop, to go to the end. I can do:
<br/>> >
<br/>> >(line size < 2) ifTrue: [ f nextLine.].
<br/>> >
<br/>> >But that would interfere with the notNil idiom at the end of the file. So where do I put this. Is there a common way to jump to the end?
<br/>> >
<br/>> >
<br/>> >Sincerely,
<br/>> >
<br/>> >
<br/>> >Joe.
<br/>> --
<br/>> Louis LaBrunda
<br/>> Keystone Software Corp.
<br/>> SkypeMe callto://PhotonDemon
<br/>>
<br/>> _______________________________________________
<br/>> Beginners mailing list
<br/>> [hidden email]
<br/>> <a href="http://lists.squeakfoundation.org/mailman/listinfo/beginners" target="_top" rel="nofollow" link="external">http://lists.squeakfoundation.org/mailman/listinfo/beginners</a><br/>>
<br/>>
<br/>> If you reply to this email, your message will be added to the discussion below:
<br/>> <a href="http://forum.world.st/go-to-the-end-of-a-loop-tp4891930p4891939.html" target="_top" rel="nofollow" link="external">http://forum.world.st/go-to-the-end-of-a-loop-tp4891930p4891939.html</a><br/>> To start a new topic under Squeak - Beginners, email <a href="/user/SendEmail.jtp?type=node&node=4891963&i=1" target="_top" rel="nofollow" link="external">[hidden email]</a>
<br/>> To unsubscribe from Squeak - Beginners, click here.
<br/>> NAML
</div><br/>
        
        
        
<br/><hr align="left" width="300" />
View this message in context: <a href="http://forum.world.st/go-to-the-end-of-a-loop-tp4891930p4891963.html">Re: go to the end of a loop</a><br/>
Sent from the <a href="http://forum.world.st/Squeak-Beginners-f107673.html">Squeak - Beginners mailing list archive</a> at Nabble.com.<br/>