On Nov 15, 2016, at 12:43 PM, Timothy Penner <tpen...@4d.com> wrote:
> 
> Quote Jim:
>>> 4D needs to alter the startup mechanism to allow developers to write code 
>>> that 
>>> runs before the datafile is opened. This would allow a developer to much 
>>> more 
>>> easily do “the right thing”, which is to put the database (you know, with 
>>> data the 
>>> user can change) in the Documents or Application Support directories. 
>>> Alternatively, if the data is indeed fully static, then the embedded 
>>> datafile could 
>>> be opened in read-only mode.
> 
> Quote Bill: 
>> Agreed. This has been long-standing issue, even before the latest changes in 
>> OS strategies.
> 
> Actually, in v15.0 4D introduced the concept of the Default Data File. 
> 
> This feature was implemented in response to the feature request for 
> "New Database Event--On Before Opening Database":
> http://forums.4d.fr/Post/EN/6265711/1/6265712#6265712 <- request
> http://forums.4d.fr/Post/EN/6265711/1/6265712#16558316 <- implementation
> 
> more info: 
> http://livedoc.4d.com/4Dv15/4D/15/Data-file-management-in-final-applications.300-2964259.en.html
>  
> 
> ----
> Opening the data file  
> 
> When a user launches a merged application or an update (single-user or 
> client-server applications), 4D tries to select a valid data file. Several 
> locations are examined by the application successively.
> The opening sequence for launching a merged application is:
> 1) 4D tries to open the Last data file opened, as described below (not 
> applicable during initial launch).
> 2) If not found, 4D tries to open the data file in a default data folder next 
> to the .4DC file in read-only mode (new in 4D v15, described below).
> 3) If not found, 4D tries to open the standard default data file (same name 
> and same location as the .4DC file).
> 4) If not found, 4D displays a standard "Open data file" dialog box.
> ----
> 
> This allows you to include a read-only data file and write code to present 
> your own dialog using your own logic to ask the end user to select or create 
> a data file at the appropriate location, prior to / instead of  4D asking the 
> end user to open/select a data file.

So the pieces are kind of in place, but I just hadn’t connected the dots. 

However, you can’t call OPEN DATA FILE from the On Startup database method, or 
any method called by it. Is there a recommended way to run code after the On 
Startup method has finished? POST KEY to a special menu item in a special menu 
is kind of a kluge. If you call OPEN DATA FILE from a new process, does that 
process need to wait for On Startup to finish before calling OPEN DATA FILE? If 
so, will it be accurate enough to check process status of the main process? Or 
would we still have to start up whatever we are using for interprocess 
communication so that On Startup can tell the other process that it is 
finishing?

This would be a lot simpler if there was an option for the OPEN DATA FILE 
command that specified to abort all running code and don’t run On Shutdown.

Jim Crate

**********************************************************************
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:4d_tech-unsubscr...@lists.4d.com
**********************************************************************

Reply via email to