contents   index   previous   next

Literal strings and comparisons


If both sides of a comparison operator are strings, and at least one of them is a literal string, then the comparison is performed as if Clib.strcmp() were being used. If one or both variables are literal strings, then the following translation of the comparison operation is performed.


lvar operator rvar Clib.strcmp(lvar, rvar) operator 0


The following examples demonstrate how literal strings follow the logic of Clib.strcmp().


if (animal == "dog")  // if (Clib.strcmp(animal, "dog") == 0)

if (animal <  "dog")  // if (Clib.strcmp(animal, "dog") <  0)

if ("dog" <= animal)  // if (Clib.strcmp("dog", animal) <= 0)


In ScriptEase, the following fragment:


var animal = "dog";

if (animal == "dog")

Clib.puts("hush puppy");




"hush puppy"


Literal strings and parameters