why can't I create a folder with a variable?
Eric Chatonet
eric.chatonet at sosmartsoftware.com
Tue Aug 21 04:50:20 EDT 2007
Hi Tiemo,
When creating a folder "C:/Temp/foo", it assumes that the folder
named Temp does exists yet or nothing will happen:
on mouseUp
local tFolder ,tResult
-----
put "C:/Temp/foo" into tFolder
put CreateFolder(tFolder) into tResult --
-----
switch tResult
case empty -- all went well
break
case "can't create that directory" -- error
-- statements
break
case "Folder exists yet." -- just FYI
-- statements
end switch
end mouseUp
-------------------------------------------
function CreateFolder pFolderPath
if there is no folder pFolderPath then
set the itemDelimiter to slash
repeat with i = 2 to the number of items of pFolderPath
if there is no folder (item 1 to i of pFolderPath) then
create folder (item 1 to i of pFolderPath)
if the result <> empty then return the result
end if
end repeat
return empty
else return "Folder exists yet."
end CreateFolder
Hope this helps.
Note that error handling is always important in any code snippet :-)
Le 21 août 07 à 09:32, Tiemo Hollmann TB a écrit :
> Hello,
>
> when saying:
> create folder "C:/Temp/foo" -- it works like expected
>
> when saying:
> put "C:/Temp/foo" into myFolder
> create folder myFolder -- nothing happens
>
> I even tried it with:
>
> put "C:/Temp/foo" into myFolder
> create folder merge(quote & myFolder & quote) -- nothing happens
> any idea, what I a missing is appreciated
Best regards from Paris,
Eric Chatonet.
----------------------------------------------------------------
Plugins and tutorials for Revolution: http://www.sosmartsoftware.com/
Email: eric.chatonet at sosmartsoftware.com/
----------------------------------------------------------------
More information about the use-livecode
mailing list