this 'if' test has deliberately NOT been
// combined with the above 'if Want_sound' test
AFAIK, the compiler generates such code that it stops evaluating the boolean expression once its result is certain.

So, the construct

[pascal]var s: ansistring;
...
if Assigned(s) and (s[1] = 'ы') then .....[/pascal]
is absolutely safe, since s[1] check is never performed if the string is empty.


So, [pascal]procedure TMainForm.play_wave(sound_effect_wave_filename: string);
begin
if Want_Sound and FileExists(sound_effect_wave_filename)
then with MediaPlayer1 do
begin
filename := sound_effect_wave_filename;
AutoRewind := true;
Open;
Wait := true;
Play;
Close;
end;
end;[/pascal]