Announcement

Collapse
No announcement yet.

Array Sort VS UDT In PBDLL5

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Array Sort VS UDT In PBDLL5

    Why a syntax error??

    Exemple:
    Code:
    Type NodeType
        NodesColl(128)  As String * 9
        Count           As Integer
    End Type
    Global LabNodes(10) As NodeType    
    .
    ..
    ...
    Array Sort LabNodes(5).NodesColl(), Descend
    -> SYNTAX ERROR??!! <--
    May be UDT aren't support by the Array Function in PB5?
    Francis Beaulieu
    Prog senior of 17 years.
    Microsoft Specialist

  • #2
    An array within a UDT is not like a conventional array - it functions more like a "table". As a result, the ARRAY statements do not work with array *within* UDT's.

    One idea you could try to sort an array within a specific UDT member - use DIM...AT, then sort that array normally.

    If I have time when I get back to my DEV PC, I'll try this out.


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

    Comment


    • #3
      You can only sort on a UDT member with ARRAY SORT using the FROM..TO option. To sort on the second field, you would need to speicfy FROM 10 to 11, the position of the member....
      ..BUT...

      When you use FROM..TO.. the bytes are sorted as characters, which means numeric datatypes do not sort in numeric order.

      You have two solutions:
      1. Create a separate integer array, sort that and TAG along your UDT array.

      2. Convert the integer to a character-sortable form. Do a search in the source code forum for "SSB" and you will find some functions to to this.

      Method A is probably better in the Windows environment, as you do not suffer for lack of memory.

      MCM
      (inventor of SSB datatypes)
      Michael Mattias
      Tal Systems Inc. (retired)
      Racine WI USA
      [email protected]
      http://www.talsystems.com

      Comment


      • #4
        Michael --

        Francis is trying to sort the elements of an array that is part of a UDT, not trying to sort an array of UDTs.

        -- Eric

        ------------------
        Perfect Sync: Perfect Sync Development Tools
        Email: mailto:[email protected][email protected]</A>

        [This message has been edited by Eric Pearson (edited February 12, 2000).]
        "Not my circus, not my monkeys."

        Comment

        Working...
        X