It is a bug, but a bug inside the language that Spacial is aware of and doesn't have a solution for.
You can NOT wait inside an IF. Try writing a loop with a condition that only executes once instead.
PAL Quick Start Guide p.7 wrote:
Very important note: Due to implementation problems, you can not do PAL.WaitForXXX within an IF statement block. This will be discussed later.
PAL Quick Start Guide p.10 wrote:
Now, a few important concepts about waiting:
You can not wait inside
a) IF..THEN statements
b) CASE..OF statements
c) Custom functions & procedures
PAL will simply skip over the wait command. This is an unfortunate result of the implementation of the core language PAL was based on. This language was never meant to be execute line-by-line, but rather as a complete program. Thus we had to significantly modify this language to meet our needs. Unfortunately we were not able to work around this problem for the above mentioned statement blocks.
The good news is that there is ways to avoid this problem.
1. Do not wait inside functions & procedures. Rather repeat the source lines where needed.
2. In the case of IF..THEN and CASE..OF statements, use a WHILE..DO loop instead.
IF (A>B) THEN
Can be replaced with:
var Dummy : Boolean = True;
WHILE (A>B) AND (Dummy) DO
Dummy := False;
While obviously not the perfect solution, it gets the job done. Oh, another tip. You can use the Dummy variable if you have many replacements to do. You just have to remember to either set Dummy := True; before the while loop.