Communication between processes?

Started by cmunoz, December 22, 2013, 01:18:02 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

cmunoz


Probably a noob question, and probably already answered somewhere, but thank you for your patience and help.

I'm finally getting the hang of Bennu and currently porting over a project I had started in flash as2, now that I see how amazing BGD is!


The main thing I'm trying to figure out, and I have had a little trouble finding anything on it in the documentation, is getting information from and sending commands to other processes.


For example, in as2 to read another clip's variables you could use:


my_variable = _root.otherclip.variable


And likewise you could tell another clip what to do with:


with(_root.otherclip){x++;}


Which leads to my next question, is there a way to do some sort of dot notation in BGD? Such as father.otherprocess for example?


So basically what I'm trying to figure out is what the best BennuGD equivalent is to doing this sort of thing. Happy Coding and a Merry Christmas!
-Tof

handsource-dyko

#1
It is possible, but in a slightly different way then you show. You'll have to use local or public variables to do inter-process communication. The "father" and "son" properties are simply predefined local varaibles of processes. All processes have these regardless if you use them or not.


You may have a look at these wiki pages: [size=78%]http://wiki.bennugd.org/index.php?title=Process[/size], [size=78%]http://wiki.bennugd.org/index.php?title=ProcessID[/size] and [size=78%]http://wiki.bennugd.org/index.php?title=ProcessType[/size].


Public variables ofter require foreward declaration and you must create your own type use them. (The process itself becomes the data type).


Bear in mind that I don't know anything about flash, it looks like an OOP langauage, wich Bennu is not.

cmunoz


Hello Handsource-Dyko,Thank you for clarifying and the links. It sounds like my best bet then would be to use a global variable that both processes can share.
Thanks again!
-Tof

panreyes

Hi cmunoz!


Your surname looks like Spanish. If you kno[size=78%]w the Cervante's language, you may easily be answered by the bigger spanish community in this forum.[/size]


Don't use globals if you don't need to. Here's an example of Local use, which requires no previous declaring.



Program example;


import "mod_say";
import "mod_key";


Global
Local
gravity;
Private
process_id;
Begin
process_id=man(); //you may use "son" too, but... whatever :)
while(!key(_esc))
  if(exists(process_id)) //remember to check always if the process still exists before accessing a local!
   say(process_id.gravity);
  end
  frame;
end
exit();
End


Process man();
Begin
loop
  gravity=rand(1,10);
  frame;
end
End

NomYenSiChomPoo


Very good post Read I'm not easy to understand it.
Actually the matter very much. There are benefits to living it.