Digital Workshop

Welcome to the Digital Workshop Message Boards
It is currently December 23rd, 2024, 5:01 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: Detect whether an object exists
PostPosted: November 1st, 2006, 4:30 pm 
Offline

Joined: December 2nd, 2004, 4:03 pm
Posts: 56
Location: California, (USA)
Opus: Pro 7.6
OS: Vista 64
System: Vista 64, HP, 6GB RAM. Basically "Out of the box" with no special graphics. Very robust.
Hi There,

I use Opus Pro 5.5. I am a light user of Opus Script...

Opus Script generates an error if a given object does not exist; fair enough.... does anyone know a clever/simple way to determine whether an object exists on a page ?

I want to update a variable based on whether an object exists.

Presently, I can overcome the error by creating dummy/hidden objects, and this seems to work fine, but I'm hoping there is a more logical solution.

Thanks !
Steve Hawley


Top
 Profile Visit website  
 
 Post subject:
PostPosted: November 1st, 2006, 6:10 pm 
Offline

Joined: November 3rd, 2004, 2:11 pm
Posts: 323
I'm sure there's a more elegant/simpler method but I tried this and it works.

Put an onshow trigger on your object you want to check if exists. Drop in a Script action and in the script apply GetUniqueObjectID() to a variable.

Then when you want to update the variable, check to see if the variable containing the Object ID is empty. If it's empty, the object is either hidden or does not exist. Otherwise it's visible or exists and you can then update your variable accordingly.

Maybe this does what you want?

_________________
Opus Pro XE 9.1 Win7 64-bit Core i3 8MB RAM


Top
 Profile Visit website  
 
 Post subject: Detect whether an object exists
PostPosted: November 1st, 2006, 8:15 pm 
Offline

Joined: December 2nd, 2004, 4:03 pm
Posts: 56
Location: California, (USA)
Opus: Pro 7.6
OS: Vista 64
System: Vista 64, HP, 6GB RAM. Basically "Out of the box" with no special graphics. Very robust.
Hi There,

I understand your idea, however, in my case there is no object in which to add an 'on show' trigger.... therein lies the problem...

As an example:

I have a page with three image-objects. The user can left-click an image-object to goto another page. I use a script to goto the new page.

If I then make a duplicate copy of the original page, and eliminate one of the three image-objects, yet leave the script unchanged, the script will
generate an error message because one of the objects not longer exists.

Ideally, Opus Script would allow me to run a script only if the object exists.

========

I hope that is clear...smile...

Thanks,
Steve Hawley


Top
 Profile Visit website  
 
 Post subject:
PostPosted: November 1st, 2006, 9:50 pm 
Offline

Joined: November 3rd, 2004, 2:11 pm
Posts: 323
Any chance you could send me, or post, the IMP file?

_________________
Opus Pro XE 9.1 Win7 64-bit Core i3 8MB RAM


Top
 Profile Visit website  
 
 Post subject:
PostPosted: November 2nd, 2006, 10:14 am 
Offline

Joined: October 26th, 2004, 10:23 am
Posts: 666
Location: Digital Workshop
To be honest it sounds as though you are over-complicating the problem! Why not have simple "Goto Page" actions that go to the relevant places? Is the scripting necessary or just making life complicated?

Anyway, you could use the FindChild() function to look for the object, which will return a reference to the object if found or null if not.
Code:
Obj = MyPage.FindChild"Button1");
if (Obj)
{
  // Do actions on/with Obj or whatever
}

_________________
ddww Opus Developer


Top
 Profile Visit website  
 
 Post subject:
PostPosted: November 3rd, 2006, 6:22 pm 
Offline

Joined: December 2nd, 2004, 4:03 pm
Posts: 56
Location: California, (USA)
Opus: Pro 7.6
OS: Vista 64
System: Vista 64, HP, 6GB RAM. Basically "Out of the box" with no special graphics. Very robust.
Hi Duncan,

I'm not too sure how the 'goto' issue arose...

My desire is to be able to detect the existence of an object, and perform an action, using Opus Script; I can't seen an obvious way of doing it.

For example, say that I have 200 pages of text, and each page can have 0 to 5 images.

Whenever an image exists, it can be clicked to goto an associated page. I can manually add the "goto page", one-by-one, up to 1,000 times, or I can use a script on a style page, and do it once, and bypass hours of work.

The script is much more efficient, and an obvious time saver, especially when there are 100's of pages.

=============

My problem is, each page can have 0 to 5 image-objects, and my script requires that an object exist, or I get an error message when the script tries to run. If a given page has only one image, then the script will generate an error because it is expecting to find images 2,3,4, and 5.

My work-around solution, in the case, was to include empty/dummy/hidden images-objects on the style page where the script resides.

Since I'm not that familiar with Opus Script, I was just asking if there is a
clever way, using Opus Script, to use an If statement to determine if an object actually exists, and bypass further processing, and therefore the error message.

I think you are right.... this is really appearing to be more complicated than it really is...

All I need to know is if there is a way that I can use Opus Script to determine whether a object exists. And I think the answer is either 'no', or that there is an statement, or set of statements/functions that I can use.

Thanks for your help.

Steve hawley


Top
 Profile Visit website  
 
 Post subject:
PostPosted: November 3rd, 2006, 6:36 pm 
Offline

Joined: December 2nd, 2004, 4:03 pm
Posts: 56
Location: California, (USA)
Opus: Pro 7.6
OS: Vista 64
System: Vista 64, HP, 6GB RAM. Basically "Out of the box" with no special graphics. Very robust.
Hi Duncan,

Also, thanks for the example; I'll give it try...

Steve Hawley


Top
 Profile Visit website  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 43 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group