Hi Klaus (again),
this is some of the biggest block. I am merge some SQL outputs different times to create a laaaaarge variable.
I am starting with the Order IDs from t_array["vBestellnummer"] to get a list with all existing Order IDs. Then, in the first section, I am matching each line of s_array["vSendungsnummern"] and find the right ID which a matching to create a new variable (v_order).
The selects are always the same:
ID TAB TrackingID (or if paid, or name, surname etc)
I THINK the Problem is that it is very heavy to calculate this again and again... Maybe we can make this faster (and shorter).
Code: Select all
####### SECTION 1
put t_array["vBestellnummer"] into tNames
put s_array["vSendungsnummern"] into tIds
#Example t_array["vBestellnummer"]
#AU123
#AU456
#AU789
#Example s_array["vSendungsnummern"]
# AU123 A123
# AU456 B456
set itemdel to TAB
## Loop through all NAME pairs
repeat for each line tLine in tNames
put item 1 of tLine & TAB into tItem
put lineoffset(tItem,tIds) into tOffset
## No match, modify this line if you want to add an empty ITEM
## to the current NAME line or whatever you want to do in that case
if tOffset = 0 then
put tab into item 2 of line tOffset of tIds
put tLine & TAB & item 2 of line tOffset of tIds & CR after v_order
next repeat
else
## repeat for each is READ only, so we just create a new list form the resulting data:
put tLine & TAB & item 2 of line tOffset of tIds & CR after v_order # [b]<- This is the Target for section 1[/b]
end if
end repeat
delete char -1 of v_order
######### RESULT:
# AU123 A123
# AU456 B456
######################################## Next Section: Match if DHL, DPD...
####### SECTION 2
#Example t_array["vVersandart2"]
#AU123 DHL
#AU456 DPD
#AU789 GLS
#Example v_order (result from the 1st section)
# AU123 DHL123
# AU456 DHL456
put v_order into tNames
put t_array["vVersandart2"] into tIds
set itemdel to TAB
## Loop through all NAME pairs
repeat for each line tLine in tNames
put item 1 of tLine & TAB into tItem
put lineoffset(tItem,tIds) into tOffset
## No match, modify this line if you want to add an empty ITEM
## to the current NAME line or whatever you want to do in that case
if tOffset = 0 then
next repeat
else
## repeat for each is READ only, so we just create a new list form the resulting data:
put tLine & TAB & item 2 of line tOffset of tIds & CR after v_order2 # [b]<- This is the Target for section 2[/b]
end if
end repeat
delete char -1 of v_order2
######### RESULT:
# AU123 A123 DHL
# AU456 B456 DPD
######################################## Next Section: Match if paid
####### SECTION 3
#Example t_array["paid"]
#AU123 yes
#AU456 no
#AU789 no
#Example v_order2 (result from the 2st section)
# AU123 DHL123 A123
# AU456 DHL456 B456
# (..) with v_order3, v_order4, v_order5, v_order6