L3DT users' wiki
Large 3D terrain generator

iseq

Description

Test the equality of two variables.

Function prototype

bool iseq <variant:arg1> <variant:arg2>

Arguments

Name Type Comment
arg1 variant The first variable to be compared.
arg2 variant The second variable to be compared.

If the type of arg1 is not equal to that of arg2, the ordering of the arguments may change the result of calls to iseq. See Comparing variables of dissimilar types.

Return value

True if the values are equal, and false otherwise.

Example

// create an integer 'i', and set it to 20
int i
set i 20

// test whether the value of 'i' is 20, and echo result to log
echo <zs:iseq i 20>

… the output of which is written to the event log by echo as:

true

Comments

Comparing variables of dissimilar types

If the type of arg2 is different to that of arg1, arg2 will be typecast to the type of arg1. Thus, in certain circumstances, the the result of iseq will be different if the argument order is swapped, even if the values are unchanged.

For example, consider the case of comparing a float (f = 4.5) with an integer (i = 4):

float f
int i

set f 4.5
set i 4

echo <iseq f i> // 'f' goes first, so comparing as floats
echo <iseq i f> // 'i' goes first, so comparing as integers

The result of this code is:

false
true

In the first comparison in the above script (echo <iseq f i>), the first argument is a float (f = 4.5) so the second argument (i = 4) will be typecast to a float with the value of 4.0. Since 4.5 does not equal 4.0, this call to iseq returns false.

In the second comparison in the above script (echo <iseq i f>), the first argument is a integer (i = 4) so the second argument (f = 4.5) will be typecast to an integer with the value of 4. Since 4 does equal 4, this call to iseq returns true.

The moral of the story is: when comparing two variables, consider the type of the variables when deciding the argument order.

See also

 
plugins/general/zeoscript/reference/functions/iseq.txt · Last modified: 2017/08/31 05:08 (external edit)
 
Except where otherwise noted, content on this wiki is licensed under the following license:CC Attribution-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki