REVO2700 5 fileUtility function uniqueName n repeat while there is a btn n of card "layout" of stack "fileUtility" put char -1 of n into c put charToNum(c) + 1 into d put numToChar(d) into c put c into char -1 of n end repeat return n end uniqueName function q s if char 1 of s = quote then return s return quote & s & quote end q function unq s if char 1 of s = quote then delete char 1 of s delete char -1 of s end if return s end unq function fixName obj set the itemDelimiter to "/" put value(word -1 of obj) into s put item -1 of s into s delete char -4 to -1 of s return word 1 to -2 of obj && q(s) end fixName function handler s,n put the number of chars of n into m put "on" && n into h put "end" && n into e put offset(h,s) into k put offset(e,s,k+m) into j return char k to j+2*m+5 of s end handler function findItem pObj,pList put number of items of pList into n repeat with i=1 to n if item i of pList = pObj then return i end repeat return 0 end findItem function removeSpaces s repeat for each char c in s if c = space then next repeat put c after r end repeat return r end removeSpaces function isNotFileList pTool,pList put the number of items of pList into n repeat for each item obj in pList if obj is not empty then if unq(word 2 of obj) = "folderIn" then answer pTool && "requires a file list as input." return true end if end if end repeat return false end isNotFileList function isNotFolderList pTool,pList put the number of items of pList into n repeat for each item obj in pList if obj is not empty then if unq(word 2 of obj) contains "folderIn" then return false end if end repeat answer pTool && "requires a folder list as input." return true end isNotFolderList function isFileNameOk fn repeat for each char C in fn if C is in ",()-+=" then return false end repeat return true end isFileNameOk function fileExtension fn set itemDelimiter to "." return item -1 of fn end fileExtension function isImageFile fn if fileExtension(fn) is in "PNG,GIF,JPEG,JPG" then return true else return false end isImageFile function shortFileName fn if fn contains " of " then get unq(word 2 of fn) return it else if "/" is in fn then set the itemDelimiter to "/" return item -1 of fn else return fn end if end shortFileName function dirFileName fn if "/" is in fn then set the itemDelimiter to "/" return item 1 to -2 of fn end if return fn end dirFileName on copyToLayout c put fld "name" of grp "controls" of card c of stack "Saves" into theName go to stack "fileUtility" put theName into fld "name" put the number of btns of card c of stack "Saves" into n repeat with b=1 to n put the short name of btn b of card c of stack "Saves" into s if s = "previous" or s = "next" or s = "delete" or s = "Close" or s = "Load" then next repeat copy btn b of card c of stack "Saves" to card "Layout" end repeat put the number of graphics of card c of stack "Saves" into n repeat with g=1 to n copy graphic g of card c of stack "Saves" to card "Layout" end repeat end copyToLayout G FileUtility U Lucida Grande W Lucida Grande U Lucida Grande W Lucida Grande cREVOnline fingerprint CK8XRsM78LLz8HW0vZX7wgid 235 cREVGeometryCache stackID 3033 cREVGeneral debugObjects button id 2149 of card id 1002 of stack "fileUtility" button id 2150 of card id 1002 of stack "fileUtility" button id 2261 of card id 1002 of stack "fileUtility"breakPoints 3103,17handlerList uniqueName q unq fixName handler findItem isNotFileList isNotFolderList isFileNameOk fileExtension isImageFile shortFileName dirFileName copyToLayoutscriptSelection char 2426 to 2442breakpointstates activescripteditorvscroll 677breakpointconditions bookmarks scripteditorselection 1161tempScript prevHandler fixNamescript layout IPglobal futObj,gRevAppIcon,gKind,gPoints on openStack set the allowInterrupts to true go to stack "status" go to stack "Tools" go to stack "Controls" end openStack local inPort,outPort on mouseDown put the long name of the target into futObj if word 1 of futObj = "card" then put empty into futObj exit mouseDown end if if the optionKey is down or the shiftKey is down then exit mouseDown put the mouseLoc into lx put the loc of futObj into cx set the draggingMe of futObj to false put empty into gPoints put empty into gKind put clickedOnPort(lx,cx) into outPort if outPort>0 then put (the short name of futObj) & gKind & outPort into n if there is a graphic n then answer "That port is already in use. Try again." exit mouseDown end if create graphic n set the style of graphic n to "line" set the endArrow of graphic n to true set the points of graphic n to gPoints set the origin of graphic n to futObj put the long name of graphic n into futObj set the draggingMe of graphic n to true else if the lockLoc of futObj then exit mouseDown set the loc of futObj to lx set the draggingMe of futObj to true end if end mouseDown on mouseEnter if futObj is not empty and there is an futObj then if futObj contains "button" and the draggingMe of futObj then set the loc of futObj to the mouseLoc end if end if end mouseEnter on mouseMove if word 1 of futObj is "card" then exit mouseMove if futObj is not empty and the lockLoc of futObj then exit mouseMove if futObj is not empty and there is an futObj then if futObj contains "button" and the draggingMe of futObj then set the loc of futObj to the mouseLoc else if futObj contains "graphic" and the draggingMe of futObj then put the points of futObj into p put the mouseLoc into line -1 of p set the points of futObj to p end if end if end if end mouseMove on mouseUp put the mouseLoc into lx if there is an futObj then if word 1 of futObj = "button" then put the icon of futObj into gRevAppIcon if the optionKey is down then answer "Do you want to delete this tool or just move it?" with "delete" or "move" if it is "move" then set the lockLoc of futObj to false exit mouseUp else if the output of futObj is not empty or the input of futObj is not empty then answer "You have to delete all the connections first. Use the shift key." exit mouseUp end if set the lockLoc of futObj to false delete futObj put empty into futObj end if end if if the shiftKey is down then answer "Do you really want to delete all the connections to" && the short name of futObj with "Yes" or "No" if it is "Yes" then removeConnections futObj exit mouseUp end if end if if futObj contains "graphic" then put findObj(lx) into otherObj if otherObj is empty then answer "Connection missed, try again." if futObj is not empty then delete futObj put empty into futObj end if exit mouseUp end if if otherObj contains "button" then put the loc of otherObj into cx put clickedOnPort(lx,cx) into inPort if inPort>0 then put the origin of futObj into orig if k="out" then send "attachInput inPort,otherObj" to orig send "attachOutput outPort,orig" to otherObj else send "attachOutput outPort,otherObj" to orig send "attachInput inPort,orig" to otherObj end if end if end if choose browse tool end if if there is a futObj then set the lockLoc of futObj to true end if if there is a futObj then set the draggingMe of futObj to false put empty into futObj end mouseUp on mouseRelease if there is an futObj then mouseUp end if end mouseRelease function findObj lx repeat with i=1 to number of btns of this card if lx is within the rect of btn i then return the long name of btn i end if end repeat return empty end findObj function clickedOnPort lx,cx put empty into p if item 2 of lx > 8 + item 2 of cx then put "out" into k if item 1 of lx < (item 1 of cx) - 8 then put 1 into tPort put (item 1 of lx) - 12 into item 1 of p put (item 2 of lx) + 16 into item 2 of p else if item 1 of lx > 8 + item 1 of cx then put 3 into tPort put (item 1 of lx) + 12 into item 1 of p put (item 2 of lx) + 16 into item 2 of p else put 2 into tPort put (item 1 of lx) - 0 into item 1 of p put (item 2 of lx) + 16 into item 2 of p end if end if put CR after p put item 1 of p into line 2 of p put (item 2 of lx) + 20 into item 2 of line 2 of p else put "in" into k if item 2 of lx < (item 2 of cx) - 8 then if item 1 of lx < (item 1 of cx) - 8 then put 1 into tPort put (item 1 of lx) - 12 into item 1 of p put (item 2 of lx) - 16 into item 2 of p else if item 1 of lx > 8 + item 1 of cx then put 3 into tPort put (item 1 of lx) + 12 into item 1 of p put (item 2 of lx) - 16 into item 2 of p else put 2 into tPort put (item 1 of lx) - 0 into item 1 of p put (item 2 of lx) - 16 into item 2 of p end if end if put CR after p put item 1 of p into line 2 of p put (item 2 of lx) - 20 into item 2 of line 2 of p else return 0 end if end if put k into gKind put p into gPoints return tPort end clickedOnPort function findPort pObj,pList put the number of items of pList into n repeat with p=1 to n if item p of pList = pObj then return p end repeat return 0 end findPort on removeConnections object put the input of object into inList put number of items of inList into n repeat with p=1 to n put item p of inList into o if o is not empty then put findPort(object,the output of o) into op put (the short name of o) & "out" & op into g if there is a graphic g of card "layout" then delete graphic g of card "layout" end if deleteItems "output",o end if end repeat set the input of object to empty put the output of object into outList put number of items of outList into n repeat with p=1 to n put item p of outList into o if o is not empty then deleteItems "input",o put (the short name of object) & "out" & p into g if there is a graphic g of card "layout" then delete graphic g of card "layout" end if end if deleteItems "output",object end repeat set the output of object to empty end removeConnections on deleteItems kind,object put the kind of object into outList put the number of items of outList into n repeat with p=n down to 1 if item p of outList is not empty then if item p of outList = futObj then delete item p of outList end if end repeat set the kind of object to outList end deleteItems on dragDrop put the long name of card "objects" of stack "Tools" into theControl if the doCreate of theControl then set the doCreate of theControl to false put the loc of card "layout" of stack "fileUtility" into lx put the dragData into futObj put the short name of futObj into n if there is a btn n of card "layout" of stack "fileUtility" then put uniqueName(n&"A") into n end if copy futObj to card "layout" of stack "fileUtility" put it into newObj set the name of newObj to n put the toolTip of newObj into tt put "Use" into word 1 of tt delete word 4 to 6 of tt set the toolTip of newObj to tt set the lockLoc of newObj to false wait 10 ticks set the loc of newObj to lx put newObj into futObj set the draggingMe of futObj to true set acceptDrop to false end if end dragDrop runFolder :/Volumes/ Files /Rev/stacks/caveAdventure/images/artifacts beginMove truedraggingMe false cREVGeometryCacheIDs 1241652510743 25551150816900704 10031151176930856 1725 cREVGeometrycache order 1151176930856 total 3 cREVGeneral breakPoints handlerList openStack mouseDown mouseEnter mouseMove mouseUp mouseRelease findObj clickedOnPort findPort removeConnections deleteItems dragDropscriptSelection char 40 to 39scripteditorvscroll 0 bookmarks scripteditorselection 0tempScript prevHandler clickedOnPortscript contextual menu mac.gif D 5 82 J Ɂ B @ ` p x | ~ ~ |B l~ FB ~ B ~ F cREVGeneral revUniqueID 1150816900704 name +h ] draggingMe false cREVGeometry Master,moveVObjectSide bottomMaster,movehDistance -0.5058Master trueMaster,moveVObjectRef cardMaster,moveHObjectRef cardMaster,moveVAbsolute false Master,moveV falseMaster,expectedRect 195,14,435,39Master,scalebottomDistance Master,movevDistance -0.949416Master,moveHObjectSide rightMaster,scalerightDistance Master,cardRanking 1Master,scaleleftDistance Master,moveHAbsolute falseMaster,scaletopDistance Master,moveH true cREVGeneral revUniqueID 1151176930856 Layout WomanMan.jpeg @ ` WomanMan.jpeg cREVGeneral revUniqueID 1241652510743 , Tools EtS File Tools U Lucida Grande U Lucida Grande W Lucida Grande cREVGeometryCache stackID 1068 cREVGeneral breakpointconditions breakpoints breakpointstates objects IPglobal futObj on mouseDown put the target into t if t contains "button" then put the long name of t into futObj set the dragData to futObj set acceptDrop to false set the doCreate of me to true end if end mouseDown on dragEnter if the short name of me = "layout" then go to card "layout" of stack "fileUtility" wait 10 ticks end if pass dragEnter end dragEnter on dragLeave send "dragDrop" to card "layout" of stack "fileUtility" --dragDrop end dragLeave on dragMove put the mouseLoc into lx set the cursor to 1003 end dragMove on mouseLeave if futObj is not empty then send "mouseEnter" to card "layout" of stack "fileUtility" end if end mouseLeave tS doCreate true cREVGeometryCacheIDs 1151347676869 10361150807676730 10091152282208562 10371213709147108 10641151347516150 10351150807492722 10071171547696639 10581215803212952 10671171554298061 10591171569740441 10631150807092882 10041153145074283 10561151098351387 10271150810225664 10111152723315228 10441243342815782 10681151064728521 10231153055705129 10551170803153980 10571150828991119 10131150937852329 10191150937213094 10181151346771407 1032 cREVGeometrycache total 23order *1150810225664 1150937213094 1151346771407 cREVGeneral bookmarks breakPoints handlerList 1mouseDown dragEnter dragLeave dragMove mouseLeavetempScript prevHandler dragEnterscript ! " # ' ( + , folderIn G[on mouseUp -- Do any setup in this handler if the draggingMe of me then pass mouseUp if the short name of this stack = "Tools" then help exit mouseUp end if set the draggingMe of me to false if the optionKey is down or the shiftKey is down then pass mouseUp answer folder "Select the folder to use" if it is empty then answer the result else set the folderName of me to it end if end mouseUp on input pPort,pData -- Process any incoming input in this handler -- End of the processing -- Let sender know that you are finished with the current input put item pPort of (the input of me) into obj if obj is not empty then send "inputDone pPort" to obj end input on inputDone pPort -- Process next output end inputDone on output pPort,pData -- Send output data to Object attached to this port put item pPort of (the Output of me) into obj if obj is not empty then send "input pPort,pData" to obj end output on attachInput pPort,pObj -- record input attachments to this port put the input of me into t put pObj into item pPort of t set the input of me to t end attachInput on attachOutput pPort,pObj -- record output attachments to this port put the output of me into t put pObj into item pPort of t set the output of me to t end attachOutput on run put the output of me into t put the number of items of t into n repeat with p=1 to n if item p of t is not empty then output p,the folderName of me end if end repeat end run on help -- use this handler to display some help put "Click on me in the layout to assign a folder to me." & CR into t put "Connect my output ports to other tools that need a folder name as input." after t set the displayData of stack "Display" to t set the title of stack "Display" to (the short name of me) && "help" go to stack "Display" end help A K draggingMe false 8Drag this Tool to the layout to choose an input folder. X cREVGeneral scripteditorvscroll 615 bookmarks revUniqueID 1150807092882scripteditorselection 10handlerList @mouseUp input inputDone output attachInput attachOutput run helpprevHandler attachInputtempScript script folderOut Gson mouseUp if the short name of this stack = "Tools" then help exit mouseUp end if if the draggingMe of me then pass mouseUp set the draggingMe of me to false if the optionKey is down or the shiftKey is down then pass mouseUp -- Do any setup in this handler answer folder "Select the folder to use" if it is empty then answer the result else set the folderName of me to it end if end mouseUp on input pPort,pData -- Process any incoming input in this handler put the folderName of me into f if f is empty then answer "Folder is not defined in" && the short name of me exit to top end if put the imageExtension of me into ext if isNotFileList(short name of me,the input of me) then exit to top put the runFolder of card "layout" of stack "fileUtility" into inf set the defaultFolder to f repeat for each line L in pData put shortFileName(L) into fn set itemDelimiter to "." if ext is empty then put "Writing file" && fn into fld "msg" of stack "status" put item -1 of fn into ext else put ext into item -1 of fn end if set itemDelimiter to comma put "binFile:" & f & "/" & fn into fa if word 1 of L = "image" then put "export" && L && "to file" && q(f & "/" & fn) && "as" && ext into doIt do doIt delete L next repeat else put "binFile:/" & inf & "/" & fn into fs put URL fs into d get the result if it is empty then put d into URL fa else answer "reading file:" && fn && "returned:" && the result exit to top end if put d into URL fa end if get the result if it is not empty then answer "Error writing file:" & fn & CR & it next repeat end if if word 1 of L = "image" then Delete L end repeat -- End of the processing -- Let sender know that you are finished with the current input put item pPort of (the input of me) into obj if obj is not empty then send "inputDone pPort" to obj end input on inputDone pPort -- Process next output end inputDone on output pPort,pData -- Send output data to Object attached to this port put item pPort of (the Output of me) into obj if obj is not empty then send "input pPort,pData" to obj end output on attachInput pPort,pObj -- record input attachments to this port put the input of me into t put pObj into item pPort of t set the input of me to t end attachInput on attachOutput pPort,pObj -- record output attachments to this port put the output of me into t put pObj into item pPort of t set the output of me to t end attachOutput on run -- execute script here end run on help -- use this handler to display some help put "Click on me in the layout to assign the folder where to write the files." & CR into t put "Connect from a source file names tool (files,split,join,filter) to one of my input ports." & CR after t put "I will copy the specified files on the input ports to the selected folder." after t set the displayData of stack "Display" to t set the title of stack "Display" to (the short name of me) && "help" go to stack "Display" end help 8 O 9Drag this tool to the layout to select an output folder. Z cREVGeneral scriptChecksum ZyHO/handlerList @mouseUp input inputDone output attachInput attachOutput run helpbreakPoints scriptSelection char 2049 to 2073 bookmarks revUniqueID 1150807492722scripteditorvscroll 800scripteditorselection 1766prevHandler attachInputtempScript script b
on mouseUp
if the short name of this stack = "Tools" then
help
exit mouseUp
end if
if the draggingMe of me then pass mouseUp
set the draggingMe of me to false
if the optionKey is down or the shiftKey is down then pass mouseUp
-- Do any setup in this handler
answer folder "Select the folder to use"
if it is empty then
answer the result
else
set the folderName of me to it
end if
end mouseUp
on input pPort,pData
-- Process any incoming input in this handler
put the folderName of me into f
if f is empty then
answer "Folder is not defined in" && the short name of me
exit to top
end if
put the imageExtension of me into ext
if isNotFileList(short name of me,the input of me) then exit to top
put the runFolder of card "layout" of stack "fileUtility" into inf
set the defaultFolder to f
repeat for each line L in pData
put shortFileName(L) into fn
set itemDelimiter to "."
if ext is empty then
put "Writing file" && fn into fld "msg" of stack "status"
put item -1 of fn into ext
else
put ext into item -1 of fn
end if
set itemDelimiter to comma
put "binFile:" & f & "/" & fn into fa
if word 1 of L = "image" then
put "export" && L && "to file" && q(f & "/" & fn) && "as" && ext into doIt
do doIt
delete L
next repeat
else
put "binFile:/" & inf & "/" & fn into fs
put URL fs into d
get the result
if it is empty then
put d into URL fa
else
answer "reading file:" && fn && "returned:" && the result
exit to top
end if
put d into URL fa
end if
get the result
if it is not empty then
answer "Error writing file:" & fn & CR & it
next repeat
end if
if word 1 of L = "image" then Delete L
end repeat
-- End of the processing
-- Let sender know that you are finished with the current input
put item pPort of (the input of me) into obj
if obj is not empty then send "inputDone pPort" to obj
end input
on inputDone pPort
-- Process next output
end inputDone
on output pPort,pData
-- Send output data to Object attached to this port
put item pPort of (the Output of me) into obj
if obj is not empty then send "input pPort,pData" to obj
end output
on attachInput pPort,pObj
-- record input attachments to this port
put the input of me into t
put pObj into item pPort of t
set the input of me to t
end attachInput
on attachOutput pPort,pObj
-- record output attachments to this port
put the output of me into t
put pObj into item pPort of t
set the output of me to t
end attachOutput
on run
-- execute script here
end run
on help
-- use this handler to display some help
put "Click on me in the layout to assign the folder where to write the files." & CR into t
put "Connect from a source file names tool (files,split,join,filter) to one of my input ports." & CR after t
put "I will copy the specified files on the input ports to the selected folder." after t
set the displayData of stack "Display" to t
set the title of stack "Display" to (the short name of me) && "help"
go to stack "Display"
end help
addAlpha G Eon mouseUp if the short name of this stack = "Tools" then help exit mouseUp end if if the draggingMe of me then pass mouseUp set the draggingMe of me to false if the optionKey is down or the shiftKey is down then pass mouseUp -- Do any setup in this handler end mouseUp on input pPort,pData -- Process any incoming input in this handler if isNotFileList(short name of me,the input of me) then exit to top set the itemDelimiter to "/" repeat for each line L in pData put item -1 of L into iName if isImageFile(iName) then put "Creating alpha for:" & iName into fld "msg" of stack "status" if there is not an image iName then create image iName end if put it into obj set the visible of obj to false set the filename of obj to L put the imageData of obj into iData put makeMask(iData,true) into aData set the alphaData of obj to aData put fixName(the long name of obj) & CR after d else put L & CR after d end if end repeat set the itemDelimiter to comma put the output of me into t repeat with p=1 to number of items of t put item p of t into obj if obj is not empty then send "input p,d" to obj end if end repeat -- End of the processing -- Let sender know that you are finished with the current input put item pPort of (the input of me) into obj if obj is not empty then send "inputDone pPort" to obj end input on inputDone pPort -- Process next output end inputDone on output pPort,pData -- Send output data to Object attached to this port put item pPort of (the Output of me) into obj if obj is not empty then send "input pPort,pData" to obj end output on attachInput pPort,pObj -- record input attachments to this port put the input of me into t put pObj into item pPort of t set the input of me to t end attachInput on attachOutput pPort,pObj -- record output attachments to this port put the output of me into t put pObj into item pPort of t set the output of me to t end attachOutput on run -- execute script here end run on help -- use this handler to display some help put "Connect tools that produce a list of file names to my input ports." & CR into t put "Connect my output ports to a folderOut tool to select where to write the output." & CR after t put "I will build an alpha mask for input image file names and add it to a copy of the input image files."&CR after t put "The folderOut tool will write the new image files to the specified output folder." after t set the displayData of stack "Display" to t set the title of stack "Display" to (the short name of me) && "help" go to stack "Display" end help function makeMask pImageData,doInverse put empty into tAlphaData put the length of pImageData/4 into tAlphaDataLength put 0 into tPos repeat for talphaDataLength times put charToNum(char tPos + 2 of pImageData) into tRr put charToNum(char tPos + 3 of pImageData) into tRb put charToNum(char tPos + 4 of pImageData) into tRg if tRr=255 and tRb=255 and tRg=255 then put 255 into tR else put 0 into tR if doInverse then put 255-tR into tR end if put tPos + 4 into tPos put binaryEncode("C",tR) after tAlphaData end repeat return tAlphaData end makeMask 8 W DDrag this tool to the layout to add an alpha mask to an image file. \ cREVGeneral breakPoints handlerList ImouseUp input inputDone output attachInput attachOutput run help makeMaskscriptSelection char 882 to 881scripteditorvscroll 533revUniqueID 1150807676730 bookmarks scripteditorselection 1029tempScript prevHandler attachInputscript template Gon mouseUp if the short name of this stack = "Tools" then help exit mouseUp end if if the draggingMe of me then pass mouseUp set the draggingMe of me to false if the optionKey is down or the shiftKey is down then pass mouseUp -- Do any setup in this handler end mouseUp on input pPort,pData -- Process any incoming input in this handler -- End of the processing -- Let sender know that you are finished with the current input put item pPort of the input of me into obj if obj is not empty then send "inputDone pPort" to obj end input on inputDone pPort -- Process next output end inputDone on output pPort,pData -- Send output data to Object attached to this port put item pPort of (the Output of me) into obj if obj is not empty then send "input pPort,pData" to obj end output on attachInput pPort,pObj -- record input attachments to this port put the input of me into t put pObj into item pPort of t set the input of me to t end attachInput on attachOutput pPort,pObj -- record output attachments to this port put the output of me into t put pObj into item pPort of t set the output of me to t end attachOutput on run -- execute script here end run on help -- use this handler to display some help put "some help" into t -- end of help define set the displayData of stack "Display" to t set the title of stack "Display" to (the short name of me) && "help" go to stack "Display" end help &