contents   index   previous   next



Pointer operator * and address operator &

 

No pointers. None. The * symbol never means pointer in ScriptEase, which might cause seasoned C programmers to gasp in disbelief. But the situation turns out not to be such a big deal. The pointer operator is easily replaced. For example, *var can be replaced by var[0].

 

Because it is common in C to use address arithmetic on string, ScriptEase providces the CString object, which provides most of the array and address functionaliity of a C string pointer. The following function displays the string in the variable s. In the first display line shows:

 

abcde

 

The second display line, which uses address arithmetic "s+2" shows:

 

cde

 

function main(argc, argv)

{

   var s = new CString("abcde");

   Screen.writeln(s);

   Screen.writeln(s+2);

}

 

Remember that in functions, all variables, except primitive data types, are passed by reference. ScriptEase adds the address operator & for primitive data types. If you want to pass a primitive data type by reference in a JavaScript function, use the address operator in the parameter list. For example,

 

function SetNumbers(&n1, n2, &n3, &n4)

{

   n1 = n2 = n3 = n4 = 5;

}

 


Case statements