The forum could be offline for 30-60 minutes in the very near future for maintenance (said 3pm Pacific). I was behind on getting this notice. I do apologize.
See more
See less

More pipe dream wishes?

  • Filter
  • Time
  • Show
Clear All
new posts

  • More pipe dream wishes?

    Someone has probably already posted this request, but, would it be feasable to include in PB/DLL either/both:

    ARRAY SORT with multiple TAGARRAY capability?

    ARRAY SORT, SCAN, INSERT, DELETE compatibility with UDT's? Something of the form:
    ARRAY SORT udt(startindex&) FOR count&, SORTKEY = UDT_TYPE.FIELD 'Possibly with multiple key possibility?
    ARRAY SCAN udt(startindex&) FOR count&, WHERE UDT_TYPE.FIELD = fieldvalue, TO index&
    ARRAY INSERT udt(index&), udtvar
    ARRAY DELETE udt(index&)

    Bernard Ertl
    Bernard Ertl
    InterPlan Systems

  • #2
    The short answer is that the ARRAY statement does not work with arrays that are part of a UDT (ie, an array within a UDT), but it does work fine with arrays of UDT's.

    The long answer is that ARRAY INSERT and ARRAY DELETE will directly work with UDT arrays. ARRAY SCAN and ARRAY sort will will also work fine, but will treat the UDT array is if it were a fixed-length string array.

    This means that you have to use a different approach if you want to scan or sort a UDT array based on a numeric member.

    You can use ARRAY SCAN to locate a specific numberic value, by specifying the FROM..TO clause and setting the expression to use MKL$(), MKBYT$(), etc, to create a string representation of the value.

    This technique should also work for a not-equal (<> ) scan, but the technique generally wont work if you require less than, greater than, etc.

    With that said, the ability for ARRAY to work more natureally with UDT structures is on the wish list, so I'll aks R&D to add your comments to that part of the list.


    PowerBASIC Support
    mailto:[email protected][email protected]</A>
    mailto:[email protected]


    • #3
      Aha! It was right there under my nose! So the ARRAY statements (specifically SORT & SCAN) ARE compatible with UDT structures. I totally missed the FROM keyword. That should help me out tremendously. I still think it would be nice to be able to specify multiple keys (multiple FROM statements?) for the sorting the udt/string arrays, however.

      I suppose if I define a UDT something like:

      One AS LONG
      Two AS DWORD
      Three AS INTEGER
      Four AS STRING * 50
      END TYPE

      DIM udt AS UDT_TYPE

      I would be able to use:

      ARRAY SCAN udt(), FROM 1 TO 4, = MKL$(matchlong&), TO Result&
      ARRAY SCAN udt(), FROM 5 TO 8, = MKDWD$(matchdword??), TO Result&
      ARRAY SCAN udt(), FROM 9 TO 10, = MKI$(matchint%), TO Result&

      DIM temp AS STRING * 50
      temp = matchstr$
      ARRAY SCAN udt(), FROM 11 TO 60, = temp, TO Result&

      Is that the general idea?

      Bernard Ertl
      Bernard Ertl
      InterPlan Systems