Hello all,
I am trying to pass an integer by reference, but I can't get it
right. Could any one help me on this?
What I tried works fine for arrays, but not for integers only. Code
is below.
Thanks
Eduard
////////////////////////////////////////////////////////////////////////
///////////////////////////////
// main
////////////////////////////////////////////////////////////////////////
///////////////////////////////
int a[10];
for(0 => int i; i < 10 ; i++) 10 - i => a[i];
PrintArray( a ); // passing array by reference works fine or am I
not referencing?
IsInArray( a, 8, 10); // ok
15 => int value;
<<<"value before modification is: ", value >>>;
ModifyValue( value, 35 ); // seems it's not correct
<<<"value after modification is: " , value >>>;
ModifyArray( a ); // ok
PrintArray( a ); // ok
////////////////////////////////////////////////////////////////////////
///////////////////////////////
// functions
////////////////////////////////////////////////////////////////////////
///////////////////////////////
fun void PrintArray( int @ array[] )
{
for( 0 => int i ; i < 10; i++ )
<<<"a[",i,"] = ", array[i]>>>;
}
fun int IsInArray(int @ array[], int num, int length )
{
if( length > array.cap() ) array.cap() => length;
if( !length ) return 0; // array is still empty
for( 0 => int i; i < length; i++ )
{
if( num == array[i] )
{
<<