ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Breaking or Continuing a Loop in WMQI 2.1

Post new topic  Reply to topic
 Breaking or Continuing a Loop in WMQI 2.1 « View previous topic :: View next topic » 
Author Message
cadenza
PostPosted: Mon Sep 20, 2004 10:20 pm    Post subject: Breaking or Continuing a Loop in WMQI 2.1 Reply with quote

Apprentice

Joined: 01 Jun 2004
Posts: 48

Dear All,

Is there a keyword / method through which I can break from the loop or continue a loop?

I am using WMQI 2.1 , CSD 07.

Thanks.
Back to top
View user's profile Send private message
kirani
PostPosted: Mon Sep 20, 2004 10:28 pm    Post subject: Reply with quote

Jedi Knight

Joined: 05 Sep 2001
Posts: 3779
Location: Torrance, CA, USA

Have you looked at the WHILE statement.

Code:

DECLARE MYVAR BOOLEAN TRUE;
While (MYVAR)
....
....
....
....
if ( exit_loop) THEN
  SET MYVAR = FALSE;
END IF;
END WHILE;


_________________
Kiran


IBM Cert. Solution Designer & System Administrator - WBIMB V5
IBM Cert. Solutions Expert - WMQI
IBM Cert. Specialist - WMQI, MQSeries
IBM Cert. Developer - MQSeries

Back to top
View user's profile Send private message Visit poster's website
cadenza
PostPosted: Mon Sep 20, 2004 10:42 pm    Post subject: Reply with quote

Apprentice

Joined: 01 Jun 2004
Posts: 48

Hi Kiran,

Thanks for your reply.

I have used such a logic before. But the problem at hand is

while(condition)

...
...

break or continue condition

...
...

end while.

How do I deal with this?
Back to top
View user's profile Send private message
cadenza
PostPosted: Mon Sep 20, 2004 10:50 pm    Post subject: Reply with quote

Apprentice

Joined: 01 Jun 2004
Posts: 48

Hi ,

Adding to my previous post.

The break or continue condition may be misleading.

Actually I have to decide on 3 conditions there:

Either I break , Or I continue (i.e. the loop restarts with updated counter) , or I proceed normally to the next statement.

So, in reality it is a 3 way branching.

Also the while indicated is within 5-6 levels of loops. I am looking for a suitable optimum method.

Thanks.
Back to top
View user's profile Send private message
mgk
PostPosted: Tue Sep 21, 2004 12:04 am    Post subject: Reply with quote

Padawan

Joined: 31 Jul 2003
Posts: 1642

Hi,


I can't rememver what version they were introduced in, but the statements you are looking for are CONTINUE and LEAVE, possible with a labled on the loop. This is certainly in V5, but I'm not sure about earlier. If not you could always be really ugly and put the part of the while loop you need to skip in an IF statement...

Cheers,
_________________
MGK
The postings I make on this site are my own and don't necessarily represent IBM's positions, strategies or opinions.
Back to top
View user's profile Send private message
cadenza
PostPosted: Tue Sep 21, 2004 1:38 am    Post subject: Reply with quote

Apprentice

Joined: 01 Jun 2004
Posts: 48

Hi,

I tried the following:

SET I = 1;
WHILE ( I < 10 ) DO

IF ( I = 3 ) THEN

LEAVE; / BREAK; / CONTINUE;

END IF;

SET I = I + 1;

END WHILE;

In all the above 3 cases I received a Syntax Error notation indicating that WMQI could not recognize it.

So, I believe I have run out of luck this time.

Thanks.
Back to top
View user's profile Send private message
mgk
PostPosted: Tue Sep 21, 2004 2:19 am    Post subject: Reply with quote

Padawan

Joined: 31 Jul 2003
Posts: 1642

Hi, So the CONTINUE / LEAVE is V5 only (BREAK is not part of ESQL)

but what (apart from being ugly) is wrong with:

SET I = 1;
WHILE ( I < 10 ) DO

IF ( I = 3 ) THEN
SET I = 10;
ELSE
-- other code here
SET I = I + 1;
END IF;
END WHILE;


or, even:

Or something similar:

DECLARE test BOOLEAN TRUE;
WHILE ( test ) DO

IF ( somecondition ) THEN
SET test = FALSE;
ELSE
-- other code here
END IF;
END WHILE;
_________________
MGK
The postings I make on this site are my own and don't necessarily represent IBM's positions, strategies or opinions.
Back to top
View user's profile Send private message
Missam
PostPosted: Tue Sep 21, 2004 6:08 am    Post subject: Reply with quote

Chevalier

Joined: 16 Oct 2003
Posts: 424

This can be acheived by adding a flag to your control.
like kirani suggested

Code:
While (i < number and flag = true) do
--
--
--
if (condition) then
set flag = flase;
end if

--
--
end while;
Back to top
View user's profile Send private message
kirani
PostPosted: Tue Sep 21, 2004 1:08 pm    Post subject: Reply with quote

Jedi Knight

Joined: 05 Sep 2001
Posts: 3779
Location: Torrance, CA, USA

cadenza,

What version of CSD are you using? I think these statements (CONTINUE, LEAVE, ..) are introduced in CSD3/4 of WMQI.
_________________
Kiran


IBM Cert. Solution Designer & System Administrator - WBIMB V5
IBM Cert. Solutions Expert - WMQI
IBM Cert. Specialist - WMQI, MQSeries
IBM Cert. Developer - MQSeries

Back to top
View user's profile Send private message Visit poster's website
mgk
PostPosted: Tue Sep 21, 2004 1:25 pm    Post subject: Reply with quote

Padawan

Joined: 31 Jul 2003
Posts: 1642

Hi cadenza,

I suspect that kirani maybe right, and I also noticed a syntax error in the code you posted. The LEAVE and CONTINUE statements require a label like this:

myLoop: WHILE ( I < 10 ) DO
SET OutputRoot.XML.Top.Result.i[I] = I;
IF I = 3 THEN
LEAVE myLoop;
END IF;
SET I = I + 1;
END WHILE myLoop ;

Cheers,
_________________
MGK
The postings I make on this site are my own and don't necessarily represent IBM's positions, strategies or opinions.
Back to top
View user's profile Send private message
cadenza
PostPosted: Wed Sep 22, 2004 2:56 am    Post subject: Reply with quote

Apprentice

Joined: 01 Jun 2004
Posts: 48

Hi All,

Thanks for your reply.

The LEAVE myLoop; doesnt give any syntax error. Unfortunately if I replace the statement with CONTINUE myLoop; then it shows syntax error.

So, could you please tell me how to use CONTINUE.

By the way the WMQI version is

Version: 530.7 CSD07

Thanks.[/quote]
Back to top
View user's profile Send private message
kirani
PostPosted: Wed Sep 22, 2004 7:07 am    Post subject: Reply with quote

Jedi Knight

Joined: 05 Sep 2001
Posts: 3779
Location: Torrance, CA, USA

Do you get syntax error in Editor or when doing a deploy. If it's in the editor then I'd suggest try deploying the message flows.
_________________
Kiran


IBM Cert. Solution Designer & System Administrator - WBIMB V5
IBM Cert. Solutions Expert - WMQI
IBM Cert. Specialist - WMQI, MQSeries
IBM Cert. Developer - MQSeries

Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Breaking or Continuing a Loop in WMQI 2.1
Jump to:  



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 vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.