.Initialize procedure is delayed when file opened from procedure


#1

I have a database, Small mailing list whose .Initialize procedure contains just one statement:

openform "Test Form"

It is not open.

I have a second database, TestBed, from which I run this procedure:

local mfg_filnam, mfg_winnam
mfg_filnam = info("databasename")
mfg_winnam = info("windowname")
openfile "Small mailing list"
openfile mfg_filnam
window mfg_winnam
message "TestBed init completed"

When Small mailing list opens, its .Init procedure is not triggered until after the “TestBed init completed” message appears. This is a bother because I want the process to end up with the * mfg_winnam* window on top but I always end up with the “Test Form” window on top. Is this expected behaviour?

Some of you will be aware that my desktop Mac is seriously neurotic. This has become so annoying that, in desperation, I’ve bought a Macbook Pro to double-check all peculiar behaviour. It does the same as described above. If it’s also off its trolley, I’m going to be seriously annoyed.


#2

This is issue #626

https://bitbucket.org/jimrea/panoramax/issues/626/initialize-procedures-run-out-of-order


#3

Thanks Dave - I looked for an earlier post on the forum - should have checked the bucket also.

Is there a work-around? As it is, I can see no way to programmatically bring the mfg_winnam window to the front.


#4

This should work.

local mfg_filnam, mfg_winnam
mfg_filnam = info("databasename")
mfg_winnam = info("windowname")
opensecret "Small mailing list"
setactivedatabase "Small mailing list"
openform "Test Form"
//openfile mfg_filnam
window mfg_winnam
message "TestBed init completed"

You could also use

local mfg_filnam, mfg_winnam
mfg_filnam = info("databasename")
mfg_winnam = info("windowname")
opensecret "Small mailing list"
setactivedatabase "Small mailing list"
call .Initialize
//openfile mfg_filnam
window mfg_winnam
message "TestBed init completed"

#5

They both work - thanks Dave. I had to use the second one because my procedure won’t know the name of the form opened by the target database (indeed, it won’t even know whether there is a .Initialize procedure) so the code with the call .Initiallize is perfect - I just had to add an if error test after it.

When there’s no .Init and/or no form, the target d/b remains secret which I had thought might be a problem because the code I sent initially is triggered by a PopUp Button Object in my crosstab emulator. This goes on to save the d/b under another name and carry out lots of complex processing but everything works seamlessly - so far :slight_smile: