pemurray
asked on
Managing Datawindow Image Print Order with Arrays
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
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
ASKER
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
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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_j ob,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_n umber)
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
integer slot_image_id_array[]
integer slot_image_id_number[]
integer ws_image_id, getimage[],image_id[]
integer i,q,max_prints_per_print_j
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_n
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_
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
q = q + 1
loop
Regards,
Sandeep
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)
do while (q <= max_prints_per_print_job) and (i <= max_prints_per_print_job)
ASKER
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
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
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.
OR
attach your datawindow here.
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_n
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
Open in new window