Solved

Managing Datawindow Image Print Order with Arrays

Posted on 2009-05-19
7
441 Views
Last Modified: 2013-12-26
Greetings All,

I am really torturing myself with trying to build an array to pass as an argument to a datawindow to print images where the argument is: image_id[].

First, I have one array as preferred_print_slots[] where I store preferred image id's.  An example would be:

preferred_print_slots[1] = 13
preferred_print_slots[6] = 10
preferred_print_slots[9] = 15
preferred_print_slots[12] = 21

The above are reserved print slots that need to be 'brought' over to another array.

Then I have an array called images_print_slots[] which I want to fill with X (let's say 12 images).

So I call a datawindow which retrieves maybe 20 images.

I want to loop through both arrays in such a way that I combine the results of the first array with the data coming from a datawindow so as to have a final array of 12 images that I can pass to another datawindow to print only those images.  We can discard any image id's where the final rowcount > 12.

The resulting image array should look like this:

image_print_slots[1] = 13 <--PREFERRED SLOT FROM preferred_print_slots[] ARRAY
image_print_slots[2] = 21
image_print_slots[3] = 20
image_print_slots[4] = 19
image_print_slots[5] = 18
image_print_slots[6] = 10 <--PREFERRED SLOT FROM preferred_print_slots[] ARRAY
image_print_slots[7] = 17
image_print_slots[8] = 16
image_print_slots[9] = 15 <--PREFERRED SLOT FROM preferred_print_slots[] ARRAY
image_print_slots[10] = 13
image_print_slots[11] = 11
image_print_slots[12] = 21 <--PREFERRED SLOT FROM preferred_print_slots[] ARRAY

I have included one of many different iterations of code.

I have tried looping through the preferred image id array first and then the rows containing image id's from the datawindow.  Then vice versa.

I generally end up with the image datawindow showing the first 4 rows from the preferred_print_slots array and then images from the datawindow.

Any assistance will sorely be appreciated!!!!!!!

I have some sample code below that does not work.  I have been re-working it back and forth so it is for illustration purposes only.

Thanks in advance!!!

PEM


long slotrows
		long s
		integer slotnumber
		long slot_image_id
		datastore setSlots
		setSlots = create datastore
		setSlots.dataobject = "dw_slots"
		setSlots.settransobject(sqlca)
		slotrows = setSlots.retrieve(image_provider_id)
		
		for s = 1 to slotrows
			slotnumber = setSlots.getitemnumber(s, "slot_number")
			slot_image_id = setSlots.getitemnumber(s, "image_id")
			slot_image_id_array[slotnumber] = slot_image_id
		next
 
		if rows > 0 then
			//FIRST PASS TO ASSIGN PREFERRED PROVIDER SLOTS
			messagebox("slot_image_id_array Current UpperBound","UpperBound is " + string(upperbound(slot_image_id_array)))
			messagebox("image_id Current UpperBound","UpperBound is " + string(upperbound(image_id)))
			//now fill out the array to match the required size
			long q
			for q = 1 to max_prints_per_print_job
				image_id[q] = 0
			next
			messagebox("image_id Current UpperBound","UpperBound is " + string(upperbound(image_id)))
 
			integer interation = 1
			
			long n
			for n = 1 to UpperBound(slot_image_id_array)
				for i = 1 to max_images_per_print_job
				
					ws_image_id = getImage.getitemnumber(i, "image_id")
				
						if image_id[n] = ws_image_id then
							preferred_slot = 'T'
							goto jumpout
						else
							preferred_slot = 'F'
						end if
						
				next
					jumpout:
					if preferred_slot = 'T' then
						//DO NOTHING - SLOT IS ALREADY SET CORRECTLY
					else
						interation =n + 1
						image_id[interation] = ws_image_id
						//image_id[i] = ws_image_id
					end if
				//next	
				preferred_slot = 'F'
			next
		end if
		
			long z
			for z = 1 to max_images_per_print_job
				messagebox("Images", string(image_id[z]))
			next

Open in new window

0
Comment
Question by:pemurray
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 2
7 Comments
 
LVL 14

Expert Comment

by:sandeep_patel
ID: 24428444
If I understand your problem correctly, I think this is what you need. Also attached the sample example with your data in code snippet.

integer slot_image_id_array[]
integer slot_image_id_number[]
integer i

for s = 1 to slotrows
   slotnumber = setSlots.getitemnumber(s, "slot_number")
   slot_image_id = setSlots.getitemnumber(s, "image_id")
   slot_image_id_array[s] = slot_image_id
   slot_image_id_number[s] = slotnumber
next

for q = 1 to max_prints_per_print_job
   for s = 1 to upperbound(slot_image_id_number)
      if slot_image_id_number[s] = q then
         image_id[q] = slot_image_id_array[s]
      end if
   next
next

i = 1
for q = 1 to max_prints_per_print_job
   ws_image_id = getImage.getitemnumber(i, "image_id")
   If image_id[q] = 0 Then
      image_id[q] = ws_image_id
      i = i + 1
   End If
next

Regards,
Sandeep
integer slot_image_id_array[]
integer slot_image_id_number[]
integer ws_image_id, getimage[],image_id[]
integer i,q,max_prints_per_print_job,s
 
max_prints_per_print_job= 12
 
slot_image_id_array[1] = 13
slot_image_id_array[2] = 10
slot_image_id_array[3] = 15
slot_image_id_array[4] = 21
 
slot_image_id_number[1] = 1
slot_image_id_number[2] = 6
slot_image_id_number[3] = 9
slot_image_id_number[4] = 12
 
getimage[1] = 4
getimage[2] = 8
getimage[3] = 12
getimage[4] = 16
getimage[5] = 20
getimage[6] = 24
getimage[7] = 28
getimage[8] = 32
getimage[9] = 36
getimage[10] = 40
getimage[11] = 44
getimage[12] = 48
getimage[13] = 52
getimage[14] = 56
getimage[15] = 60
 
 
for q = 1 to max_prints_per_print_job
   for s = 1 to upperbound(slot_image_id_number)
      if slot_image_id_number[s] = q then
         image_id[q] = slot_image_id_array[s]
      end if
   next
next
 
i = 1
for q = 1 to max_prints_per_print_job
   ws_image_id = getimage[i]
   If image_id[q] = 0 Then
      image_id[q] = ws_image_id
      i = i + 1
   End If
   messagebox('',string(image_id[q]))
next

Open in new window

0
 

Author Comment

by:pemurray
ID: 24437468
Thanks Sandeep,

I made some progress, but am still having trouble.  Perhaps, I should have pointed out that the reserved images can also show up on the regular images.

So I have the following reserved slots:

slot_image_id_array[1] = 30
slot_image_id_array[2] = 31
slot_image_id_array[3] = 32
slot_image_id_array[4] = 33
 
slot_image_id_number[1] = 1
slot_image_id_number[2] = 6
slot_image_id_number[3] = 9
slot_image_id_number[4] = 12

and I am filling getimage[] as follows:

getimage[1] = 33
getimage[2] = 31
getimage[3] = 30
getimage[4] = 32
getimage[5] = 28
getimage[6] = 25
getimage[7] = 24
getimage[8] = 22
getimage[9] = 26
getimage[10] = 21
getimage[11] = 23
getimage[12] = 29
getimage[13] = 27
getimage[14] = 20

Right now I end up with the following from your messagebox as follows:

slot 01 = 30
slot 02 = 33
slot 03 = 31
slot 04 = 30
slot 05 = 32
slot 06 = 31
slot 07 = 28
slot 08 = 25
slot 09 = 32
slot 10 = 24
slot 11 = 22
slot 12 = no messagebox displays

When I view the final image[] array, it does show the same information with the final slot 12 = 33.

slot 01 = 30 <-- RESERVED (CORRECT)
slot 02 = 33 <-- THIS SHOULD ONLY SHOW IN SLOT 12
slot 03 = 31 <-- THIS SHOULD ONLY SHOW IN SLOT 6
slot 04 = 30 <-- THIS SHOULD ONLY SHOW IN SLOT 1
slot 05 = 32 <-- THIS SHOULD ONLY SHOW IN SLOT 9
slot 06 = 31 <-- RESERVED (CORRECT)
slot 07 = 28 <-- THIS SHOULD SHIFT UP TO SLOT 2
slot 08 = 25 <-- THIS SHOULD SHIFT UP...
slot 09 = 32 <-- RESERVED (CORRECT)
slot 10 = 24 <-- THIS SHOULD SHIFT UP...
slot 11 = 22 <-- THIS SHOULD SHIFT UP...
slot 12 = 33 <-- RESERVED (CORRECT)

If you can point out where to eliminate the duplicates so that everything shifts up that would be great!!!

Thanks again Sandeep!!

PEM
//fill the image_id array with the image id's from offer_slots
		long slotrows
		long s
		integer slotnumber
		long slot_image_id
		datastore setSlots
		setSlots = create datastore
		setSlots.dataobject = "dw_slots"
		setSlots.settransobject(sqlca)
		slotrows = setSlots.retrieve(image_provider_id)
		
		for s = 1 to slotrows
			slotnumber = setSlots.getitemnumber(s, "slot_number")
			slot_image_id = setSlots.getitemnumber(s, "image_id")
			slot_image_id_array[s] = slot_image_id
			slot_image_id_number[s] = slotnumber
		next
 
long rows
		datastore getImages
		getImages = create datastore
		getImages.dataobject = "dw_ws_getimages"
		getImages.settransobject(sqlca)
		rows = getImages.retrieve(arguments...)
		
		long q
		if rows > 0 then
			
			for q = 1 to rows
				getimage[q] = getImages.getitemnumber(q, "image_id")
			next
			
			for q = 1 to max_offers_per_print_job
				for s = 1 to upperbound(slot_image_id_number)
					if slot_image_id_number[s] = q then
						image_id[q] = slot_image_id_array[s]
					end if
				next
			next
			 
			i = 1
			for q = 1 to max_offers_per_print_job
				ws_image_id = getimage[i]
				If image_id[q] = 0 Then
					image_id[q] = ws_image_id
					i = i + 1
				End If
				messagebox('',string(image_id[q]))
			next

Open in new window

0
 
LVL 14

Accepted Solution

by:
sandeep_patel earned 500 total points
ID: 24438056
Here you go!!!

integer slot_image_id_array[]
integer slot_image_id_number[]
integer i
string ls_reserved

ls_reserved = ''
for s = 1 to slotrows
   slotnumber = setSlots.getitemnumber(s, "slot_number")
   slot_image_id = setSlots.getitemnumber(s, "image_id")
   slot_image_id_array[s] = slot_image_id
   slot_image_id_number[s] = slotnumber
   ls_reserved = ls_reserved + string(slot_image_id) + ','
next

for q = 1 to max_prints_per_print_job
   for s = 1 to upperbound(slot_image_id_number)
      if slot_image_id_number[s] = q then
         image_id[q] = slot_image_id_array[s]
      end if
   next
next

i = 1
q = 1
do while q <= max_prints_per_print_job
   ws_image_id = getImage.getitemnumber(i, "image_id")
   If pos(ls_reserved,string(ws_image_id)) > 0 Then
            i = i + 1
            continue
   End If
   If image_id[q] = 0 Then
      image_id[q] = ws_image_id
      i = i + 1
   End If
   messagebox('',string(image_id[q]))
   q = q + 1      
loop


Regards,
Sandeep
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 14

Expert Comment

by:sandeep_patel
ID: 24438069
and this is with your sample data. previous post is the actual code where it's populating data in array and this is an example where array already has data.

integer slot_image_id_array[]
integer slot_image_id_number[]
integer ws_image_id, getimage[],image_id[]
integer i,q,max_prints_per_print_job,s

string ls_reserved

max_prints_per_print_job= 12

slot_image_id_array[1] = 30
slot_image_id_array[2] = 31
slot_image_id_array[3] = 32
slot_image_id_array[4] = 33

slot_image_id_number[1] = 1
slot_image_id_number[2] = 6
slot_image_id_number[3] = 9
slot_image_id_number[4] = 12

getimage[1] = 33
getimage[2] = 31
getimage[3] = 30
getimage[4] = 32
getimage[5] = 28
getimage[6] = 25
getimage[7] = 24
getimage[8] = 22
getimage[9] = 26
getimage[10] = 21
getimage[11] = 23
getimage[12] = 29
getimage[13] = 27
getimage[14] = 20

ls_reserved = '30,31,32,33'

for q = 1 to max_prints_per_print_job
   for s = 1 to upperbound(slot_image_id_number)
      if slot_image_id_number[s] = q then
         image_id[q] = slot_image_id_array[s]
      end if
   next
next

i = 1
q = 1
do while q <= max_prints_per_print_job
   ws_image_id = getimage[i]
   If pos(ls_reserved,string(ws_image_id)) > 0 Then
            i = i + 1
            continue
   End If
   If image_id[q] = 0 Then
      image_id[q] = ws_image_id
      i = i + 1
   End If
   messagebox('',string(image_id[q]))
   q = q + 1      
loop

Regards,
Sandeep
0
 
LVL 14

Expert Comment

by:sandeep_patel
ID: 24438085
you might need to change do while condition little bit in case if you have both reserved and getimage array same. in this case change do while to

do while (q <= max_prints_per_print_job) and (i <= max_prints_per_print_job)
0
 

Author Closing Comment

by:pemurray
ID: 31583293
Thank you, Sandeep!!!  My head was spinning a bit on that one.  I am still fuzzy on your last comment and will have to experiment with different scenarios.

Also, I pass the array to my datawindow as a retrieval argument and I 'thought' it would display the images in the same order, but I find that is not the case.  I have no sort order on the dw so I will have to experiment with that as well.

Thanks VERY much!!!

PEM
0
 
LVL 14

Expert Comment

by:sandeep_patel
ID: 24441687
Not sure how you are displaying images in datawindow but I am sure you can set the order in your datawindow. There must be workaround for that too... Let me know how you display the images in your datawindow

OR

attach your datawindow here.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
How to install Selenium IDE and loops for quick automated testing. Get Selenium IDE from http://seleniumhq.org Go to that link and select download selenium in the right hand columnThat will then direct you to their download page.From that page s…
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question