Commenting Out All "put" Statements
Date: Sat, 2 Dec 1995 00:10:48 -0800
From: Miles Lightwood <miles@RHYTHM.COM>
Subject: putOut()...
Here's the code for the PowerTool that comments out all Message window
'put' statements. Currently it's only been tested on DFM, so under
Windows, YMMV.
I'm providing it as a free-ware development tool to the Direct-L community,
so feel free to modify it to suit your needs.
Enjoy.
--===== putOut() 13Nov95 19Nov95 v 0.7 =======================================
-- This handler walks a range of castmembers commenting out all Message window
-- 'put' statements. It also optionally saves backup copies of scripts prior
-- to commenting them out.
--
-- Example: putOut(1, 23, FALSE)
-- Syntax: putOut(^startCast, ^endCast, ^makeBackups)
on putOut startCast, endCast, makeBackups
if voidP(startCast) then set startCast = 1
if voidP(endCast) then set endCast = the number of castmembers
if voidP(makeBackups) then set makeBackups = TRUE
if makeBackups then
set alertList = ["A backup of each script will be stored in '" & the pathname & ,
"' as individual files named 'scriptText <cast number>'"]
alert getAt(alertList,1)
put getAt(alertList,1)
end if
put "Started:" && the long date && the long time
put "Working on:"
repeat with currCast = startCast to endCast
if the castType of cast currCast <> #empty then
if the scriptText of cast currCast <> EMPTY then
set currCastName = "'" & the name of cast currCast & "'"
put "cast" && currCast && currCastName & "..."
set currScriptText = the scriptText of cast currCast
if makeBackups then
set xWriteFile = FileIO(mNew, "write", the pathName &
"scriptText" && currCast)
if xWriteFile = -43 then
alert "xWriteFile instantiation failed. Error code: -43"
return
end if
xWriteFile(mSetFinderInfo, "TEXT", "ttxt")
xWriteFile(mWriteString, currScriptText)
end if
repeat with currLine = 1 to the number of lines in currScriptText
if word 1 of line currLine of currScriptText = "put" then
if line currLine of currScriptText contains "after" then next repeat
if line currLine of currScriptText contains "before" then next
repeat
if line currLine of currScriptText contains "into" then next repeat
put "-- " before line currLine of currScriptText
end if
end repeat
end if
set the scriptText of cast currCast = currScriptText
put "finished."
end if
end repeat
if objectP(xWriteFile) then xWriteFile(mDispose)
put "Finished:" && the long date && the long time
end putOut
________________________________________________________
m i l e s l i g h t w o o d
________________________________________________________
m i l e s @ r h y t h m . c o m
________________________________________________________
rhythm & hues studios, inc. hollywood, ca, usa