TIP: put it out!

MisterX b.xavier at internet.lu
Sat Jul 3 04:25:00 CDT 2004


Hi everyone,

To avoid the sometimes inpractical debugger (debug doesn't update the
variables always, no command keys, awkward scrolling, impractical portable
mice, and limited screen real estate), I usually put a script line like:

put "a status to check:" && a variableortwo

which gives me a quick and dirty status of a script.

The downside of this is that sometimes you forget about one or two of these
status display lines when you release software.

So here is a script that reports them...
The only little problem with this line is that if you force wrap the
statement with a backslash it will not be detected but this is a rather
benign problem which you can solve easily.

Since I use lots of dynamic scripts, I also included a check for those!

Enjoy
Xavier
http://monsieurx.com

on mouseUp
  put "yourstackname" into thisstack
  put the short name of the topstack into laststack
  set the defaultstack to thisstack
  put the script of stack thisstack into dscript
  put findputs(dscript) into resultlist
  if resultlist is not empty then
    put "Stack" && thisstack & CR & resultlist & CR after xoutput
  end if
  repeat with x = 1 to the number of cds
    put the script of cd x into dscript
    put findputs(dscript) into resultlist
    if resultlist is not empty then
      put "card" && x & CR & resultlist & CR after xoutput
    end if
  end repeat

  repeat with c = 1 to the number of controls
    put the script of control c into dscript
    put findputs(dscript) into resultlist
    if resultlist is not empty then
      put "Control" && c && the short name of control c && "ID:" & the short
id of control c & CR \
          & resultlist & CR after xoutput
    end if

  end repeat

  set the defaultstack to laststack
  put xoutput
end mouseUp

function findPuts dscript
  put "" into lineslist
  repeat with l = 1 to the number of lines in dscript
    set cursor to busy
    get line l of dscript
    if word 1 of it is "put" then
      if "into" is not in it and "after" is not in it and "before" is not in
it then
        put l & cr after lineslist
      end if
    end if
    if word 1 of l is "do" then
      if quote&"put" is in l and "into" is not in it and "after" is not in
it and "before" is not in it then
        put l & "*" & cr after linelist
      end if
    end if
  end repeat
  return lineslist
end findPuts



More information about the use-livecode mailing list