I'm puzzled why I'm getting the following error; The code looks fine to me.
I have the exact same code in another function and that's not complaining. This piece of code was working fine before. The only thing I recall doing was trying to add another "Wait For" statement in the same function, which B4X complained about so I removed it and, since then I keep getting this error. At the end of the function I get the following;
I managed to find the issue. There was in actual fact a missing "end if" towards the bottom of the function code, which I only noticed when I formatted the code and saw that the main "if" statement was not vertically aligned correctly. Once I added the missing "end if" all was well.