QT: Defaultfolder & files

Eric Chatonet eric.chatonet at sosmartsoftware.com
Wed Aug 27 08:06:03 EDT 2008

Re bonjour William,

Actually, if you add a slash, Rev considers it as an absolute path  
name and it leads to the root of your hard disk.
All this is normal.
To create the folder at the same level as your application, deduce  
the complete path name from your app path name:

local tPath
put the filename of this stack into tPath
-- in an OS X bundle it will be something like:
-- /Applications/<App name>.app/Contents/MacOS/<App name>
set the itemDelimiter to slash
if the environment is "development" then
  -- easier to handle both environments: dev and standalone
   put "Backup" into item -1 of tPath
   -- a backup folder at the same level as the stack
else -- standalone
   put "Backup" into item -2 to -1 of tPath
   -- > /Applications/<App name>.app/Contents/Backup
end if
if there is no folder tPath then etc.

Have a look at 12.1 File Name Specifications and File Paths in Rev  
PDF documentation (p. 318) that details absolute and relative file  

Le 27 août 08 à 13:05, William de Smet a écrit :

> Bonjour and merci Eric,
> I added a "/" (slash) and now it works (only one folder is created and
> all the .txt files are stored in it):
> if there is a folder "/Backup" then set defaultfolder to it
> else create folder "/Backup"
> The folder however is now created on the root of my OSX HD.
> What happens when I create a standalone?
> Will the folder be created on the same level as the standalone or also
> on the root of my HD?
> (I actually want it to be on the same level as the standalone)
> greetings,
> William
> 2008/8/27 Eric Chatonet <eric.chatonet at sosmartsoftware.com>:
>> Bonjour William,
>> When you write: 'if there is a folder "Backup"', Rev looks at a  
>> 'Backup'
>> folder in the current default folder because you specify a name only.
>> Try to use a complete path name for the backup folder and it will  
>> work :-)
>> I assume you can deduce it from your main stack location.
>> Le 27 août 08 à 12:43, William de Smet a écrit :
>>> Hi there,
>>> A quick question about Defaultfolder & files.
>>> I create a folder "Backup" and set the defaultfolder to it and then
>>> save the .txt file.
>>> But now everytime there is a new folder created in which the  
>>> new .txt
>>> file is saved.
>>> Of course I want the Backup folder to be created only once  so I  
>>> want
>>> to check if it exists on mouseup:
>>> if there is a folder "Backup" then set defaultfolder to it
>>> else create folder "Backup"
>>> The 'problem' still exists.
>>> What am I doing wrong?
>>> Greetings,
>>> William

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