Sujit.
You can control where the default datafile is using build with xml keys…i hope
the following does not stray far from what you are trying to do….
I know that at one point I wanted to a make a downloadable single user demo
version of a product AND i wanted new client server builds to guide the
existing customers to open their correct current datafile.
Realising that ‘virgin’ users confronted with ‘open datafile’ dialogues will
wail in horror(and probably would end up creating a blank datafile) I did the
following:
1) You will see in the code i get the ‘current data file’. I do this pretty
much before anything else in my startup method-I don't know of any other way to
interrogate it other than within the code-the method i use allows switching to
another datafile on startup..(well not really on startup actually AFTER
startup).
In my startup method if the ‘wrong’ datafile is in use is don't do anything(i
am a fan of doing as little as possible at startup anyway).
While (Semaphore("$DuringLogin"))
DelayTicks
End while
If (DB_ControlDataFilePath )
CLEAR SEMAPHORE("$DuringLogin”)
//the correct datafile is in use carry on.
else
CLEAR SEMAPHORE("$DuringLogin")
//don't do anything just let startup end-see what DB_ControlDataFilePath does
to restart with the correct datafile.
end if
2) Using a build key strategy i made sure there default datafile inside my
package(not a good place to keep a datafile when someone overwrites the
package). This was the demo datafile I wanted users to use.
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<Preferences4D>
<BuildApp>
<BuildApplicationName>Database</BuildApplicationName>
<BuildWinDestFolder/>
<BuildMacDestFolder>::Database_Build:</BuildMacDestFolder>
<DataFilePath>:DemoData.4DD</DataFilePath>
Most of what i am doing here does not rely on the build with xml keys being
used(that was really for doing a distributable structure to potential customers
without having to go into complicated explanations about data-files)
3) On launch of the database I look for an invisible document that i create in
the users document folder(Other strategies may be used for this of course-it
would be better maybe if they were stored in for example 'Library/Application
Support’ on a Mac). In the document i stored the path to the ‘real’ datafile.
This meant that on first launch this document did not exist so it was created
and the user was asked where they would like to store the data(offering them
their document folder as a default). On that initial launch i then move the
datafile store from inside the package to that location and store the path in
the invisible document.
4) if the document exists then look to see if we are opening the last used
datafile and if not switch it(in single user mode) or ask in client server mode.
There are some nuances to the way you do this so I have posted a copy of the
code i use on my drop box
https://www.dropbox.com/s/j7vb6b6jgrfg5xq/DB_ControlDataFilePath.txt?dl=0
<https://www.dropbox.com/s/j7vb6b6jgrfg5xq/DB_ControlDataFilePath.txt?dl=0>
Feel free to come back with any questions-the code is kind of self explanatory
Nigel Greenlee
> On 16 Dec 2016, at 02:03, Sujit Shah <[email protected]> wrote:
>
> Does anyone know where 4D Stores the default Data file an application opens
> with?
>
> I know it opens the last Data file opened but where is this information
> stored?
>
> --
>
> xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> "There must be ingenuity as well as intention, strategy as well as
> strength. "
> **********************************************************************
> 4D Internet Users Group (4D iNUG)
> FAQ: http://lists.4d.com/faqnug.html
> Archive: http://lists.4d.com/archives.html
> Options: http://lists.4d.com/mailman/options/4d_tech
> Unsub: mailto:[email protected]
> **********************************************************************
**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ: http://lists.4d.com/faqnug.html
Archive: http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub: mailto:[email protected]
**********************************************************************