Page 1 of 1

Bug Report Mac v4.0 - Indenting with word ELSE

Posted: Tue Feb 23, 2010 6:41 pm
by MouseUp
There seems to be a bug in the auto formatting in the script editor. If the word "else" is in the comment it won't indent correctly after that line:

Code: Select all

on newPage
   lock screen -- keep this at this spot or else you get white holes in screen
doMenu "New Card"
beep
end newPage
Remove the else in the comment and it indents as it is supposed to. Try it in the editor.

Re: Bug Report Mac v4.0 - Indenting with word ELSE

Posted: Tue Feb 23, 2010 7:29 pm
by bn
MouseUp,
same for me here in 4.0
regards
Bernd

Re: Bug Report Mac v4.0 - Indenting with word ELSE

Posted: Tue Feb 23, 2010 8:08 pm
by FourthWorld
FWIW it indents correctly in the MetaCard IDE, which uses this script:

Code: Select all

function reformatscript startline, endline
  local spaces, nspaces, fw, lw, continuation, gotthen, curline, newl, newdata
  put "                              " into spaces  put 0 into nspaces
  get line startline to endline of field "Editor Field"
  put it into newdata
  put false into continuation
  put true into gotthen
  put 1 into curline
  repeat for each line l in it
    put token 1 of l into fw
    if char 1 of fw is "#" or char 1 to 2 of fw is "--"
    then put l into line curline of newdata
    else
      put token -1 of l into lw
      if (fw is "end" or fw is "case" or fw is "default" or fw is "catch" or fw is "finally" or (fw is "else" and gotthen)) and nspaces > 0
      then subtract 2 from nspaces
      put char 1 to nspaces of spaces & word 1 to -1 of l into newl
      if newl is not l then put newl into line curline of newdata
      if the last char of l is "\" then
        if not continuation then
          put true into continuation
          add 4 to nspaces
          if word 1 of L is among the items of "on,private,command,function,getProp,setProp" then put 2 into nspaces
          else if word 1 of L is among the items of "repeat,case,switch,default,try,catch,finally" then add 2 to nspaces
        end if
      else
        put true into gotthen
        if continuation then
          put false into continuation
          subtract 4 from nspaces
        end if
        switch lw
        case "then"
        case "else"
          add 2 to nspaces
          break
        default
          switch fw
          case "if"
            if " else " is not in l
            then put false into gotthen
            break
          case "then"
            put false into gotthen
            break
          case "else"
            if token 2 of l is among the items of "if,repeat,switch,try"
            then put false into gotthen
            break
          case "repeat"
          case "case"
          case "switch"
          case "default"
          case "try"
          case "catch"
          case "finally"
            add 2 to nspaces
            break
          case "on"
          case "function"
          case "getprop"
          case "setprop"
          case "private"
          case "command"
            put 2 into nspaces
            break
          end switch
          break
        end switch
      end if
    end if
    add 1 to curline
  end repeat
  --
  GetHandlers
  --
  return newdata &cr
end reformatscript

Re: Bug Report Mac v4.0 - Indenting with word ELSE

Posted: Sat Apr 06, 2013 5:30 am
by MouseUp
I just downloaded and updated to LiveCode 5.0.2 for Mac and this indenting bug that I reported over 3 years ago is still present. Grrr.

v5.0.2 is the latest I could get in my account without paying more money.

Any chance it has been fixed in later versions?

Re: Bug Report Mac v4.0 - Indenting with word ELSE

Posted: Mon Apr 15, 2013 2:14 pm
by MouseUp
Verson 6.0 still has this bug...

Re: Bug Report Mac v4.0 - Indenting with word ELSE

Posted: Tue Apr 16, 2013 5:00 am
by dunbarx
Confirmed here.

If it matters, you can defeat it. Write:

on mouseUp
put 1 into temp
add 1 to temp --or else
add 1 to temp
end mouseUp

If you just write the above script, the indent fails below the "else". It remains improper even if you change the "else" to elseX". But if you press the tab key to reset indents while the line reads "elseX", the indents are fixed, and will STAY FIXED even if you restore the ordinary "else", for all subsequent lines of code.

Craig Newman