PDA

View Full Version : Loop inside Loop logic


akki
10-18-2003, 16:05
Hi,
I have 2 stringlist in the pipeline strList1 and strList2. I want to loop over this strlist one inside the other in such a so that I can do 1-to-1 mapping of values in this srtlist.
This is what I am doing.
1st loop/strList1 (Name1, Name2, Name3)
do something
2nd loop/strList2 (Name11, Name22, Name33)
do something
Map Name1 - Name11

I want to Map Name1 - Name11, Name2 - Name22, Name3 - Name33 and so on.
Does somebody knows how we can implement this logic.

Thanks for the help.
Akshay

chrisl
10-18-2003, 19:45
Have your tried using StrList1 as the input array and strList2 as the output array for the loop?
I think that should do what you want.

HTH

akki
10-20-2003, 09:56
Hi Chris,
When I am looping over loop2 for the first time then I want to map only Name11 value and need to exit so that the control goes to Loop1. When I 2nd time loop over loop2, I want Name22 only and again need to exit. I need to repeate the same till I map all the values.
I hope I clarified my problem.
Could you explain me in detail how we can do this.

Thanks
Akshay.

mcarlson
10-20-2003, 12:35
Akshay,

Are you using StrList2 as a lookup table of sorts? In other words are you trying to find the value of the string from StrList1 inside StrList1 and then do something? If so, a couple of alternatives related to recordLists were discussed here: http://www.wmusers.com/wmusers/messages/117/21992.shtml

If you always want to set the string in the current element n of StrList1 to the value of the same element n in StrList2, you can do that with a map statement that sets the value of your StrList1 string to <font color="0000ff">%StrList2[myCounter]%</font>, where <font color="0000ff">myCounter</font> is set to the value of <font color="0000ff">$iteration - 1</font> (using the pub.math:subtractInts service).

Can you clarify what you are trying to do?

Mark

guest (Unregistered Guest)
10-20-2003, 14:14
Mark,

Have you actually used it? I was trying something similar and variable substitution with index like, %Array[index]%, just doesn't work for me. Am I missing something here. BTW, I am using IS4.6

RMG (Unregistered Guest)
10-20-2003, 14:41
if you looking for loop index and want to use dynamic increment you can use the $iterate pipeline variable(which will be inside the loop step).
And do a variable substitution %iteration% (on Branch or sequence).


HTH.

akki
10-20-2003, 14:42
Mark,
Here is what I want to do.

In the first Iteration:
loop-1/strList1 (Name1, Name2, Name3)
do something
loop-2/strList2 (Name11, Name22, Name33)
do something
*******get the first value of strList2 (Name11)
end Loop-2

end Loop-1

In the 2nd Iteration:
loop-1/strList1 (Name1, Name2, Name3)
do something
loop-2/strList2 (Name11, Name22, Name33)
do something
*******get the second value of strList2 (Name22)
end Loop-2

end Loop-1

I am not able to do ******* part in my logic.

Could you please let me know how this can be implemented.

Thanks
Akshay

guest (Unregistered Guest)
10-20-2003, 15:07
I am not sure I understand correctly. Are you suggeting I create a separate branch sequence for each possible value of $iteration and assign the corresponding Array element inside that Branch.

mcarlson
10-20-2003, 17:08
My earlier post was incorrect. I apologize for the bad info.

It is possible to directly reference a string or record contained in a stringList or recordList, but not using the solution I gave.

Use the pub.list:getListItem to do this. Since array elements are numbered beginning with 0 and loop iterations are numbered beginning at 1, you need to use the pub.math:subtractInts service to set a varable (index) to $iteration - 1. Map this value to the index parameter of the pub.list:getListItem service (mapping StrList2 to its list parameter).

The attached package contains a single service which illustrates what *I think* Akshay is attempting to do (still not clear on this).


http://www.wmusers.com/wmusers/icons/mime_zip.gifWMUsersExamples.Zip package (Copy to your IS server's /replicate/inbound folder and load with the Admin tool's "Install Inbound Releases" function.
WMUsersExamples.zip (http://www.wmusers.com/wmusers/messages/117/WMUsersExamples-25809.zip) (3.3 k)


HTH,

Mark

akki
10-20-2003, 19:26
Thanks Mark for the help.
This is what I am looking for.
But I am using wm 6.0 in which pub.list:getListItem is deprecated.
Do we have some alternate service for this in 6.0.

Thanks' for your help
Akshay.

wkriski
10-20-2003, 19:49
Hi Akshay - you should take some time to read the built-in services guide and other pdf's, however the service you probably want is pub.list:getRecordListItem for 6.0.

Good luck!

mcarlson
10-20-2003, 20:02
The IS 6.0 release notes indicate that there is no replacement service for the pub.list.getListItem servic, but that <font color="0000ff">"you can achieve the old services' functionality by using the Pipeline Editor to link items and specify array indexes in Link Properties."</font>

My IS 6.0 server is down just now, but I'll attempt to test this tomorrow.

BTW, a list of services deprecated in WM 6.0 can be found here:
http://www.wmusers.com/wmusers/messages/6855/IS_6_0_Deprecated_Built-In_Services_v1_1-15278.xls

-M

mcarlson
10-20-2003, 20:44
Developer 6.0 allows you to specify a variable name (enclosed with '%' characters) on the Indexing tab of the Link Properties dialog. You access the Link Properties dialog by double-clicking on the line connecting your source and target variables. When the source or target variables are lists (string or record) you can specify an index value. In IS 4.6, this could only be an integer and could not be a variable.


The attached package contains an example of this that works for IS 6.0.

http://www.wmusers.com/wmusers/icons/mime_zip.gifIS 6.0 Mapping Example
WMUsersExamples60.zip (http://www.wmusers.com/wmusers/messages/117/WMUsersExamples60-25815.zip) (7.2 k)


Regards,

Mark

akki
10-21-2003, 10:47
Thanks Mark and thanks to all for the help.
This worked perfectly for me.

Akshay

hope
06-25-2007, 10:59
Thanks for all the help Mark. Just faced the prob and your reply post helped me solving.

arulchristhuraj
06-25-2007, 23:25
* For pub.list services without replacement services, you can achieve the old services' functionality by using the Pipeline Editor to link items and specify array indexes in Link Properties.

pub.list:appendToRecordList pub.list:appendToDocumentList
pub.list:stringListToRecordList pub.list:stringListToDocumentList
pub.list:copyListItem No replacement services. See *.
pub.list:getListItem No replacement services. See *.
pub.list:getRecordListItem No replacement services. See *.
pub.list:getStringListItem No replacement services. See *.
pub.list:setListItem No replacement services. See *.
pub.list:setRecordListItem No replacement services. See *.
pub.list:setStringListItem No replacement services. See *.