change boolean = single string to an error

This commit is contained in:
Steve Plimpton
2022-06-29 07:49:22 -06:00
parent 1dc71ef3e3
commit 1fabd5a56b
2 changed files with 7 additions and 3 deletions

View File

@ -198,8 +198,9 @@ FALSE.
.. note::
If the Boolean expression is a single numeric value with no Boolean
operators, it will be FALSE if the value = 0.0, otherwise TRUE. If the
Boolean expression is a single string, it will always be FALSE.
operators, it will be FALSE if the value = 0.0, otherwise TRUE. If
the Boolean expression is a single string, an error message will be
issued.
----------

View File

@ -4857,8 +4857,11 @@ double Variable::evaluate_boolean(char *str)
if (nargstack != 1) error->all(FLERR,"Invalid Boolean syntax in if command");
// if flag == 1, Boolean expression was a single string with no operator
// error b/c invalid, only single number with no operator is allowed
if (argstack[0].flag == 1)
error->all(FLERR,"If command boolean cannot be single string");
if (argstack[0].flag == 1) return 0.0;
return argstack[0].value;
}