'how to get Imacros to click on a specific thing in a loop

I have a site that I want to refresh in a loop until it shows a specific text, then when it does, click on a button (with the text on it) and then stop the loop.

as for now I have this V

VERSION BUILD=1011 RECORDER=CR
*finding the site and going where it needs*
SET !ERRORIGNORE YES
TAG POS=2 TYPE=SPAN ATTR=TXT:
var G_Extract= iimGetLastExtract(1);
if (G_Extract=="No<SP>available<SP>dates<SP>found*") <- the text I need to find
{
*click on button*
*stop the loop*
}
if else (*something else (not the text I want) appears*)
{
*continue the loop from the start until it shows that text*
}

is there any way to do that? I searched for hours...

if someone can write only that part where it clicks on the text "No available dates found" and stops the loop it will be great, thanks <3



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source