The fileName: When using it in scripts, how to avoid modifiying it for each user ?

Jim Ault JimAultWins at yahoo.com
Wed Nov 1 10:08:52 CST 2006


On 11/1/06 9:30 AM, "André.Bisseret" <Andre.Bisseret at inria.fr> wrote:

> Hi,
> I have an app a substack of which is a model. This model is clone in
> ordre to create other stacks. These created stacks  are main stacks
> (not substacks) because they are populated with data which have to be
> saved. They are accumulated in a folder (say « theFolder »).
> 
> So, for each created stack, I must set its fileName in order to place
> it into « theFolder » ; also I must use the fileName in order to be
> able to re-open on such stack from «theFolder ». (in each of these
> cases, if I simpy use the stack name, that does not work).
> 
> Ex : stack « /Users/user¹name/desktop/theFolder/oneStackName »
> 
> My problem arises when I want to give my app to another user who will
> use it with stackRunner (or as a standalone if I save it under this
> form) :
> then, in several scripts I must change the fileName ; specifically ,
> the « user¹name ». But also, possibly the destination (« theFolder »
> or even « desktop/theFolder », depending on where the user want to
> put this folder).
> 
> If I want several users get my app., this change becomes
> unacceptable (even not possible).
> 
> Is it a way to get rid of this constraint ?


First, 
the stack filename contains the path to its location.  Use that as the
'home' or 'root' folder name.

Second, on starting the app, get a list of the folders in that same folder
your stack is currently in.  If there are none, then ask the user for a
folder name (or create a "defaultHome" folder)(or
set the itemdel to "/"
put item 3 of the filename of this stack into tUser
creae folder tUser&"Data"

Third, use the defaultHome folder until the user chooses to do it
differently and names the folder to his liking.  At this time, move all of
the files from the defaultHome to the new folder, then delete the old
defaultHome folder.  On start, this will be the only folder that contains
the dataFile you need.  Now your stack startup routine will get a list of
folders, then look inside until it finds the 'userData.txt file you saved
previously.

Fourth, in your defaultFolder, save a text file with the names of the stacks
the user may choose in the future, but use default names in case they don't
make the effort.

Hope this helps.

Jim Ault
Las Vegas






More information about the use-livecode mailing list