Sorting Problem (OpenInsight 32-Bit)
At 16 NOV 2008 09:18:40PM Chee Onn Wu wrote:
i got an array with @FM and @VM .
Example.
array=a long list of document date with @vm delimited
array=a long list of document number with @vm delimited
array=a long list of customer code with @vm delimited
array=other detail with @vm delimited
…till array
Now i want to sort the array base on Document date then Document No using V119.
i am using the following method to convert the array into the format that V119 needed.
FOR ROW_P=1 TO ROW_COUNT
FOR COL_P=1 TO COLUMN_COUNTNew_array=arrayNEXT COL_PNEXT ROW_P
SWAP @FM WITH @RM IN new_array
SWAP @VM WITH @FM IN new_array
This is work but the problem is dynamic array is slow when the data grow.
Is there a better way to convert the array into new_array? So that it could run faster.
At 17 NOV 2008 03:51AM [url=http://www.sprezzatura.com]The Sprezzatura Group[/url] wrote:
See http://www.revelation.com/Revelation.nsf/byTitle/Tutorial+Home+Page?OpenDocument - specifically the "Efficient Basic + Coding for OpenInsight" section.
pre.code {
background-color: #E5E5E5;border: 1px solid #000000;width: 450px;padding: 5px;font-family: courier, verdana, arial, serif;margin: 0px 10px auto;}
RowPtr=1 NewArray=" FOR ROW_P=1 TO ROW_COUNT NextRow=ArrayRowPtr, @Fm RowPtr=Col2() + 1 ColPtr=1 FOR COL_P=1 TO COLUMN_COUNT NextCol=NextRowColPtr, @Vm ColPtr=Col2() + 1 NewArray := NextCol : @Fm Next NewArray-1, 1=@RM NextWorld leaders in all things RevSoft
At 18 NOV 2008 01:27AM Chee Onn Wu wrote:
Thanks, i learned a lot from your previous post.I made my program run more faster with concantenate ":= method.
Now i have an extra question, I am trying to change data position to suit V119 format. Example.
Array='
Array=DOC 1':@VM:'DOCC 2':@VM:'DOCCC 3'
Array=T 1' :@VM:'T 2' :@VM:'T 3'
Array=YY 1' :@VM:'YY 2' :@VM:'YY 3'
i want change the data position to -
Array=DOC 1' :@VM:'T 1' :@VM:'YY 1'
Array=DOCC 2' :@VM:'T 2' :@VM:'YY 2'
Array=DOCCC 3' :@VM:'T 3' :@VM:'YY 3'
I have 2 method :
method 1: ( Faster )
]NEWARRAY= ''
]
]FOR ROW_POS=1 TO ROW_COUNT
] FOR COL_POS=1 TO COLUMN_COUNT
]
] NEWARRAY := ARRAY :@vM
]
] NEXT COL_POS
]
] NEWARRAY := @FM
]
]NEXT ROW_POS
method 2: ( Slower )
]NEWARRAY="
]FOR VM_P=1 TO ROW_COUNT
]
] FM_PTR=1
] FOR FM_P=1 TO COLUMN_COUNT
]
] TMP=ARRAYFM_PTR,@FM
] FM_PTR=COL2() + 1
]
] VM_PTR=1
] TMP2=TMPVM_PTR,@VM
]
] FOR I=1 TO VM_P
] TMP2=TMPVM_PTR,@VM
] VM_PTR=COL2() + 1
] NEXT I
]
] NEWARRAY := TMP2 :@VM
]
] NEXT FM_P
]
] NEWARRAY := @FM
]
]NEXT VM_P
Just want to know a better way to change data position . Thanks in advance.
At 18 NOV 2008 02:12AM [email protected]'s Frank Tomeo wrote:
SRP has a free set of utilities that I think would greatly assist you in sorting and "rotating" your data elements. What you are attempting to do can be done with just one or two simple commands, without the need for additional swapping or looping. It is also very fast, which I think is what you are mainly looking for.
Let us know if you require any further assistance.
At 18 NOV 2008 04:01AM Chee Onn Wu wrote:
Tested the SRP_rotate , like a charm.
Is the SRP utility free to install and use in runtime version?
At 18 NOV 2008 09:44AM [email protected]'s Frank Tomeo wrote:
Yes it is - glad it could help out.
At 19 NOV 2008 12:58AM [email protected]'s Don Bakke wrote:
As my colleague pointed out, this is free for you to distribute in a runtime. If you use the RDK to deploy your application components then you'll want to look in SYSPROG for the SRP_UTILITIES Repository View. This will help you package your own RDK for runtime applications.
It appears you had success with the SRP_Rotate_Array but I thought you wanted to sort your data. If so, then use the SRP_Sort_Array function. This will take your dynamic array regardless of whether it is in "array" or "list" format and regardless of what order your columns are in and allow you to sort in the way you desire. That was the underlying purpose of that function: quick and easy sorting with no messy restructuring of dynamic arrays.