Omnis Studio - Multi Library Tasks
Stephane Pras
stephane.pras at noos.fr
Mon Jan 12 09:18:12 EST 2015
Hi Bastian,
I've been thinking of this kind of philosophical question from the very
beginning. In fact we have to options:
1. Creating a container MyLib task in which I open both LibA and LibB tasks,
which then will be operating in parallel the same as when they are running
alone, under the ruling of their own startup task.
2. Shutting down LibA and LibB startup tasks as soon as I open them, and
develop more coding in MyLib startup task for it to properly manage all
classes belonging to LibA or LibB. Then we will enter into the problems you
raise in your last paragraphs, i.e. making sure each class addresses the
proper task and file.
I made the (lazy ?) choice of (1) to avoid to much coding in MyLib. In fact
that library only displays a menu for opening/closing LibA or LibB, plus a
menu line I use to display the current situation on screen. Here is the
smart (…) coding for it :-)
OK message {Current Task is: [$ctask().$name]//Active Task is:
[$activetask().$name]//Current Data File is: [$cdata().$name] //Top Window
is: [sys(50)]}
This OK message can be used at any time to check which are the current task,
active task, current data file and top window. It confirms that when I click
a window, the active task changes accordingly, but not the data file.
I then concluded I must introduce a test on $activetask().$name (or use
$activate/$deactivate, or $suspend/$resume, as suggested by Brian) to
trigger the file change each time the active task changes. Something like:
If $activetask().$name = LibA
> Set current data file FileA
Else
> Set current data file FileB
End if
But I failed to find which event I could use to detect the active task
change and launch the test, and where to put it. I made many unsuccessful
trials at MyLib or LibA/LibB level, in $control, $event or $resume, using
evToTop or else. No clue yet.
Stephane
From: Bastiaan Olij <bastiaan at basenlily.me>
Reply-To: OmnisDev List - English <omnisdev-en at lists.omnis-dev.com>
Date: Sunday, January 11, 2015 11:31 PM
To: <omnisdev-en at lists.omnis-dev.com>
Subject: Re: Omnis Studio - Multi Library Tasks
Hey Stephane,
As you are starting each library with their own startup task active they
in essence become containers each with their own global state. This is
different from O7 days where all libraries shared the same global state.
The question you need to ask in your situation, do you want 3 startup tasks?
If MyLib is your primary library from which all the others start you can
change your code to only use the instance of it's startup task.
The rule in Omnis is very simple. Any class constructed within the
context of a task is part of that tasks global state regardless of the
library the class resides in.
Instead of telling Omnis to instantiate the startup task of each library
when those libraries are opened you can forego this and instead have
your own initialisation object within each library that you instantiate
from the main startup task.
Any menus you install on the menu bar will thus belong to the main task
Any window you open from those menus will belong to the main task
The only thing to be aware off is that Omnis doesn't realise which task
you've designated as your main task. When you CTRL-T to open a window to
test Omnis will always try to associate it with the task of the library
the window class is in which in your case will likely be the WRONG task
and thus lead to the window not behaving as expected.
In a multi library environment you thus need to be very careful in how
you open up windows, you need to make sure you open them up from places
the user will open them from to ensure the right task is associated with
the window instance.
While I don't use datafiles anymore I suspect this is at the core of
your issue. We do everything with SQL where a similar issue exists in
that my startup task encapsulates my database connection and if you open
up a window in a separate library the wrong way, you do not have direct
access to that connection.
Cheers,
Bas
On 12/01/2015 6:03 am, Stephane Pras wrote:
> I want to use two libraries LibA and LibB at the same time. I created a
> small library MyLib with two tasks LaunchA and LaunchB I use to open and
> close LibA and LibB at will. Of course I included in these tasks :
> "Do LibA.$autoactivate.$assign(kTrue)" and "Do
> LibB.$autoactivate.$assign(kTrue)"
>
> € When I open the first library (whichever it is) it runs fine as usual.
> € When I open the second one, it runs fine too.
>
> At this stage we have three open libraries in the Studio Browser (MyLib,
> LibA and LibB) with their respective datafiles FileA and FileB. Windows and
> Menus belonging both to LibA and LibB are on screen.
>
> Trouble is that when I click a Window belonging to the first opened library,
> it cannot access any record any more !!!
>
> € But when I close the second opened library, the first one resume normal
> operation at once ...
>
> It is clearly a datafile access problem. I tested $activetask() and $cdata()
> : it confirms the current data file doesn¹t change when the active task
> changes by clicking back on windows belonging to the first opened library.
>
> I need to insert some instruction ruling that. But I cannot figure out where
> and how to put it. I browsed manuals and archives without success, and made
> many unsuccessful trials. Any suggestion ?
>
> Thanks Š
>
> Stephane
>
>
> _____________________________________________________________
> Manage your list subscriptions at http://lists.omnis-dev.com
>
>
--
Kindest Regards,
Bastiaan Olij
e-mail: bastiaan at basenlily.me
web: http://www.basenlily.me
Skype: Mux213
http://www.linkedin.com/in/bastiaanolij
_____________________________________________________________
Manage your list subscriptions at http://lists.omnis-dev.com
More information about the omnisdev-en
mailing list