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
Moderator: Klaus
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
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