setting defaultFolder in V8

Richard Gaskin ambassador at fourthworld.com
Mon Apr 18 13:54:04 EDT 2016


William Prothero wrote:

 > I was just trying to get a list of folders in version 8 rc1, OSX El
 > Capitan. It doesn’t seem to set the defaultFolder, so I can’t get a
 > list of folders.
 >
 > I do:
 > on mouseUp
 >
 > 	put appNavParams["home"]["path"]&"/ appStacks/lessonsstacks" into 
lessonsPath
 > 	set the defaultFolder to lessonsPath
 > 	put the defaultFolder into tPath
 > 	put the detailed folders into tLessons
 > p	ut the files into tFiles
 > end mouseUp
 >
 >
 > The defaultFolder is set to the engine path and isn’t changed to the
 > value I set it to. This is the same in DP16. When I list the files,
 > it always shows the files in the engine folder.

When anything produces unexpected results it's usually helpful to check 
"the result" immediately after, e.g.:

    set the defaultFolder to lessonsPath
    if the result is not empty then
       answer "Couldn't set folder: "& the result &"("& sysError() &")" \
          &cr& lessonsPath
       exit to top
     end if

Things can go wrong in many placed, but file I/O is one of those areas 
where error-checking can be an especially useful habit.

The sysError function will let you know what the OS is trying to tell 
you about why it didn't work.

Also, it may just be a typo when pasting into email but there's a tab 
character in "put" in the last line.

-- 
  Richard Gaskin
  Fourth World Systems
  Software Design and Development for the Desktop, Mobile, and the Web
  ____________________________________________________________________
  Ambassador at FourthWorld.com                http://www.FourthWorld.com





More information about the use-livecode mailing list