WARNING - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

WARNING

write a warning message to the current output stream

 Calling Sequence WARNING(msgString, msgArg1, msgArg2, ...)

Parameters

 msgString - text of warning message msgArg1, msgArg2, ... - arguments to substitute into msgString

Description

 • A call to the WARNING function causes a warning to be produced on the current output stream. The message is displayed preceded by the prefix "Warning,".
 • If warnings are turned off, via interface(warnlevel=0), the warning will not be produced, and the call to WARNING will have no effect.
 • The msgString and any msgArg arguments specify how the warning is displayed. The same formatting rules applied to the error statement are used for warnings, except that display of a warning does not stop execution and throw an exception, and the message itself is prefixed by "Warning," instead of "Error,".
 • For details on the construction of WARNING %n parameter forms (also supported by error and StringTools:-FormatMessage), refer to Error and Warning Message Formatting.

Examples

 > f := proc(x) if x<0 then WARNING("result is complex") end if; sqrt(x) end proc;
 ${f}{≔}{\mathbf{proc}}\left({x}\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{if}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{x}{<}{0}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{then}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathrm{WARNING}}{}\left({"result is complex"}\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{end if}}{;}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathrm{sqrt}}{}\left({x}\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{end proc}}$ (1)
 > $f\left(-3\right)$
 ${I}{}\sqrt{{3}}$
 Warning, result is complex
 > $\mathrm{interface}\left(\mathrm{warnlevel}=0\right)$
 ${0}$ (2)
 > $f\left(-4\right)$
 ${2}{}{I}$ (3)
 > $\mathrm{interface}\left(\mathrm{warnlevel}=4\right)$
 ${0}$ (4)
 > $\mathrm{WARNING}\left("%1 CPU seconds used",\mathrm{time}\left(\right)\right)$
 Warning, .27e-1 CPU seconds used