// Script function: Locations of global and local variables. 

// Unless named starting with GlobalSino, EM, My, Self, the function commands are defined 
//by Gatan DM, please see at link: http://www.globalsino.com/EM/page2597.html

void EMfunction();
number EMright; // EMright is a global variable

EMright = 0;
EMright = EMright + 1
result ("EMright is " + EMright + " for now\n")
EMfunction()


void EMfunction()
{
number EMcount; // This EMcount is local variable in EMfunction() block and unrelated to the global one. 
number EMa, EMb; // This EMa and EMb are local variables as well. 
EMa = random()
EMb = random()

// The script gets three tries to get "round of EMc is equal to 3".
for(EMcount=0; EMcount<3; EMcount++) 
{
number EMc = EMa + EMb + EMcount
result ("EMc is equal to " + EMc + " when EMcount is " + EMcount + ". \n") ;

number EMround = round (EMc);

result ("Round of EMc is equal to: " + EMround + "\n")
if(EMround==3) 
{
EMright++;
result ("EMright is: " + EMright + " since round of EMc is finally equal to 3. \n\n")
return;
}
}

number EMd = 2*(EMa+EMb)
result ("The answer of EMd is " + EMd + "\n\n\n")

}
