Can't end IF statements

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
monkey
Posts: 9
Joined: Mon Feb 17, 2014 9:38 pm

Can't end IF statements

Post by monkey » Thu Feb 20, 2014 2:11 pm

Hi all,

Can somebody please tell me what I'm doing wrong here?

I've typed the following code:
repeat with x = 1 to number of characters in currentWord
if wordArray[x] is " "
then put "/" after field "legend"
else put "*" after field "legend"
end if
end repeat
On application, I receive the following error:
card "game": compilation error at line 49 (repeat: missing 'end repeat'), char 4
It seems that LiveCode wants me to end repeat before ending IF, which makes no sense to me. If I do it that way, I'm then told that IF is not a valid handler.

I've looked online at examples of other IF statements and can't see anything wrong with what I've done.

So it must, therefore, be something bleeding obvious.

Any and all help appreciated!

Thanks again

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Can't end IF statements

Post by Klaus » Thu Feb 20, 2014 2:20 pm

Hi Monkey,

this should do:

Code: Select all

...
 repeat with x = 1 to number of characters in currentWord
    if wordArray[x] is " " then
      put "/" after field "legend"
    else
      put "*" after field "legend"
    end if
  end repeat
...
Note he "position" of THEN and ELSE!


Best

Klaus

monkey
Posts: 9
Joined: Mon Feb 17, 2014 9:38 pm

Re: Can't end IF statements

Post by monkey » Thu Feb 20, 2014 2:59 pm

D'oh!

Thanks again! :)

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Can't end IF statements

Post by Klaus » Thu Feb 20, 2014 3:02 pm

Yo :D

There are several ways to use IF THEN ELSE with or without END IF,
but I never "got" them, so I always the most verbose but also most
readable version like in my example. 8)

Post Reply