If the user makes a mistake (e.g. types conflicting settings into your form window), you can use the exitScript function (§5.8) to stop the execution of the script with an error message:
form: "My analysis"
real: "Starting time (s)", "0.0"
real: "Finishing time (s)", "1.0"
if finishing_time <= starting_time
exitScript: "The finishing time should exceed ", starting_time, " seconds."
# Proceed with the analysis...
For things that should not normally go wrong, you can use the assert directive:
power = Get power
assert power > 0
This is the same as:
if (power > 0) = undefined
exitScript: "Assertion failed in line ", lineNumber, " (undefined): power > 0"
elsif not (power > 0)
exitScript: "Assertion failed in line ", lineNumber, " (false): power > 0"
You can prevent Praat from issuing warning messages:
nowarn Save as WAV file: "hello.wav"
This prevents warning messages about clipped samples, for instance.
You can also prevent Praat from showing a progress window:
pitch = noprogress To Pitch: 0, 75, 500
This prevents the progress window from popping up during lengthy operations. Use this only if you want to prevent the user from stopping the execution of the script.
Finally, you can make Praat ignore error messages:
This would cause the script to continue even if there is nothing to remove.
© ppgb 20230122