Manual:DIL Manual/string in string
Jump to navigation
Jump to search
string in string
Operator (integer).
s1 in s2 : integer
TRUE (1) when the text s1 appears anywhere in s2, FALSE (0) when it doesn't. Case is ignored, and s1 may be part of a word: "key" in "Do you have a KEY?" and "ear" in "I hear you" are both TRUE.
Returns
TRUE or FALSE. An empty s1 ("") is found in every string.
Notes
- It is a plain substring test: to match whole words, use
inwith a stringlist (for example one made withsplit()) instead. - A string variable that was never assigned has no value at all, which isn't the same as
"". With such a variable on either side the result is null instead of an integer: aniftreats it as false, but assigning it to an integer variable stops the program with "Type error in integer assignemt" in the log. - The same operator with a stringlist or an extra description list on the right works differently: see the pages below.
Example
dilbegin keyword();
code
{
heartbeat := PULSE_SEC * 5;
:start:
wait(SFB_CMD, command("say") and (activator.type == UNIT_ST_PC));
if ("password" in argument)
exec("say Shh! Not so loud!", self);
goto start;
}
dilend
A monster that reacts when a player says something with "password" in it.