[SUGGESTION] If TAG exists

Support for iMacros. The iMacros software is the unique solution for automating every activity inside a web browser, for data extraction and web testing.
Forum rules
iMacros EOL - Attention!

The renewal maintenance has officially ended for Progress iMacros effective November 20, 2023 and all versions of iMacros are now considered EOL (End-of-Life). The iMacros products will no longer be supported by Progress (aside from customer license issues), and these forums will also no longer be moderated from the Progress side.

Thank you again for your business and support.

Sincerely,
The Progress Team

Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the search box (at the top of each forum page) to see if a similar problem or question has already been addressed.
3. Try searching the iMacros Wiki - it contains the complete iMacros reference as well as plenty of samples and tutorials.
4. We can respond much faster to your posts if you include the following information: CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST
Post Reply
coolcocky
Posts: 21
Joined: Tue Sep 01, 2009 8:45 pm

[SUGGESTION] If TAG exists

Post by coolcocky » Thu Jun 10, 2010 1:15 pm

Dear Danial / Hannes,

I would like to suggest an improvement to imacros, by adding conditional statement which should be easy to implement.

How about adding an "IF TAG.." statement followed with "END IF TAG.." where the statements between both these commands are executed if a particular tag exists otherwise imacros skips it. Also, commands like "ELSE IF TAG" can be incorporated which executes statements when the tag does not exist and if possible you can check suitability of nested ifs also.

This will greatly enhance the suitability of imacros

currently for doing it with scripting we have to send 3 macros to the open imacros window i.e.

1st macro do some work
2nd macro check if tag exists i.e. if tag is found
3rd send macro commands depending on the result of 2nd

and you can of course visualize the scenario where more than one if statements or nested if statements are required based on tag results.

hope this is feasibility for implementation as it increases the utility of imacros by a great extent.

regards,

CooooL

PS: Daniel I have posted source code of Imacros Testing Environment also just have a look
LSnelson
Posts: 17
Joined: Thu Jan 29, 2009 6:02 pm

Re: [SUGGESTION] If TAG exists

Post by LSnelson » Thu Jun 10, 2010 9:38 pm

I totally agree with this. A simple IF statement would make life easier for us.

Larry
Daniel, Tech Support
Posts: 1483
Joined: Tue Jan 26, 2010 11:35 am

Re: [SUGGESTION] If TAG exists

Post by Daniel, Tech Support » Fri Jun 18, 2010 11:27 am

Hi,

Thank you very much for the suggestion! I am sorry for only coming back to you now.

We are thinking of what we can do to add some control flow logic without creating a new complex programming language. And any ideas are very welcome! I will forward this one to our developers now.

Thanks again,
Daniel, iOpus Support
Daniel, Tech Support
Posts: 1483
Joined: Tue Jan 26, 2010 11:35 am

Re: [SUGGESTION] If TAG exists

Post by Daniel, Tech Support » Fri Jun 18, 2010 11:27 am

P.S. Thanks for the sources!!
Daniel, iOpus Support
coolcocky
Posts: 21
Joined: Tue Sep 01, 2009 8:45 pm

Re: [SUGGESTION] If TAG exists

Post by coolcocky » Fri Jun 18, 2010 7:42 pm

@Daniel

I should be the one thanking the whole imacros team for this great software, I have created a couple of bots using c# with imacros and its really easy as compared to doing a bot in c# alone

regards
Jonjozz
Posts: 2
Joined: Sat Aug 02, 2014 8:09 pm

Re: [SUGGESTION] If TAG exists

Post by Jonjozz » Sat Aug 02, 2014 8:18 pm

Use
ActiveDocument.SelectContentControlsByTag("XXXX").Count

if ActiveDocument.SelectContentControlsByTag("XXXX").Count = 0 (There is no Content Control tagged "XXXX")
if ActiveDocument.SelectContentControlsByTag("XXXX").Count = 1 (There is only one Content Control tagged "XXXX")
if ActiveDocument.SelectContentControlsByTag("XXXX").Count = 2 (There are two different Content Control tagged "XXXX")
... and so on.
Last edited by Jonjozz on Sat Aug 02, 2014 8:35 pm, edited 1 time in total.
Jonjozz
Posts: 2
Joined: Sat Aug 02, 2014 8:09 pm

Re: [SUGGESTION] If TAG exists

Post by Jonjozz » Sat Aug 02, 2014 8:31 pm

or then

Dim CC As ContentControls

' Get the collection of all content controls with this tag.
Set CC = ActiveDocument.SelectContentControlsByTag("Thing")

' If any content controls are found iterate through them and give the type.
If CC.Count = 0 Then ‘ The content control tagged "Thing" doesn´t exist.
If CC.Count = 1 Then ‘ There is only one content control tagged "Thing".
If CC.Count = 2 Then ‘ There are 2 different content control tagged "Thing".
… and so on
If CC.Count <> 0 Then ‘The content control tagged "Thing" exists (It could be one or more, but there is at least one Content Control tagged "Thing").
Post Reply