Path Management tricks
Edwin Gore
edgore at shinra.com
Wed Aug 20 15:02:01 EDT 2003
Some of the things that Chipp mentioned in his post about auto-updating got me to thinking...How do others do their path management?
I started off being stupid and going through all the steps to set up a path and then set the defaultfolder to it. Then I crawled out of the sea and started using functions to do it instead. Now, I am up in the trees using the following single function with parameters in a backscript:
(feel free to steal from it)
function getPath pathType, category, section
switch pathtype
case "app"
set the itemDelimiter to "/"
put item 1 to -2 of the effective filename of \
stack "aassist" into thePath
set the itemdelimiter to comma
break
case "document"
set the itemDelimiter to "/"
put item 1 to -2 of the effective filename of stack \
gDocument into thePath
set the itemdelimiter to comma
break
case "image"
if char 2 of field "imagefolder" of card 1 of stack \
gDocument <> ":" then
put getpath("document") & "/" & field \
"imageFolder" of card 1 of stack gDocument into \
thePath
else
put field "imagefolder" of card 1 into thePath
end if
break
case "htmlFolder"
put gHtmlFolder & "/" into thePath
break
case "htmlCatFolder"
put stripchars(category) into category
put getPath("htmlFolder") & category & "/" into thePath
break
case "htmlSubFolder"
put stripchars(category) into category
put getPath("htmlCatFolder",category) & section & "/" \
into thePath
break
case "htmlImage"
put getPath("htmlFolder") & "images/" into thePath
break
case "ftpFolder"
put field "ftpHost" of card 1 of stack gDocument & "/" \
& field "ftpDir" of card 1 of stack gDocument into \
thePath
break
case "ftpCatFolder"
put stripchars(category) into category
put getPath("ftpFolder") & category & "/" into thePath
break
case "ftpSubFolder"
put stripchars(category) into category
put getPath("ftpCatFolder",category) & Section & "/" \
into thePath
break
case "ftpImage"
put getPath("ftpFolder") & "images/" into thePath
break
end switch
return thePath
end getPath
The biggest advantage is that since I have everything for all pths in one place, I don't have to remember what has a trailing slash and what doesn't, since it's all at least in one place.
What I am wondering is, what are other people doing? Any responses from those walking upright on land, or even better, using fire, would be greatly appreciated.
More information about the use-livecode
mailing list