Hi!! I hope you can help me. I want to do this:
http://www.compubitweb.com/vwsmalltalk/searchwindow.png A search Customer window that you can search by name or id. This is the message of the button: searchForButton | resBusqueda | resBusqueda := searchForInput value = '' ifTrue: [listCustomers] ifFalse: [listCustomers select: [:cli | ((cli perform: searchForInput value) findString: searchForInput value startingAt: 1) isZero not]]. listCustomers list: resBusqueda. Searching by name it works perfect, but if you search by id it fails. The message is that is not the same type, because the input is an string, and the id is an integer. How do I solve this?? Thanks a lot JP Cook _______________________________________________ vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc |
Hi Juan,
you probably need to convert the number to a string first. #asString can do that and is probably also understood by the string :-) Kind Regards Karsten Juan Pablo Cook wrote: > Hi!! I hope you can help me. I want to do this: > http://www.compubitweb.com/vwsmalltalk/searchwindow.png > > A search Customer window that you can search by name or id. > > This is the message of the button: > > searchForButton > > | resBusqueda | > > resBusqueda := searchForInput value = '' > ifTrue: [listCustomers] > ifFalse: [listCustomers > > select: > [:cli | > ((cli perform: searchForInput value) > findString: searchForInput value > startingAt: 1) isZero not]]. > > listCustomers list: resBusqueda. > > Searching by name it works perfect, but if you search by id it fails. > The message is that is not the same type, because the input is an > string, and the id is an integer. How do I solve this?? > > Thanks a lot > > JP Cook > _______________________________________________ > vwnc mailing list > [hidden email] > http://lists.cs.uiuc.edu/mailman/listinfo/vwnc > > > -- Karsten Kusche - Dipl.Inf. - [hidden email] Tel: +49 3496 21 43 29 Georg Heeg eK - Köthen Handelsregister: Amtsgericht Dortmund A 12812 _______________________________________________ vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc |
Thanks for your help. But, I don't know what to put that asString message.
I tried this but don't work: searchForButton | resBusqueda | resBusqueda := searchForInput value = '' ifTrue: [listCustomers] ifFalse: [listCustomers select: [:cli | ((cli perform: searchForInput value) findString: ((searchForInput value) asString) startingAt: 1) isZero not]]. listCustomers list: resBusqueda. I don't know how to tell the message, that when is an integer it has to be converted to a String. Thanks again... On Thu, Jan 22, 2009 at 3:46 PM, Karsten <[hidden email]> wrote: > Hi Juan, > > you probably need to convert the number to a string first. #asString can do > that and is probably also uniderstood by the string :-) > > Kind Regards > Karsten > > > > Juan Pablo Cook wrote: >> >> Hi!! I hope you can help me. I want to do this: >> http://www.compubitweb.com/vwsmalltalk/searchwindow.png >> >> A search Customer window that you can search by name or id. >> >> This is the message of the button: >> >> searchForButton >> >> | resBusqueda | >> >> resBusqueda := searchForInput value = '' >> ifTrue: [listCustomers] >> ifFalse: [listCustomers >> >> select: >> [:cli | >> ((cli perform: searchForInput value) >> findString: searchForInput value >> startingAt: 1) isZero not]]. >> >> listCustomers list: resBusqueda. >> >> Searching by name it works perfect, but if you search by id it fails. >> The message is that is not the same type, because the input is an >> string, and the id is an integer. How do I solve this?? >> >> Thanks a lot >> >> JP Cook >> _______________________________________________ >> vwnc mailing list >> [hidden email] >> http://lists.cs.uiuc.edu/mailman/listinfo/vwnc >> >> >> > > -- > Karsten Kusche - Dipl.Inf. - [hidden email] > Tel: +49 3496 21 43 29 > Georg Heeg eK - Köthen > Handelsregister: Amtsgericht Dortmund A 12812 > > _______________________________________________ vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc |
In reply to this post by Karsten Kusche
Unless you are a friend of slow operations (due converting thousands? of
customer ids to strings), you might choose this alternative: Convert your ID input to a number, then select the customer with the ID (which is - as Juan wrote - a number value in the customer model). Of course, you cannot use #findString:startingAt:. You must compare the id inst.var. value with the number. This way of searching is recommended when searching within a database. It depends on what you want: If you want to enter a digit and want the system to pick all customers where the first digit of the id matches the entered digit, then Karsten's proposal is easy to implement. Note: Karsten made one tiny mistake. In a plain vanilla image, #asString is not implemented for Number. Use #printString instead. Even if your interface should select like this, you can still use the number-based retrieval. If your IDs all have the same length, let's say 5 digits, you can speed up by selecting "id between: 10000 and: 19999". Cheers Holger Guhl Karsten schrieb: > Hi Juan, > > you probably need to convert the number to a string first. #asString can > do that and is probably also understood by the string :-) > > Kind Regards > Karsten > > > > Juan Pablo Cook wrote: > >> Hi!! I hope you can help me. I want to do this: >> http://www.compubitweb.com/vwsmalltalk/searchwindow.png >> >> A search Customer window that you can search by name or id. >> >> This is the message of the button: >> >> searchForButton >> >> | resBusqueda | >> >> resBusqueda := searchForInput value = '' >> ifTrue: [listCustomers] >> ifFalse: [listCustomers >> >> select: >> [:cli | >> ((cli perform: searchForInput value) >> findString: searchForInput value >> startingAt: 1) isZero not]]. >> >> listCustomers list: resBusqueda. >> >> Searching by name it works perfect, but if you search by id it fails. >> The message is that is not the same type, because the input is an >> string, and the id is an integer. How do I solve this?? >> >> Thanks a lot >> >> JP Cook >> _______________________________________________ >> vwnc mailing list >> [hidden email] >> http://lists.cs.uiuc.edu/mailman/listinfo/vwnc >> vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc |
In reply to this post by Juan Pablo Cook
On Jan 22, 2009, at 6:27 PM, Juan Pablo Cook wrote: > searchForButton > > | resBusqueda | > > resBusqueda := searchForInput value = '' > ifTrue: [listCustomers] > ifFalse: [listCustomers > > select: > [:cli | > ((cli perform: searchForInput value) > findString: searchForInput value > startingAt: 1) isZero not]]. > > listCustomers list: resBusqueda. > > Searching by name it works perfect, but if you search by id it fails. > The message is that is not the same type, because the input is an > string, and the id is an integer. How do I solve this?? By trying to be less clever ;-) The way I usually factor such a method would be more like the following: searchButtonPressed searchText := searchTextHolder value. searchType := searchTypeHolder value. searchText isEmpty ifTrue: [^self showAll]. searchType = #id ifTrue: [ ^self showWithIdsMatchingString: searchText]. searchType = #name ifTrue:[ ^self showWithNamesMatching: searchText]. self error: 'software bug: should never reach this point' Starting from such a point the various search variants get specified in separate methods, this reduces the pressure on the programmer to implement all different search variants in the same way as you seem to be ending up with above. Another nice side effect is that the method above no longer needs to know how the lists are maintained. HTH, Reinout ------- _______________________________________________ vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc |
In reply to this post by Holger Guhl
Now it works perfectly with the printString ;)
Thanks a lot. JP Cook On Thu, Jan 22, 2009 at 4:43 PM, Holger Guhl <[hidden email]> wrote: > Unless you are a friend of slow operations (due converting thousands? of > customer ids to strings), you might choose this alternative: Convert your ID > input to a number, then select the customer with the ID (which is - as Juan > wrote - a number value in the customer model). Of course, you cannot use > #findString:startingAt:. You must compare the id inst.var. value with the > number. This way of searching is recommended when searching within a > database. > > It depends on what you want: If you want to enter a digit and want the > system to pick all customers where the first digit of the id matches the > entered digit, then Karsten's proposal is easy to implement. Note: Karsten > made one tiny mistake. In a plain vanilla image, #asString is not > implemented for Number. Use #printString instead. > Even if your interface should select like this, you can still use the > number-based retrieval. If your IDs all have the same length, let's say 5 > digits, you can speed up by selecting "id between: 10000 and: 19999". > Cheers > > Holger Guhl > > > Karsten schrieb: >> >> Hi Juan, >> >> you probably need to convert the number to a string first. #asString can >> do that and is probably also understood by the string :-) >> >> Kind Regards >> Karsten >> >> >> >> Juan Pablo Cook wrote: >> >>> >>> Hi!! I hope you can help me. I want to do this: >>> http://www.compubitweb.com/vwsmalltalk/searchwindow.png >>> >>> A search Customer window that you can search by name or id. >>> >>> This is the message of the button: >>> >>> searchForButton >>> >>> | resBusqueda | >>> >>> resBusqueda := searchForInput value = '' >>> ifTrue: [listCustomers] >>> ifFalse: [listCustomers >>> >>> select: >>> [:cli | >>> ((cli perform: searchForInput value) >>> findString: searchForInput value >>> startingAt: 1) isZero not]]. >>> >>> listCustomers list: resBusqueda. >>> >>> Searching by name it works perfect, but if you search by id it fails. >>> The message is that is not the same type, because the input is an >>> string, and the id is an integer. How do I solve this?? >>> >>> Thanks a lot >>> >>> JP Cook >>> _______________________________________________ >>> vwnc mailing list >>> [hidden email] >>> http://lists.cs.uiuc.edu/mailman/listinfo/vwnc >>> > vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc |
In reply to this post by Reinout Heeck
In our application we have a class that we use to keep all the methods that call out to our C implementations of our compute intensive routines, CPOKTestInterface. It has about 480 methods in it. I would like to clean it up since I know some of the routines are not used anymore. What I'd like to do is duplicate the action of the browser to find all the senders of the individual methods but am not having a whole lot of luck. Here is what I have: mc := MethodCollector new. filter := mc searchClassHierarchy: CPOKTestInterface. result := mc select: filter. res2 := List new. result select:[ :element | ( (element asString findString: ('CPOKT' asString) startingAt:1) > 0) ifTrue:[ "Transcript show:element printString;cr." res2 add: element.]. 1=1.]. res2 inspect. res2 has just the methods that are in CPOKTestInterface, (result has some that aren't that is why I filter them the second time). What I don't know how to do is to search the system for senders of (res2 element selector). Any suggestions? Thanks _______________________________________________ vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc |
Jim,
You only did half the job. What you want to do is find all references to each of the method selectors involved. So, you need something like:
| final | final := Set new. res2 do: [:item | final addAll: (mc referencesTo: item "...")]. "open method list browser on res2"
Alternatively, you can add to final only those that have no references:
res2 do: [:item | (mc referencesTo: item "...") isEmpty ifTrue: [final add: item]]. "open method list browser on final"
Cheers!
Tom Hawker -------------------------- Senior Framework Developer -------------------------- Home +1 (408) 274-4128 Office +1 (408) 576-6591 Mobile +1 (408) 835-3643
-----Original Message-----
In our application we have a class that we use to keep all the methods that call out to our C implementations of our compute intensive routines, CPOKTestInterface. It has about 480 methods in it. I would like to clean it up since I know some of the routines are not used anymore. What I'd like to do is duplicate the action of the browser to find all the senders of the individual methods but am not having a whole lot of luck. Here is what I have:
mc := MethodCollector new.
filter := mc searchClassHierarchy: CPOKTestInterface.
result := mc select: filter.
res2 := List new.
result select:[ :element | ( (element asString findString: ('CPOKT' asString) startingAt:1) > 0) ifTrue:[ "Transcript show:element printString;cr." res2 add: element.]. 1=1.]. res2 inspect.
res2 has just the methods that are in CPOKTestInterface, (result has some that aren't that is why I filter them the second time). What I don't know how to do is to search the system for senders of (res2 element selector).
Any suggestions? Thanks
_______________________________________________ vwnc mailing list http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
_______________________________________________ vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc |
In reply to this post by Jim Harsh
This is what I use:
"To find any string in any method:" [ | mc matchString | mc := MethodCollector new. matchString := '*findThisString*'. mc browseSelect: (mc methodsSelect: [:m| matchString match: (m getSource ifNil: ['']) ignoreCase: false]) ] forkAt: Kernel.Processor userBackgroundPriority Paul Baumann -----Original Message----- From: [hidden email] [mailto:[hidden email]] On Behalf Of Jim Harsh Sent: Monday, March 16, 2009 5:41 PM To: VW NC Subject: [vwnc] (no subject) In our application we have a class that we use to keep all the methods that call out to our C implementations of our compute intensive routines, CPOKTestInterface. It has about 480 methods in it. I would like to clean it up since I know some of the routines are not used anymore. What I'd like to do is duplicate the action of the browser to find all the senders of the individual methods but am not having a whole lot of luck. Here is what I have: mc := MethodCollector new. filter := mc searchClassHierarchy: CPOKTestInterface. result := mc select: filter. res2 := List new. result select:[ :element | ( (element asString findString: ('CPOKT' asString) startingAt:1) > 0) ifTrue:[ "Transcript show:element printString;cr." res2 add: element.]. 1=1.]. res2 inspect. res2 has just the methods that are in CPOKTestInterface, (result has some that aren't that is why I filter them the second time). What I don't know how to do is to search the system for senders of (res2 element selector). Any suggestions? Thanks _______________________________________________ vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc This message may contain confidential information and is intended for specific recipients unless explicitly noted otherwise. If you have reason to believe you are not an intended recipient of this message, please delete it and notify the sender. This message may not represent the opinion of IntercontinentalExchange, Inc. (ICE), its subsidiaries or affiliates, and does not constitute a contract or guarantee. Unencrypted electronic mail is not secure and the recipient of this message is expected to provide safeguards from viruses and pursue alternate means of communication where privacy or a binding message is desired. _______________________________________________ vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc |
In reply to this post by thomas.hawker
Thanks Tom,
Once I modified the line to: res2 do: [:item | (mc select:(mc referencesTo: item "...")) isEmpty ifTrue: It worked fine! Paul, the browseSelect opened dialog for each method which I didn't want, I was just looking for a list. Thanks All, Jim At 04:18 PM 3/16/2009, [hidden email] wrote: Jim, _______________________________________________ vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc |
>
Paul, the browseSelect opened dialog for each method which I didn't want
It never opened more than one window for me nor anyone else here using VW 7.5 (and 7.3.1 before that).
To get a list of methods (instead of a method list window) then use this:
| mc matchString |
matchString := '*replaceWithStringToMatch*'. mc := MethodCollector new. ^(mc methodsSelect: [:m| matchString match: (m getSource ifNil: ['']) ignoreCase: false]) select Paul Baumann
From: [hidden email] [mailto:[hidden email]] On Behalf Of Jim Harsh Sent: Tuesday, March 17, 2009 11:02 AM To: [hidden email]; [hidden email] Subject: Re: [vwnc] (no subject) Once I modified the line to: res2 do: [:item | (mc select:(mc referencesTo: item "...")) isEmpty ifTrue: It worked fine! Paul, the browseSelect opened dialog for each method which I didn't want, I was just looking for a list. Thanks All, Jim At 04:18 PM 3/16/2009, [hidden email] wrote: Jim, This message may contain confidential information and is intended for specific recipients unless explicitly noted otherwise. If you have reason to believe you are not an intended recipient of this message, please delete it and notify the sender. This message may not represent the opinion of IntercontinentalExchange, Inc. (ICE), its subsidiaries or affiliates, and does not constitute a contract or guarantee. Unencrypted electronic mail is not secure and the recipient of this message is expected to provide safeguards from viruses and pursue alternate means of communication where privacy or a binding message is desired. _______________________________________________ vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc |
Free forum by Nabble | Edit this page |