[Newbies] Re: next or break in a loop

2016-05-10 Thread Joseph Alotta
Lou,

I was trying to use the ReadStream, but the issue is to get execution to go 
back to the top.  If I send the upToEnd message, it still executes from the 
same line and goes through the rest of the tests.


Sincerely,

Joe.



> On May 9, 2016, at 3:56 PM, Louis LaBrunda [via Smalltalk] 
>  wrote:
> 
> Hi Joe, 
> 
> You can map your collection to a stream and then use the stream methods to 
> traverse the 
> collection. 
> 
> stream := ReadStream on: myCollection. 
> [stream atEnd] whileFalse: [:item | 
> item := stream next. 
> "I'm not sure upToEnd is the right method here but it is close.  Look around, 
> I'm sure you will 
> find what you need." 
> item doSomeWork. 
> (when you think you are done with item) ifTrue: [stream 
> upToEnd]. 
> ]. 
> 
> Lou 
> 
> On Mon, 9 May 2016 16:00:58 -0500, Joseph Alotta <[hidden email]> wrote: 
> 
> >I don’t think any of the solutions work for my case. 
> > 
> >I want to evaluate several different variable for each step, make 
> >calculations and if all of the conditions are met, then skip to the next 
> >item, otherwise, do the next step of calculations. 
> > 
> >The project is reading comma deliminated bank or credit card files, taking a 
> >column of data, counting various characters, and trying to determine what 
> >kind of data it is.  For example, a column of data with two slash characters 
> >and eight digits per line is likely to be a date field.  A column of data 
> >with more than 3 letter characters and a percentage of digits and a 
> >percentage of hash signs is likely to be a payee field.  A column of data 
> >with no spaces, no digits, no special characters is likely to be a type of 
> >transaction field.  A column of data with one period per item, and only 
> >digits or a minus sign is  likely to be a amount field, and a column of data 
> >with a high percentage of zero length items and the rest having C or K and a 
> >pound sign and four or more digits is likely to be a check number field. 
> > 
> >I am doing a lot of tests for each field and I don’t think the switch is a 
> >good fit. 
> > 
> >Sincerely, 
> > 
> >Joe.
> -- 
> Louis LaBrunda 
> Keystone Software Corp. 
> SkypeMe callto://PhotonDemon 
> 
> ___ 
> Beginners mailing list 
> [hidden email] 
> http://lists.squeakfoundation.org/mailman/listinfo/beginners
> 
> 
> If you reply to this email, your message will be added to the discussion 
> below:
> http://forum.world.st/next-or-break-in-a-loop-tp4894095p4894128.html
> To start a new topic under Squeak - Beginners, email 
> ml-node+s1294792n107673...@n4.nabble.com 
> To unsubscribe from Squeak - Beginners, click here.
> NAML





--
View this message in context: 
http://forum.world.st/next-or-break-in-a-loop-tp4894095p4894218.html
Sent from the Squeak - Beginners mailing list archive at Nabble.com.___
Beginners mailing list
Beginners@lists.squeakfoundation.org
http://lists.squeakfoundation.org/mailman/listinfo/beginners


[Newbies] next or break in a loop

2016-05-10 Thread Louis LaBrunda
Joe,

At each test for the type of data you can also test to see if you found type, 
something like
this:

stream := ReadStream on: myCollection.
[stream atEnd] whileFalse: [:item | | notFound |
item := stream next.
notFound := true.
(notFound and: [your column test1]) ifTrue: [notFound := false. 
stream upToEnd].
(notFound and: [your column test2]) ifTrue: [notFound := false. 
stream upToEnd].
(notFound and: [your column test3]) ifTrue: [notFound := false. 
stream upToEnd].
].

Not pretty but it should work.  You should also look into the #caseOf: method 
Bert suggested. I
have my own Case class in VA Smalltalk that I expect is similar but I'm not 
familiar with
#caseOf:, so you should look it up.  I expect it will make the code a little 
cleaner.

Lou

On Tue, 10 May 2016 08:57:03 -0700 (PDT), Joseph Alotta 
 wrote:

>Lou,
>
>I was trying to use the ReadStream, but the issue is to get execution to go 
>back to the top.  If I send the upToEnd message, it still executes from the 
>same line and goes through the rest of the tests.
>
>
>Sincerely,
>
>Joe.
>
>
>
>> On May 9, 2016, at 3:56 PM, Louis LaBrunda [via Smalltalk] 
>>  wrote:
>> 
>> Hi Joe, 
>> 
>> You can map your collection to a stream and then use the stream methods to 
>> traverse the 
>> collection. 
>> 
>> stream := ReadStream on: myCollection. 
>> [stream atEnd] whileFalse: [:item | 
>> item := stream next. 
>> "I'm not sure upToEnd is the right method here but it is close.  Look 
>> around, I'm sure you will 
>> find what you need." 
>> item doSomeWork. 
>> (when you think you are done with item) ifTrue: [stream 
>> upToEnd]. 
>> ]. 
>> 
>> Lou 
>> 
>> On Mon, 9 May 2016 16:00:58 -0500, Joseph Alotta <[hidden email]> wrote: 
>> 
>> >I don?t think any of the solutions work for my case. 
>> > 
>> >I want to evaluate several different variable for each step, make 
>> >calculations and if all of the conditions are met, then skip to the next 
>> >item, otherwise, do the next step of calculations. 
>> > 
>> >The project is reading comma deliminated bank or credit card files, taking 
>> >a column of data, counting various characters, and trying to determine what 
>> >kind of data it is.  For example, a column of data with two slash 
>> >characters and eight digits per line is likely to be a date field.  A 
>> >column of data with more than 3 letter characters and a percentage of 
>> >digits and a percentage of hash signs is likely to be a payee field.  A 
>> >column of data with no spaces, no digits, no special characters is likely 
>> >to be a type of transaction field.  A column of data with one period per 
>> >item, and only digits or a minus sign is  likely to be a amount field, and 
>> >a column of data with a high percentage of zero length items and the rest 
>> >having C or K and a pound sign and four or more digits is likely to be a 
>> >check number field. 
>> > 
>> >I am doing a lot of tests for each field and I don?t think the switch is a 
>> >good fit. 
>> > 
>> >Sincerely, 
>> > 
>> >Joe.
>> -- 
>> Louis LaBrunda 
>> Keystone Software Corp. 
>> SkypeMe callto://PhotonDemon 
>> 
>> ___ 
>> Beginners mailing list 
>> [hidden email] 
>> http://lists.squeakfoundation.org/mailman/listinfo/beginners
>> 
>> 
>> If you reply to this email, your message will be added to the discussion 
>> below:
>> http://forum.world.st/next-or-break-in-a-loop-tp4894095p4894128.html
>> To start a new topic under Squeak - Beginners, email 
>> ml-node+s1294792n107673...@n4.nabble.com 
>> To unsubscribe from Squeak - Beginners, click here.
>> NAML
-- 
Louis LaBrunda
Keystone Software Corp.
SkypeMe callto://PhotonDemon

___
Beginners mailing list
Beginners@lists.squeakfoundation.org
http://lists.squeakfoundation.org/mailman/listinfo/beginners


[Newbies] new and initialize

2016-05-10 Thread Joseph Alotta
Greetings,

I have an instance method called ‘initialize’ that defines instance variables.  

I want it to run whenever a new instance is created.  How do I accomplish that?

I tried to add a class method ‘new’  that contained ^(super new) initialize.  
But it warned me about adding the message saying it would have serious effects.

So where do I put it?

Sincerely,

Joe.



___
Beginners mailing list
Beginners@lists.squeakfoundation.org
http://lists.squeakfoundation.org/mailman/listinfo/beginners


RE: [Newbies] new and initialize

2016-05-10 Thread Ron Teitelbaum
Hi Joe,

Excellent question.  Try this.  

Object new. 

Highlight it and do debug it.   Click "Into" to go into the #new method.

Notice the implementation of #new.  

You should be able to see there that #initialize is called automatically.
 
Also for extra points notice what class new is implemented on.  What method 
should you call to skip initialize?

All the best,

Ron Teitelbaum



> -Original Message-
> From: beginners-boun...@lists.squeakfoundation.org [mailto:beginners-
> boun...@lists.squeakfoundation.org] On Behalf Of Joseph Alotta
> Sent: Tuesday, May 10, 2016 2:07 PM
> To: beginners@lists.squeakfoundation.org
> Subject: [Newbies] new and initialize
> 
> Greetings,
> 
> I have an instance method called ‘initialize’ that defines instance variables.
> 
> I want it to run whenever a new instance is created.  How do I accomplish
> that?
> 
> I tried to add a class method ‘new’  that contained ^(super new) initialize.
> But it warned me about adding the message saying it would have serious
> effects.
> 
> So where do I put it?
> 
> Sincerely,
> 
> Joe.
> 
> 
> 
> ___
> Beginners mailing list
> Beginners@lists.squeakfoundation.org
> http://lists.squeakfoundation.org/mailman/listinfo/beginners

___
Beginners mailing list
Beginners@lists.squeakfoundation.org
http://lists.squeakfoundation.org/mailman/listinfo/beginners


[Newbies] Re: new and initialize

2016-05-10 Thread Joseph Alotta

> On May 10, 2016, at 12:45 PM, Ron Teitelbaum [via Smalltalk] 
>  wrote:
> 
> Hi Joe, 
> 
> Excellent question.  Try this.   
> 
> Object new. 
> 
> Highlight it and do debug it.   Click "Into" to go into the #new method. 
> 
> Notice the implementation of #new.   
> 
> You should be able to see there that #initialize is called automatically. 
>   
> Also for extra points notice what class new is implemented on.

Behavior

>  What method should you call to skip initialize? 

basicNew

More questions:  why isn’t there a command key for debug it?
 why isn’t my initialize method not running or running without 
setting variables?


Thank you.

Sincerely,

Joe.






--
View this message in context: 
http://forum.world.st/new-and-initialize-tp4894227p4894237.html
Sent from the Squeak - Beginners mailing list archive at Nabble.com.___
Beginners mailing list
Beginners@lists.squeakfoundation.org
http://lists.squeakfoundation.org/mailman/listinfo/beginners


[Newbies] Re: next or break in a loop

2016-05-10 Thread Joseph Alotta

> On May 10, 2016, at 12:03 PM, Louis LaBrunda [via Smalltalk] 
>  wrote:
> 
> Joe, 
> 
> At each test for the type of data you can also test to see if you found type, 
> something like 
> this: 
> 
> stream := ReadStream on: myCollection. 
> [stream atEnd] whileFalse: [:item | | notFound | 
> item := stream next. 
> notFound := true. 
>   (notFound and: [your column test1]) ifTrue: [notFound := false. 
> stream upToEnd]. 
> (notFound and: [your column test2]) ifTrue: [notFound := 
> false. stream upToEnd]. 
> (notFound and: [your column test3]) ifTrue: [notFound := 
> false. stream upToEnd]. 
> ]. 
> 
> Not pretty but it should work. 

I added a flag and set it as one of the conditions.

Also, to make reading simpler, I stacked all the booleans.

bool := bool and: (condition).
bool := bool and: (another condition).

It is not pretty, but it avoids endless seas of parentheses.

Sincerely,

Joe.






--
View this message in context: 
http://forum.world.st/next-or-break-in-a-loop-tp4894095p4894238.html
Sent from the Squeak - Beginners mailing list archive at Nabble.com.___
Beginners mailing list
Beginners@lists.squeakfoundation.org
http://lists.squeakfoundation.org/mailman/listinfo/beginners


Re: [Newbies] Re: new and initialize

2016-05-10 Thread Ben Coman
On Wed, May 11, 2016 at 3:37 AM, Joseph Alotta  wrote:
>
>> On May 10, 2016, at 12:45 PM, Ron Teitelbaum [via Smalltalk] <[hidden
>> email]> wrote:
>>
>> Hi Joe,
>>
>> Excellent question.  Try this.
>>
>> Object new.
>>
>> Highlight it and do debug it.   Click "Into" to go into the #new method.
>>
>> Notice the implementation of #new.
>>
>> You should be able to see there that #initialize is called automatically.
>>
>> Also for extra points notice what class new is implemented on.
>
> Behavior
>
>>  What method should you call to skip initialize?
>
> basicNew
>
> More questions:
>  why isn’t my initialize method not running or running
> without setting variables?

Is your initialize method on the class-side or the instance-side ?
At the very very start of using Squeak this would catch me up.  It
soon became instinctive to notice which side I was working on.

cheers -ben
___
Beginners mailing list
Beginners@lists.squeakfoundation.org
http://lists.squeakfoundation.org/mailman/listinfo/beginners


RE: [Newbies] Re: new and initialize

2016-05-10 Thread Ron Teitelbaum
 

 

From: Joseph Alotta
Sent: Tuesday, May 10, 2016 3:38 PM



 


> On May 10, 2016, at 12:45 PM, Ron Teitelbaum [via Smalltalk] <[hidden email]> 
> wrote: 
> 
> Hi Joe, 
> 
> Excellent question.  Try this.   
> 
> Object new. 
> 
> Highlight it and do debug it.   Click "Into" to go into the #new method. 
> 
> Notice the implementation of #new.   
> 
> You should be able to see there that #initialize is called automatically. 
>   
> Also for extra points notice what class new is implemented on. 


Behavior 

[Ron Teitelbaum] Exactly!  



>  What method should you call to skip initialize? 

basicNew 

[Ron Teitelbaum] Excellent!



More questions:  why isn’t there a command key for debug it? 

[Ron Teitelbaum] No clue.  


 why isn’t my initialize method not running or running without 
setting variables? 

[Ron Teitelbaum] put a halt in your method and run it.  See if the initialize 
is being called at all.  If it is then check the content of your method for 
errors.  If not then your initialize method is spelled wrong, is not on the 
instance side, or there is a new method implemented in your class or a 
superclass that is bypassing the default implementation of #new which is a bad 
thing.  The system gives you a warning to let you know that!! J

All the best,

Ron




Thank you. 

Sincerely, 

Joe. 




  _  

View this message in context: Re: new and initialize 
 
Sent from the Squeak - Beginners mailing list archive 
  at Nabble.com.

___
Beginners mailing list
Beginners@lists.squeakfoundation.org
http://lists.squeakfoundation.org/mailman/listinfo/beginners