// Script function: Build a swap function with call-by-reference

// 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 swap(number &x, number &y)
{
number EMtemp;
EMtemp = x; // save the value at address x
x = y; // put y into x
y = EMtemp; // put x into y
}

number EMi, EMj;
EMi = 10;
EMj = 20;
result ("Original values of EMi and EMj are " + EMi + " and " + EMj + " respectively.\n")
swap(EMj, EMi)
result ("New values of EMi and EMj are " + EMi + " and " + EMj +  " respectively.\n\n")
