warning
Display a warning message.
📝Syntax
warning()
warning(msg)
warning(id, msg)
warning(state)
warning(state, id)
st = warning()
warning(st)
📥Input Arguments
Parameter Description
id a string: identifier for the warning.
msg a string: message to warn.
state a string: 'on', 'off', 'aserror', 'all' or 'query'.
st a struct: set warning settings.
📤Output Arguments
Parameter Description
st a struct, warning settings.
📄Description

warning displays a warning message.

warning(' ') resets lastwarn state.

When called as warning(id, msg, ...) or warning(state, id), the identifier is written component:mnemonic, with one or more component fields followed by a mnemonic, each field starting with a letter and containing only letters, digits, or underscores, separated by colons (example: 'Nelson:io:fileNotFound'). Warnings raised by Nelson use Nelson as the first component; in your own code use a component of your choosing (for example your module name).

A few rules keep identifiers useful: the component should route to the area that raises the warning and the mnemonic should name the specific case in camelCase; a short two-field identifier is enough for cases that can happen anywhere; give one identifier a single message text (an identifier reused with several different messages cannot be translated); and reuse an existing identifier for the same case rather than a near-duplicate. The identifier is also what warning('off', id) and warning('on', id) enable or disable, so a stable identifier lets users control the warning.

💡Examples
warning('your warning message.')
warning('on', 'myModule:identifier');
warning('myModule:identifier', 'my message 1 on');
warning('off', 'myModule:identifier');
warning('myModule:identifier', 'my message 2 off');
warning('aserror', 'myModule:identifier');
warning('myModule:identifier', 'my message 3 as error');
🔗See Also
lasterrorerrorlastwarn
🕔Version History
Version Description
1.0.0 initial version
Edit this page on GitHub