QSA-interest Archive, January 2006
check for existance of an object in QScript
Message 1 in thread
Hi QSA-fans ;) ...
Does anybody knows how to check for existance of an object in QScript?
My app adds objects to a QSProject on run-time depending on the user.
For example it adds a "currentView"-Object if a MDIWindow with a 3DView is
activated by the user.
Now I want to write a script to zoom in that 3DView when the user clicks into
the window. Everthing works fine as long as there is a "currentView"-Object
(the MDIWindow exists).
But if the user hasn´t opend a 3DView my script fails because it depends on an
existing "currentView" member: I tried to check for the existance of
"currentView" in QScript like this:
if(Application.currentView)
and like this:
if(Application.currentView != undefined)
but it doesn´t work.
Even though currentView does not exists these lines are always true :(
Any ideas?
Greetings
Jens
To unsubscribe - send "unsubscribe" in the subject to qsa-interest-request@xxxxxxxxxxxxx
Message 2 in thread
Jens-
Maybe this will work?
function currentViewExists() {
try {
Application.currentView;
return true;
} catch (e) {
return false;
}
}
-Joel
On Jan 4, 2006, at 12:14 PM, Jens G. wrote:
> Hi QSA-fans ;) ...
>
> Does anybody knows how to check for existance of an object in QScript?
>
> My app adds objects to a QSProject on run-time depending on the user.
> For example it adds a "currentView"-Object if a MDIWindow with a
> 3DView is
> activated by the user.
> Now I want to write a script to zoom in that 3DView when the user
> clicks into
> the window. Everthing works fine as long as there is a
> "currentView"-Object
> (the MDIWindow exists).
>
> But if the user hasn´t opend a 3DView my script fails because it
> depends on an
> existing "currentView" member: I tried to check for the existance of
> "currentView" in QScript like this:
> if(Application.currentView)
> and like this:
> if(Application.currentView != undefined)
> but it doesn´t work.
> Even though currentView does not exists these lines are always true :(
>
> Any ideas?
>
> Greetings
> Jens
>
> To unsubscribe - send "unsubscribe" in the subject to
> qsa-interest-request@xxxxxxxxxxxxx
To unsubscribe - send "unsubscribe" in the subject to qsa-interest-request@xxxxxxxxxxxxx
Message 3 in thread
Joel Nordell wrote:
> Jens-
>
> Maybe this will work?
>
> function currentViewExists() {
> try {
> Application.currentView;
> return true;
> } catch (e) {
> return false;
> }
> }
>
> -Joel
Actually, the simplest is
if ("currentView" in Application)
// do stuff with currentView
else
// do nothing...
Best regards,
Gunnar
To unsubscribe - send "unsubscribe" in the subject to qsa-interest-request@xxxxxxxxxxxxx
Message 4 in thread
Thanks ...
That works fine.
Greetings
Jens
Am Freitag, 6. Januar 2006 09:54 schrieb Gunnar Sletta:
> Joel Nordell wrote:
> > Jens-
> >
> > Maybe this will work?
> >
> > function currentViewExists() {
> > try {
> > Application.currentView;
> > return true;
> > } catch (e) {
> > return false;
> > }
> > }
> >
> > -Joel
>
> Actually, the simplest is
>
> if ("currentView" in Application)
> // do stuff with currentView
> else
> // do nothing...
>
> Best regards,
> Gunnar
>
> To unsubscribe - send "unsubscribe" in the subject to
> qsa-interest-request@xxxxxxxxxxxxx
To unsubscribe - send "unsubscribe" in the subject to qsa-interest-request@xxxxxxxxxxxxx