This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| crpl:docs:eq [2013/01/14 19:00] – created virgilw | crpl:docs:eq [2025/02/14 14:57] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | TODO | + | |
| + | <- [[crpl: | ||
| + | ===== eq ===== | ||
| + | |||
| + | ^Arguments^Result^Notation^ | ||
| + | |Two Values|true or false (1 or 0) |'' | ||
| + | |||
| + | |||
| + | === Description === | ||
| + | Top two items are popped from the stack and ' | ||
| + | comparison is performed. 0 or 1 is pushed back to the stack where 1 indicates true. | ||
| + | |||
| + | === Comparing unlike types === | ||
| + | When trying to do a comparison where one argument is a string and the other is an int, the string gets coerced into an int. If the string is something like " | ||
| + | |||
| + | In particular, if x may be a string or number, (<-x " | ||
| + | |||
| + | The ' | ||
| + | - If either argument is a floating point number, then treat both arguments as floating point numbers, coercing the other argument if necessary. | ||
| + | - If both arguments are strings, then do string comparisons. | ||
| + | - If neither 1 nor 2 above is true, then treat each argument as an int, coercing the arguments if necessary. | ||
| + | |||
| + | === Examples === | ||
| + | < | ||
| + | # Compares numbers to 100. | ||
| + | # Pointless, in programming, | ||
| + | 100 50 gt # True, 100 is greater than 50 | ||
| + | 45 50 gt # False, 45 is not greater than 50 | ||
| + | 50 50 gt # False, 50 is not greater than 50</ | ||
| + | |||
| + | Examples of comparing with unlike types | ||
| + | < | ||
| + | " | ||
| + | 0 ->zero | ||
| + | 1 ->one | ||
| + | Trace(< | ||
| + | Trace(< | ||
| + | |||
| + | " | ||
| + | Trace(< | ||
| + | Trace(< | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | # If core doesn' | ||
| + | # Then " | ||
| + | Trace(GetScriptVar(< | ||
| + | # The following version returns TRUE only if core has Script.crpl attached with | ||
| + | # a variable " | ||
| + | Trace(GetScriptVar(< | ||
| + | </ | ||