Page 1 of 1
Defaultfolder Issue
Posted: Thu May 09, 2013 8:11 am
by vbro
I added a handler to my stack that reads a number of .txt files from a folder and stores their content in an array. It uses the
defaultfolder property and the
files keyword to get the list of files to process. At first, the handler was working fine and producing the expected results, but then the next time I opened LiveCode it was no longer working correctly. After some debugging, it seems like defaultfolder property is not retaining the value I give it when I use the
set command. I even created a new mainstack and put this code into a button...
Code: Select all
on mouseUp
set the defaultfolder to "./data/ships/"
put the defaultfolder into fld 1
end mouseUp
...Which should set the defaultfolder to a path relative to where the .livecode stack resides. However, when the button is pressed, the value that gets put in field 1 is "/Users/vbro/Applications". What am I missing here?
Re: Defaultfolder Issue
Posted: Thu May 09, 2013 8:39 am
by jmburnod
Hi vbro,
I understand you didn't save your stack and the defaultfolder is the path of applications folder.
You have to build the path as you want
This function return the path of the folder where is the stack or the standalone
function MainStackFolder
put the filename of this stack into rMainStackFolder
put the platform into tPlatForm
put the environment into pEnv
put the itemdel into OID
set the itemdel to "/"
put the num of items of rMainStackFolder into nbF
if tPlatForm = "MacOS" then
if pEnv = "standalone application" then
delete item (nbF-3) to nbf of rMainStackFolder
end if
if pEnv = "development" then
delete last item of rMainStackFolder
end if
else
delete last item of rMainStackFolder
end if
set the itemdel to OID
return rMainStackFolder
end MainStackFolder
Best regards
Jean-Marc
P.S. Why "code" and "quote" buttons dont' work today ?
Re: Defaultfolder Issue
Posted: Sat May 11, 2013 7:19 am
by vbro
Thank you very much. With this handler I can now set the defaultFolder appropriately according to the environment and OS the stack is running on. I think I may have been putting malformed folder paths into defaultFolder, but I'm not sure. Either way, greatly appreciated.