Hi all.
-- Need advice from smalltalk experts. Have classes as in the picture. IPStools holds instance variable csa, csa holds instance variable sm. As you can see at some time csa needs to execute a method defined in IPStools (red arrow). At some time sm also will need to access methods of IPStools and vice versa. What is the proper algorithm to achieve this? How do you usually do in such a situation? Regards Sergei. You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To post to this group, send email to [hidden email]. Visit this group at https://groups.google.com/group/va-smalltalk. For more options, visit https://groups.google.com/d/optout. Captured001.png (37K) Download Attachment |
Hi Sergei,
-- You can do almost anything in Smalltalk and you can probably do this if you use enough class methods. But if you are having this much trouble, I suggest you re-think your design. Do the simplest thing that could possibly work. Donald [|] You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To post to this group, send email to [hidden email]. Visit this group at https://groups.google.com/group/va-smalltalk. For more options, visit https://groups.google.com/d/optout. |
Hi Donalds.
-- Thank you for your reply. четверг, 1 июня 2017 г., 18:46:21 UTC+3 пользователь Donald MacQueen написал:
Yes, that`s it. I see several workarounds for implementing this kind of trouble - some seem to me very complex, some - affordable. I temporary made the following: right after creating object ''sm" in "IPStools" i call specially created "reference:" with self (IPStools) as argument in 'sm'' and assign "self" to a new variable "refIPSTools". After that I have direct access to all methods of "IPStools". But in fact only further development will show whether this mechanism will stay on or will be replaced.
I have already made one redesign of this application from the scratch - helpfully it was in the most beginning - and I don`t with to do it again :-)) I`ll do my best to fulfill this project as it is very interesting to me. Donald [|] You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To post to this group, send email to [hidden email]. Visit this group at https://groups.google.com/group/va-smalltalk. For more options, visit https://groups.google.com/d/optout. |
In reply to this post by ipstools.project
Got stuck with this. The working code is very complex and unreadable.
-- Can someone show me on a simple and working example how to achieve: Class A has B, B has C as variable. Class C needs to alert both A and B of some event. The only I found suitable is to try #signalEvent method. Can i use #signalEvent? Will it work for messages between non-visual parts? Guess no (got error). I'm grieving... ((( Sergei понедельник, 29 мая 2017 г., 18:08:27 UTC+3 пользователь [hidden email] написал:
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To post to this group, send email to [hidden email]. Visit this group at https://groups.google.com/group/va-smalltalk. For more options, visit https://groups.google.com/d/optout. |
Hi Sergei,
-- I'm not sure exactly what you are trying to do but maybe this will help. Check out #abtWhenPrimitive:perform: and #abtWhen:perform:. The first parameter is a symbol naming your event and the second is a DirectedMessage. You will have to check out DirectedMessage to see what you need to set to meet your needs. Basically it is the object and method you want to catch the event and some info about parameters. Once this is setup you can #signalEvent: with parms if need be. The object and its method specified in the DirectedMessage will get the event and do what you want. This or something similar is used a lot with GUI widgets but it does work with any object. So, if you look at the GUI stuff it should help you understand how it works. Lou On Sunday, October 8, 2017 at 3:18:10 PM UTC-4, [hidden email] wrote:
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To post to this group, send email to [hidden email]. Visit this group at https://groups.google.com/group/va-smalltalk. For more options, visit https://groups.google.com/d/optout. |
Hi Louis, thank you for your answer.
-- I`ll try to make the most of English to explain what I do want. Just started to learn Smalltalk as my first Programming language, just for fun. To learn it best I`m developing a practical application in the area of my position, i. e. telecom. As I am in the beginning status of application development, and know simply nothing yet, my code in Smalltalk is by fact very unstructured, and the consequence of this is the fact that classes in the app are in relations "all to all". (sorry, don`t know how this express in English) As a result of this I want again to re-code the app and looking for short examples of correct classes interaction. #signalEvent is by my point of view one of correct ways of organizing of messages between the classes. Unfortunately documentation doesn`t show how to use it in Smalltalk with non-visual parts. Returning to the solution you suggested, my test code is as follows and doesn`t work as expected (by me). There might be an error somewhere. For class A: AbtAppBldrPart subclass: #A classInstanceVariableNames: '' instanceVariableNames: 'classB ' classVariableNames: '' poolDictionaries: '' initialize classB := B new. subscribe self abtWhenPrimitive: #digitChanged perform: (DirectedMessage new receiver: self; selector: #notify; arguments: #()). classB ^classB notify Transcript show: 'Class A: notifying...'; cr. For class B: AbtAppBldrPart subclass: #B classInstanceVariableNames: '' instanceVariableNames: 'digit ' classVariableNames: '' poolDictionaries: '' initialize digit := 0. increment digit := digit + 1. self signalEvent: #digitChanged. Transcript show: 'Class B: digit incremented to ', digit asString, '.'; cr. Transcript show: 'Alerting digit change.'; cr. And finally the code for Transcript: | a b | a := A new subscribe. a classB increment; increment; increment. What I need: Class A to be aware of every change of digit variable. The code complies successfully but there is no expected message by the #notify method. So where I am wrong in the code? This code reflects how I understood your advise. Sergei. понедельник, 9 октября 2017 г., 17:33:51 UTC+3 пользователь Louis LaBrunda написал:
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To post to this group, send email to [hidden email]. Visit this group at https://groups.google.com/group/va-smalltalk. For more options, visit https://groups.google.com/d/optout. |
Hi Sergei,
-- You are very close. The #digitChanged event is something that happens to class B but you have declared it as an event for class A: subscribe self abtWhenPrimitive: #digitChanged perform: (DirectedMessage new receiver: self; selector: #notify; arguments: #()). this should work: subscribe classB abtWhenPrimitive: #digitChanged perform: (DirectedMessage new receiver: self; selector: #notify; arguments: #()). I'm not sure why you are sub-classing #AbtAppBldrPart? There is nothing wrong with that but if you don't need any of what #AbtAppBldrPart does you can sub-class a simpler class. If you tell me a little more about what you are doing, maybe I can make some more suggestions. Lou On Monday, October 9, 2017 at 12:12:18 PM UTC-4, [hidden email] wrote:
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To post to this group, send email to [hidden email]. Visit this group at https://groups.google.com/group/va-smalltalk. For more options, visit https://groups.google.com/d/optout. |
Hi Lui
-- понедельник, 9 октября 2017 г., 21:17:21 UTC+3 пользователь Louis LaBrunda написал:
This worked, great. Thank you again.
Don`t pay attention on that, for this example it is not important. It`s just a default value VA Organizer suggests.
Sergei
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To post to this group, send email to [hidden email]. Visit this group at https://groups.google.com/group/va-smalltalk. For more options, visit https://groups.google.com/d/optout. |
In reply to this post by ipstools.project
Hi all! Once again need your help (let`s this thread will be for newbie questions)
Have the code: shell := CwTopLevelShell createApplicationShell: 'shell' argBlock: [:w | w width: 400; height: 600]. form := shell createForm: 'form' argBlock: nil. form manageChild. text := form createScrolledText: 'text' argBlock: [:w | w editMode: XmMULTILINEEDIT; "scrollHorizontal: false;" wordWrap: true. w parent leftAttachment: XmATTACHFORM. w parent bottomAttachment: XmATTACHFORM. w parent topAttachment: XmATTACHFORM. w parent rightAttachment: XmATTACHFORM. ]. text setString: 'Edit me 1!'. text manageChild. text2 := form createScrolledText: 'text' argBlock: [:w | w editMode: XmMULTILINEEDIT; "scrollHorizontal: false;" wordWrap: true. w parent leftAttachment: XmATTACHFORM. w parent bottomAttachment: XmATTACHFORM. w parent topAttachment: XmATTACHFORM. w parent rightAttachment: XmATTACHFORM. ]. text2 setString: 'Edit me 2!'. "text2 manageChild." shell realizeWidget. when resizing the window the text sub-window may disappear and that`s what i don`t want to happen. Why I need this? Need to have two views which will be toggled by ESC-key. One will be visible, the other hidden. And vice versa. I try to emulate this bit it doesn`t work as expected. -- You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To post to this group, send email to [hidden email]. Visit this group at https://groups.google.com/group/va-smalltalk. For more options, visit https://groups.google.com/d/optout. |
OK, found a workaround.
-- I change the sizes of each view: one occupies the hole window and the other have zero width; and vice versa. Sergei. вторник, 17 октября 2017 г., 20:39:03 UTC+3 пользователь [hidden email] написал: Hi all! Once again need your help (let`s this thread will be for newbie questions) You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To post to this group, send email to [hidden email]. Visit this group at https://groups.google.com/group/va-smalltalk. For more options, visit https://groups.google.com/d/optout. |
Free forum by Nabble | Edit this page |