One of the quickest and easiest ways to generate code is to convert a command sequence to a method. In the Form Editor, select Convert to Method from the menu button displayed in the
Settings window below an existing command sequence. The command sequence is automatically replaced by an equivalent method. In the same way you can select
Convert to Form Method and
Convert to Local Method.
Select the Convert to Method option below the command sequence.

Click the Go to Method button. The Method Editor opens with the tab for
method3 active.

In the Method Editor, add a call to the built-in method playSound to play the sound file
success.wav, available in the COMSOL sound library, by using the syntax shown in the figure below.

Note that in the example above, you do not have to use the Method Editor. In the command sequence, select the file success.wav under
Libraries >
Sounds and click the
Run command button under the tree, as shown in the figure below.
