PDA

View Full Version : Then expected near <eof>?



Visvalor
December 14th, 2009, 06:22
if UnarmedProfLevel.getValue() < 10 then

creates the error "Then expected near <eof> same as anytime I try to use less then.

However

UnarmedProfLevel.getValue() == 10 then or UnarmedProfLevel.getValue() > 10 then both work fine.

What am I doing wrong :\?

Foen
December 14th, 2009, 06:25
If you are using script in an xml file (instead of a stand-alone .lua file) you need to 'escape' any angle brackets:


if UnarmedProfLevel.getValue() &lt; 10 then

Foen

Visvalor
December 14th, 2009, 06:43
Ooooo well yes it's in XML :P not in a lua, quick script and all ^_^. Thanks again XD!


Ok so another question, how do you do <= in XML then :P?

Foen
December 14th, 2009, 07:00
The characters you need to escape are (officially) < & and >:

< is &lt;
> is &gt;
& is &amp;

It works at a character level, so <= is &lt;= and >= is &gt;=

You should perhaps take a look at the script documentation (https://www.fantasygrounds.com/modguide/scripting.xcp) for FG, the section Using Scripts alludes to this issue.

It also mentions the use of comment markers: XML is considered to be all on one line (line breaks are not honoured) and so the -- sequence to comment out the remainder of a line will in fact comment out the remainder of the script. When using comments in XML script you need to use the --[[ my comment here ]] syntax, and ensure you include the closing double square brackets.

Foen

Visvalor
December 14th, 2009, 07:03
<= also didn't work so I'd write it out to be &lt;= ?

Fenloh
December 14th, 2009, 07:13
Hi,

are you sure it is that line that creates the Error? Maybe you forgot the
'end' tag in the line above.

Tell me wrong, but shouldnt the correct line read

UnarmedProfLevel.getValue() == 10 or UnarmedProfLevel.getValue() > 10 then

without the second 'then'? wouldnt every 'then' need an end tag by itself?
if the following line is the one with the < 10 it would state the eof error in that line i think.

also you may consider to use 'else'

UnarmedProfLevel.getValue() == 10 or UnarmedProfLevel.getValue() > 10 then
blabla;
else
BlaBla;
end


Fenloh

Foen
December 14th, 2009, 07:17
It works at a character level, so <= is &lt;= and >= is &gt;=

Like I said :)