Bug Report Mac v4.0 - Indenting with word ELSE

Something you want to see in a LiveCode product? Want a new forum set up for a specific topic? Talk about it here.

Moderator: Klaus

Post Reply
MouseUp
Posts: 41
Joined: Sun Feb 14, 2010 3:41 pm

Bug Report Mac v4.0 - Indenting with word ELSE

Post by MouseUp » Tue Feb 23, 2010 6:41 pm

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.
Thanks,

MouseUp

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4163
Joined: Sun Jan 07, 2007 9:12 pm

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

Post by bn » Tue Feb 23, 2010 7:29 pm

MouseUp,
same for me here in 4.0
regards
Bernd

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10043
Joined: Sat Apr 08, 2006 7:05 am
Contact:

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

Post by FourthWorld » Tue Feb 23, 2010 8:08 pm

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
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

MouseUp
Posts: 41
Joined: Sun Feb 14, 2010 3:41 pm

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

Post by MouseUp » Sat Apr 06, 2013 5:30 am

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?
Thanks,

MouseUp

MouseUp
Posts: 41
Joined: Sun Feb 14, 2010 3:41 pm

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

Post by MouseUp » Mon Apr 15, 2013 2:14 pm

Verson 6.0 still has this bug...
Thanks,

MouseUp

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10305
Joined: Wed May 06, 2009 2:28 pm

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

Post by dunbarx » Tue Apr 16, 2013 5:00 am

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

Post Reply