Welcome to the SRP Forum! Please refer to the SRP Forum FAQ post if you have any questions regarding how the forum works.
Trimming and sorting arrays
Looking for suggestions as I might not be seeing clearly.
Basic premise is we use OI tables on databound forms to perform the actual read/write however they are hidden tables and we provide SRP edittables for the GUI. Better experience for the user and greater flexibility for us coders.
Here's where I'm getting a little stuck. On the read event, I take the content of the hidden OI table and place it into the SRP table.
A simple get_property/set_property. As part of that process I want to trim all the blank rows/records from the data before setting it into the SRP table. Not every column/field has data in every cell so the number of trailing vms can be different for each column.
First point, I've been unable to see a use of srp_array("Clean".....) that will actually clean the multiDimensional array. The documentation suggests that "TrimTrailing" should do it but it doesn't seem to. I got around that by just looping through each field and cleaning them one at a time. That worked fine initially.
However, now we want to sort the data before displaying it. The column I'm sorting on has the maximum number of records/rows.
When the sort occurs, it sorts correctly except for the shorter/lesser fields. If one of the those has data that needs to move to a position that it doesn't already have (because it was trimmed), then the data just gets dropped.
Actually now that I've taken the screenshot maybe it's only if it moves to the very last position?
Any suggestions on any of the above are welcome.
Basic premise is we use OI tables on databound forms to perform the actual read/write however they are hidden tables and we provide SRP edittables for the GUI. Better experience for the user and greater flexibility for us coders.
Here's where I'm getting a little stuck. On the read event, I take the content of the hidden OI table and place it into the SRP table.
A simple get_property/set_property. As part of that process I want to trim all the blank rows/records from the data before setting it into the SRP table. Not every column/field has data in every cell so the number of trailing vms can be different for each column.
First point, I've been unable to see a use of srp_array("Clean".....) that will actually clean the multiDimensional array. The documentation suggests that "TrimTrailing" should do it but it doesn't seem to. I got around that by just looping through each field and cleaning them one at a time. That worked fine initially.
However, now we want to sort the data before displaying it. The column I'm sorting on has the maximum number of records/rows.
When the sort occurs, it sorts correctly except for the shorter/lesser fields. If one of the those has data that needs to move to a position that it doesn't already have (because it was trimmed), then the data just gets dropped.
Actually now that I've taken the screenshot maybe it's only if it moves to the very last position?
Any suggestions on any of the above are welcome.
Comments
Keen to be enlightened.
maintContents = Get_Property(maint_table$, "ARRAY") maintContents = srp_array("Clean", maintContents, "TrimTrailing", vm$)
That trims the trailing vms off just the last field only so to work around that I loop through the fields and do the same thing just on a field by field basis which is fine in this case because I know it's only a handful of fields. Wouldn't really want to be doing that in a more dynamically sized array. I would if I had to but...As for the sorting of the end result, that's just done like this
sortedArray = srp_array("SortRows", maintContents, "AR":mdateCol$)
Start from the end and loop backwards until a cell value.
< snippet >
EditTableList = get_property(CtrlEntId,"ARRAY")
vColCnt = count(EditTableList,@fm) + (EditTableList <>'')
vRowCnt = count(EditTableList<1>,@vm) + (EditTableList<1> <>'')
GotValue=0
for cRow = vRowCnt to 1 step -1 until GotValue
if EditTableList<1,cRow> = '' then
for cCol = 1 to vColCnt
EditTableList = delete(EditTableList,cCol,cRow,'')
next cCol
end else
GotValue=1
end
next cRow
if EditTableList else EditTableList:=@fm
set_property_only(CtrlEntId,"ARRAY",EditTableList)
NoCols = DCount(maintContents, fm$) for colno = 1 to NoCols maintContents<colno> = srp_array("Clean", maintContents<colno>, "TrimTrailing", vm$) Next colno
Function Ut_trim_delim( data) /* Matthew Crozier 17 May 1997 Removes trailing system delimiters (except RM) from within delimited data. Sensitive to delimiter hierarchy. Assumes that system delimiters are single byte and mutually exclusive of all OI UTF8 characters. */ pos = getByteSize( data) curr.delim = 5; data.delim = 6 Loop while pos delim = index( \FAFBFCFDFEFF\, data[ pos, 1, 1], 1) If delim then If delim <= curr.delim then If delim < data.delim then data[ pos, 1, 1] = '' End else If not( curr.delim) or delim > data.delim then data.delim = delim curr.delim = delim End End else If curr.delim then If data[ pos, 1, 1] = ' ' then data[ pos, 1, 1] = '' end else curr.delim = 0 End End End pos -= 1 Repeat Return data
HTH, M@
With multiple copies of OI on my machine, how do I know which SRP utilities is being used?
Is it just whichever one is in the root directory of that OI or is it like the controls and registered somewhere?