Welcome to the SRP Forum! Please refer to the SRP Forum FAQ post if you have any questions regarding how the forum works.

SRP_Array (SortArray)

I have an array, I populate it COL:ROW and Set_Property(@window:'.TBL_DEPOSITS','ARRAY',DepositArray)
I am trying to use SRP_Array(SortArray...) to sort based on Column #1.
I am not having any luck with SRP_Array and I am sure its based on not knowing how to use it.

I followed the following instructions from the SRP wiki:

// Sort an OI EditTable on column 2 in ARRAY format
TableArray = Get_Property(@Window:".EDT_TEST", "ARRAY")
NewArray = SRP_Array("SortRows", TableArray, "AL2")
Set_Property(@Window:".EDT_TEST", "ARRAY", NewArray)

But it did not produce the results I expected.

I have created two separate arrays, one that lists all deposits and one that lists all posted interest both have an associated data field (AVM). I join the arrays together and populate the data into the edit-table on the form as an 'ARRAY', but since I joined two separate arrays, I need it to sort based on Col#1 which is the date field, and need it to sort on the OCONV of the date.

Attached is my sample code and attached is a screenshot of the result. Any help would be appreciated, TIA

Comments

  • Try using the LIST property of EDT_TEST instead.
  • Nope, that did not help, see attached. I am wondering since I want to sort on Col#1 which is an OCONV of a date value, if its having trouble on how to treat the data? Your thoughts?
  • Try sorting using "AR2". Since dates are numeric, they need to be sorted as numbers.
  • edited February 2017
    Wouldn't the value in Col1 be 'varchar' as its not the iconv but the oconv of a date field? Just a question.
    As it has '/' in the masking of the date i.e. 04/16/2001. And try AR2 as an 'ARRAY' or 'LIST'? Thanks,
  • edited February 2017
    But sorting on an oconv'ed date will not get you the date in date order!
    You will need to:

    for k = 1 to TotDeposits DepositArray<1,k> = InvestmentRec<LV$DEPOSIT_DATE,k> . . for k = 1 to TotInterest InterestArray<1,k> = InvestmentRec<LV$INTEREST_DATE,k> . . for k = 1 to 5 DepositArray<k> = DepositArray<k>:VM$:InterestArray<k> . . . SortedArray = SRP_Array('SortRows',DepositArray,'AR1') DepositArray<1>=oconv(DepositArray<1>,'D4/')
  • I was assuming ARRAY returned the data iconv'd. If it doesn't, then yes, you need to IConv before the sort.
  • edited February 2017
    That is what I thought. No, the ARRAY does not return the ICONV, I am going to have to retool the logic, it gives me a starting point to figure it out. I was trying to not have to completely convert the ARRAY for v119, so I wanted something light and simple. Thank you very much, Barry/Kevin.
  • I think you can use INVALUE, which is the same as ARRAY but IConv'd.
  • if you do this DepositArray<1>=oconv(DepositArray<1>,'D4/') then use ARRAY in the set_property, if you leave it out use INVALUE in the set_property.
  • edited February 2017
    Thanks Barry, I followed your model above and yes, I had already determine 'DepositArray<1>=oconv(DepositArray<1>,'D4/')' would be an ARRAY format vs LIST format.
    I've got it working. Thanks again.
Sign In or Register to comment.