passing variables in action

18 views
Skip to first unread message

Srirama Bhamidipati

unread,
Aug 6, 2014, 10:04:51 AM8/6/14
to gama-p...@googlegroups.com
Hi,

I am having a little trouble in using action and passing variable (arguments) from a do statement to a action block. I tried from https://code.google.com/p/gama-platform/wiki/G__Statements#do , but not much success, Could you please point me to some examples where do is sending some arguments and may be also receiving them. it was a little difficult to find them with search function (ctrl+H) in the GUI.

 Will be very helpful. 

thanks.
Srirama

Patrick Taillandier

unread,
Aug 6, 2014, 10:09:36 AM8/6/14
to gama-p...@googlegroups.com
You have many examples in the "Syntax/Syntax (1.6)" model

//Compact

list<int> dummy1 (int a <- 100, float b) {

return [a, int(b)];

}


// The classic way

do action: dummy1 with: [a::10, b::100];


// Another classic way using facets

do action: dummy1 a: 10 b: 100;


// Another by removing the first facet

do dummy1 a: 10 b: 100;


// The new alternative one 

do dummy1(a: 10, b: 100);


Cheers,

Patrick


--
You received this message because you are subscribed to the Google Groups "GAMA" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gama-platfor...@googlegroups.com.
To post to this group, send email to gama-p...@googlegroups.com.
Visit this group at http://groups.google.com/group/gama-platform.
For more options, visit https://groups.google.com/d/optout.

Alexis Drogoul

unread,
Aug 6, 2014, 10:10:51 AM8/6/14
to gama-p...@googlegroups.com
Hi Srirama,

Better explain what you intend to do. Otherwise the passing of arguments to actions is pretty straightforward in GAML.

If you declare in a species S the following action:

action A(int one, float two) {…}

then you can use this action somewhere else, for instance:

ask one_of(S) {
do A(1, 1.0);
}

Is it what you were looking for ?

Cheers
Alexis
> --
> You received this message because you are subscribed to the Google Groups "GAMA" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to gama-platfor...@googlegroups.com.
> To post to this group, send email to gama-p...@googlegroups.com.
> Visit this group at http://groups.google.com/group/gama-platform.
> For more options, visit https://groups.google.com/d/optout.

--
Senior Researcher, UMI UMMISCO 209, IRD & UPMC, France.
Invited Researcher, DREAM, Can Tho University, Viet Nam.
--
alexis....@gmail.com | http://tiny.cc/liqemw
[Vietnam] +84915088155 [France] +33608698845
--
GAMA: https://code.google.com/p/gama-platform/

Srirama Bhamidipati

unread,
Aug 6, 2014, 10:16:32 AM8/6/14
to gama-p...@googlegroups.com
Thank you Patrick, Alexis. I am just learning the syntax. So far I have been building more of a sequential models, step by step, line by line execution, storing temporary variables and making global variables, now I am learning to use functions( actions) to pass some variables. So I did not have any example i am working on, so i could not quote what I am working on.

I will study your examples.

thanks
Srirama
Reply all
Reply to author
Forward
0 new messages