RAD function: same

A RAD function that compares two values. If the values are equal or both values are null, the result is true; otherwise, the result is false.

Function

same

Format

same(value1,value2)

Parameters

The following parameters are valid for this function.

Parameter Description
value1 The first value to be compared.
value2 The second value to be compared.

Factors

Use this function to compare arrays and structures, nulls, files, or empty strings.

When using the same function to compare arrays or structures, preface the variable names with denull, as shown in the following example:

not same(denull($filea), denull($fileb))

Note When using the same function to compare two files, the files must have the same schema, data, display value, and so on to return a result of True.

Return values

  • True: same
  • False: not same

Examples

same(1,NULL) returns false.

same(NULL,NULL) returns true.

same({},{,}) returns true.

same({1},{1,}) returns true.

same("",NULL) returns false.

The following is another example:

function testdisplayvaluecopy()
{
	var sql = 'select * from cm3r where number="C10001"';
	var file = new SCFile('cm3r');

	var file1 = new SCFile('cm3r');
	var rc = system.functions.fduplicate( file, file1 );
	
	rc = file.doSelect(sql);
	rc = system.functions.same( file, file1 );
	print("file is same as file1 after file.doSelect: ", rc );
	
	rc = file1.doSelect(sql);
	rc = system.functions.same( file, file1 );
	print("file is same as file1 after file1.doSelect: ", rc );
	var vRet = system.functions.set_display_value(file1, "assets", "testbystone", 1);
	
	rc = system.functions.same( file, file1 );
	print("file is same as file1 after set.display.value: ", rc );

	vRet = system.functions.display_value_copy(file, file1);
	
	rc = system.functions.same( file, file1 );
	print("file is same as file1 after display.value.copy: ", rc );
}
testdisplayvaluecopy();

This example returns these results:

file is same as file1 after file.doSelect:  false
file is same as file1 after file1.doSelect:  true
file is same as file1 after set.display.value:  false
file is same as file1 after display.value.copy:  true