Perform

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Perform

Jakub-8
hello i have class with two setters
phone1: aValue
phone2: aValue

and i want call it dynamically
aSelector is phone1 or phone2 string

setPhohne: aSelector by: aValue

phoneBook perform aSelector, ':' aValue

but this is not working how can i do this when i try this iwth getters it works fine

Transcript show: (phoneBook perform aSelector); cr.


--
Jakub.
_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Perform

Mathieu SUEN
Hi Jakub,

#perform: is for unary message

If you want to pass arguments you have to use
#perform:with:    "On argument"
#perform:with:with: "Two arguments"
..
#perform:withArguments:  "Several arguments inside an Array"

so in your case it should be:

phonebook perform: #phone1 with: aValue

HTH

On Jan 14, 2008, at 2:58 PM, Jakub wrote:

> hello i have class with two setters
> phone1: aValue
> phone2: aValue
>
> and i want call it dynamically
> aSelector is phone1 or phone2 string
>
> setPhohne: aSelector by: aValue
>
> phoneBook perform aSelector, ':' aValue
>
> but this is not working how can i do this when i try this iwth  
> getters it works fine
>
> Transcript show: (phoneBook perform aSelector); cr.
>
>
> --
> Jakub. _______________________________________________
> Beginners mailing list
> [hidden email]
> http://lists.squeakfoundation.org/mailman/listinfo/beginners

        Mth



_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Perform

Frank Urbach
In reply to this post by Jakub-8
Hi Jakub,
 
if I correctly understand your question the following will do what you want:
 
test := MyTest new.
 
myString:= ('phone1' , ':' asString) asSymbol.
 
test perform: myString with: 'tesValue'.
 
The above you can use in a Workspace.
 
The essential from this is: Object perform: with: 
 
MyTest contains:
 
MyTest>>phone1: aValue
  phone1 := aValue.
 
MyTest>>phone2: aValue
  phone2 := aValue.
 
HTH
 
  Frank
 
 
>hello i have class with two setters

>phone1: aValue
>phone2: aValue
>
>and i want call it dynamically
>aSelector is phone1 or phone2 string
>
>setPhohne: aSelector by: aValue
>
>phoneBook perform aSelector, ':' aValue
>
>but this is not working how can i do this when i try this iwth getters it works fine
>
>Transcript show: (phoneBook perform aSelector); cr.
 
 
Edelstahlwerke Schmees GmbH 

Geschäftsleitung Clemens Schmees

Sitz D-01796 Pirna

Handelsregister Dresden HRB 54

E-Mail: [hidden email]

WEB:     www.schmees.com

 

Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und vernichten Sie diese Mail. Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail ist nicht gestattet.

 

This e-mail may contain confidental and/or privileged information. If you are not intended recipient or have received this e-mail in error, please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is stictly forbidden.

_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Perform

Zulq Alam-2
In reply to this post by Mathieu SUEN
And, instead of concatenating your selector with ':', you can send a
symbol the message #asMutator (which does it for you).

For example:

#phone1 asMutator "prints #phone1:"
#phone2 asMutator "prints #phone2:"

Which you can use like this:

phoneBook perform: aSelector asMutator with: aValue

Regards,
Zulq.


Mathieu Suen wrote:

> Hi Jakub,
>
> #perform: is for unary message
>
> If you want to pass arguments you have to use
> #perform:with:    "On argument"
> #perform:with:with: "Two arguments"
> ...
> #perform:withArguments:  "Several arguments inside an Array"
>
> so in your case it should be:
>
> phonebook perform: #phone1 with: aValue
>
> HTH
>
> On Jan 14, 2008, at 2:58 PM, Jakub wrote:
>
>> hello i have class with two setters
>> phone1: aValue
>> phone2: aValue
>>
>> and i want call it dynamically
>> aSelector is phone1 or phone2 string
>>
>> setPhohne: aSelector by: aValue
>>
>> phoneBook perform aSelector, ':' aValue
>>
>> but this is not working how can i do this when i try this iwth getters
>> it works fine
>>
>> Transcript show: (phoneBook perform aSelector); cr.
>>
>>
>> --
>> Jakub. _______________________________________________
>> Beginners mailing list
>> [hidden email]
>> http://lists.squeakfoundation.org/mailman/listinfo/beginners
>
>     Mth

_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners