Stray Puts
Michael Doub
mikedoub at gmail.com
Fri Feb 24 21:16:32 EST 2012
As long as we are sharing debugging techniques, let me share what I am doing for IOS development. I created a launcher app that has a Global LogData buffer. The launcher app has a display window and 3 buttons. One button goes to a file in my dropbox that contains a list of URLs to the other stacks available to load and lists them in the display window. A second button does a "go stack URL" to the selected line in the display window thus dynamically loading the stack from my dropbox. This allows for a quick edit/save/test cycle that people discussed on a separate thread. The third button copies the LogData into the display window.
In my stacks I include the routines below for logging. I find the IOS environment pretty fragile so I set things up to bail out of the stack leaving the logData for examination. I push and pop the log so I can keep the memory foot print down and the current context readily available.
There are 2 logging functions tlog and log. I replace "tlog" with "--tlog" after debugging or set the logTrace to false. The log, push and pop stay in place for when things go really bad. I tend make the tlog output "documentation like" so it is pretty easy to come back and figure out what in the world I was thinking about when I wrote this code.
Enjoy!
Mike
--> Log Management Functions
Global LogData
Global logTrace
Global Logindent
on tlog x
if (logTrace) then log (x)
end tlog
on log x
repeat Logindent times
put space after LogData
end repeat
put x && return after LogData
end log
on Dump
Log ("== Dump Forced ==")
close the defaultStack
exit to top
end Dump
on clearlog x
put 0 into Logindent
put empty into LogData
end clearlog
on Pushlog x
put "<>" && x & return after LogData
add 3 to Logindent
do x
end Pushlog
on Poplog
repeat until LogData is empty
put the last line of LogData into y
if word 1 of y <> "<>" then
delete the last line of LogData
else
delete the last line of LogData
exit repeat
end if
end repeat
subtract 3 from Logindent
end Poplog
On 02/24/2012, at 2:05 PM, Marty Knapp wrote:
> I've gotten in the habit of doing this:
>
> --TEST:
> put blah blah blah
>
> Then I can just do a search for "--TEST" and find the "put" and delete it. Not very high-tech, but it works for me.
>
> Marty K
>> Anyone ever scripted a put to put something in the message box, and then forgot it was there and had a helluvatime finding it again? I give you:
>>
>> function findPut theScript
>> filter theScript without "* into *"
>> filter theScript without "* before *"
>> filter theScript without "* after *"
>> filter theScript with "*put *"
>> return theScript
>> end findPut
>>
>> I LOVE that filter command!
>>
>> Bob
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
More information about the use-livecode
mailing list