BASIC unexpected error: end if

Macro’s that ran before now give me a BASIC error: unexpected error run if
Help

Dick

If you want someone to answer a question about a macro runtime error, please provide the macro (no fortune tellers known to be registered users here)

I don’t think it is a syntax problem because it worked before. Its i very mysterious.
To illustrate I the following one stament macro:

sub test
if (3 > 2) then v=1 end if
end sub

results in the following error message (BASIC syntax error.
Unexpected symbol: End If.)

If the conditional statement is reduced to a non conditional (the if-end if removed) there is no problem.
So it seems LibreOffice itself or some settings of LibreOffice.

I cannot proceed without conditional statements so please help me
Dick

It works - if you use line feeds:

sub test()
  if (3 > 2) then
    v=1 
  end if
end sub

so it is a syntax error (and the one-liner doesn’t work down to openoffice version 4.1). Hence can’t understand how you got to “it worked before

That is weird. I am awfully sorry. I think I tried the extended format you suggest. But that was in a slightly larger macro with several if end-if’s and possibly I tried to use the extended format and got the same error message and I forgot to check if that was the same line. Thanks for allowing me to be stupid.

FTR: there is a one-liner syntax for the if, but it doesn’t include the end if:

sub test
  if (3 > 2) then v=1
end sub

That is weird. I am awfully sorry. I think I tried the extended format you suggest. But that was in a slightly larger macro with several if end-if’s and possibly I tried to use the extended format at one place in the code and got the same error message and I forgot to check if that was the same line. Thanks for allowing me to be stupid.
Dick