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.


  • FWIW, I've worked around this but I still feel like I'm missing something or not doing something correctly.
    Keen to be enlightened.
  • Can you provide sample code to show us exactly what you're doing?
  • edited September 2019
    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$)
  • edited September 2019
    >>that I loop through the fields and do the same thing just on a field by field basis <<
    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> <>'')
    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
    next cRow
    if EditTableList else EditTableList:=@fm
  • edited September 2019
    NoCols = DCount(maintContents, fm$) for colno = 1 to NoCols maintContents<colno> = srp_array("Clean", maintContents<colno>, "TrimTrailing", vm$) Next colno
  • I've got an utility function that trims a multi-nested dynamic array of trailing system delimiters (and spaces) for all system delimiters. I use it to reduce highly structured arrays (typically records) and when checking for changes.
    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@
  • @AusMarkB, I am unable to recreate this issue in SRP Utilities 2.0.5. I created a sample array that mimics your own. I looped through it, cleaning each field, which led to the same results as you. Then, when I do SortRows, I get the data as it should be.

  • Well I'll start with the version being the problem.
    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?
  • Your best bet is to check the Product Version of the SRPUtilities.dll file in the REVBOOT folder. This is not a registered component, so you need to always check the file that is in the REVBOOT folder you are running OI in. Having said that, it is possible for the RDK entities to get out of sync with the DLL. This happens when the DLL file is dropped in but the RDK is not installed...or vice-versa. However, when this happens it often leads to runtime errors.
Sign In or Register to comment.