Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;Declaration
- Local $a_Block[rows][properties] ; an imported array of storage rows with each their own number of pallets and total space
- ;$a_block[row][0] = number of pallets stored in the storage row
- ;$a_block[row][1] = maximum storage spaces in this row
- Local $Total_space = 0
- Local $Number_of_pallets = 0
- Local $a_Rows_to_be_filled[UBound($a_Block, 1)]; declare an onedimensional array with same number of indices as the imported array
- ;/declaration
- For $i = 0 To UBound($a_Block, 1) - 1 ; for all rows in array $a_block
- $Total_space += $a_Block[$i][1] ; add the current row's total space to the total space
- $Number_of_pallets += $a_Block[$i][0] ; add current row's number of pallets to total number of pallets
- Next
- _ArraySort($a_Block, Default, Default, Default, 1)
- ; sort the array on maximum storage spaces, smallest first
- ;secondary sort all the rows with same number of maximum storage space by number of pallets stored with the biggest number of pallets first
- For $i = 0 To UBound($a_Block, 1) - 1 ; for all rows in array $a_block
- If ($Total_space - $Number_of_pallets) > $a_Block[$i][1] And $Number_of_pallets > 0 Then ; check if we can free up space by filling this row
- $a_Rows_to_be_filled[$i] = 1; set the local array so we know the row can be completly filled
- $Total_space -= $a_Block[$i][1] ; substract the filled row from maximum storage space
- $Number_of_pallets -= $a_Block[$i][1] ; subtract the number of pallets we used to fill that row
- Else
- $a_Rows_to_be_filled[$i] = 0
- ReDim $a_Rows_to_be_filled[$i]
- Break
- EndIf
- Next
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement