<div dir="ltr">Yes, except #whileFalse: only works against blocks. So:<div><span style="font-size:12.8px"> [f atEnd] whileFalse: [ </span><br style="font-size:12.8px"></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Apr 25, 2016 at 9:59 AM, Joseph Alotta <span dir="ltr"><<a href="mailto:joseph.alotta@gmail.com" target="_blank">joseph.alotta@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">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><span class=""><br>> On Apr 25, 2016, at 10:06 AM, Louis LaBrunda [via Smalltalk] <<a href="http:///user/SendEmail.jtp?type=node&node=4891963&i=0" rel="nofollow" link="external" target="_blank">[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></span><div><div class="h5">> 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 <a href="callto://PhotonDemon" target="_blank">callto://PhotonDemon</a>
<br>>
<br>> _______________________________________________
<br>> Beginners mailing list
<br></div></div>> [hidden email]
<br>> <a href="http://lists.squeakfoundation.org/mailman/listinfo/beginners" rel="nofollow" link="external" target="_blank">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" rel="nofollow" link="external" target="_blank">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="http:///user/SendEmail.jtp?type=node&node=4891963&i=1" rel="nofollow" link="external" target="_blank">[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" target="_blank">Re: go to the end of a loop</a><br>
Sent from the <a href="http://forum.world.st/Squeak-Beginners-f107673.html" target="_blank">Squeak - Beginners mailing list archive</a> at Nabble.com.<br><br>_______________________________________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@lists.squeakfoundation.org">Beginners@lists.squeakfoundation.org</a><br>
<a href="http://lists.squeakfoundation.org/mailman/listinfo/beginners" rel="noreferrer" target="_blank">http://lists.squeakfoundation.org/mailman/listinfo/beginners</a><br>
<br></blockquote></div><br></div>