Announcement

Collapse
No announcement yet.

Matrix Help

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

  • Matrix Help

    Hi:

    A couple questions:

    (I understand that 1-dimension is not truely an array, but let's go with it)
    Code:
    SUB ArraySort ALIAS "ArraySort"(BYVAL Member AS LONG,_
                                    BYVAL SortLength AS LONG,_
                                    BYVAL StartPos AS LONG)                 
    
      REDIM xTSLArray(Member,DimArray) AS GLOBAL SINGLE,xTSLIArray(Member,DimArray) AS GLOBAL LONG
      MAT xTSLArray(Member,0) = TSLArray(Member,0)
      MAT xTSLIArray(Member,0) = TSLIArray(Member,0)
      ARRAY SORT xTSLArray(Member,StartPos) FOR SortLength,TAGARRAY xTSLIArray() ,ASCEND
    END SUB
    This is a code snippet

    1). I get an error "missing declaration" Member at Comple time ...WHY?

    All Arrays xTSHLArray,TSLArray ...have been previously Dim as Global Single or Long
    These arrays big.

    2). Could I MAT xTSLArray() = TSHLArray(Member,0)?
    I other words can I copy out Member to a 1-dim Array?

    Sure would me helpful and easier. Don't want to use a For Loop.

    3). What about the TAGARRAY xTSLIArray()..
    Do I need a xTSLIArray(Member,0) here?

    Thanks for your help.

    Bruce


    ------------------

  • #2
    1). I get an error "missing declaration" Member at Comple time ...WHY?
    The error is slightly misleading in this context. MAT required the 'whole' array for the operand, not a specific array subscript:
    Code:
    MAT xTSLArray() = TSLArray()
    2). Could I MAT xTSLArray() = TSHLArray(Member,0)?
    I other words can I copy out Member to a 1-dim Array?
    Sure would me helpful and easier. Don't want to use a For Loop.
    Please see the MAT statement in the documentation for the syntax.

    3). What about the TAGARRAY xTSLIArray()..
    Do I need a xTSLIArray(Member,0) here?
    No, ARRAY works on the relative subscript "position" in the TAGARRAY array, so you only need to supply the array name with empty parentheses.

    That is, lets say you are sorting subscripts 10 to 20 of A$(0:200). ARRAY SORT rearranges the TAGARRAY subscript in the matching positions. The actual LBOUND/UBOUND is irrelevent - the subscripts positions are important.
    Code:
    DIM A$(200), B$(1000:1200)
    ARRAY SORT A$(), TAGARRAY B$()
    If the first and second subscripts in A$ are reversed, then the 1st and 2nd subscripts in B$ will be reversed too. In this case, this would A$(0) and A$(1), plus B$(1000) and B$(1001).

    I hope this helps!


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

    Comment


    • #3

      Hi Lance:

      1). So MAT can only copy the entire Huge Array and not just Member to Member?

      The Doc stated A1%(? to ?,? to ?).

      2). I can't say like 5 to 10 as variables?
      MAT A1%(Start to Finish) = MAT A2%(Start to Finish)
      or
      MAT A1%() = MAT A2%(Start to Finish)


      Ok..the tag I understand..I thought so, but just checking.

      3). Will the below statement, just sort the Array Member specified From StartPos to End?

      ARRAY SORT xTSLArray(Member,StartPos) FOR SortLength,TAGARRAY xTSLIArray() ,ASCEND

      Thanks again for you fast replys


      Bruce

      ------------------

      Comment


      • #4
        1). So MAT can only copy the entire Huge Array and not just Member to Member?
        Yes, that is correct. If you want to copy a single member to another, just assign the value A1%(x) = A2%(x), etc.

        To duplicate a whole array use MAT. To copy "sequential" blocks of more than one member, there are tricks like PEEK$/POKE$, or pointers that can be used.
        The Doc stated A1%(? to ?,? to ?).
        You can certainly construct arrays in that manner, but the MAT documentation does not describe that format as valid syntax of the MAT statement. The MAT statement expect array names with empty parentheses, which denotes a complete array.

        2). I can't say like 5 to 10 as variables?
        MAT A1%(Start to Finish) = MAT A2%(Start to Finish)
        or
        MAT A1%() = MAT A2%(Start to Finish)
        See my answer above, or create a FOR loop.

        3). Will the below statement, just sort the Array Member specified From StartPos to End?

        ARRAY SORT xTSLArray(Member,StartPos) FOR SortLength,TAGARRAY xTSLIArray() ,ASCEND

        Thanks again for you fast replys
        It sorts xTSLArray() from the subscript at '(Member, Startpos)' and sorts 'SortLen' subscripts. They are sorted in column-major order.

        Please refer to ARRAY SORT in the documentation for mode information on sorting multi-dimensional arrays.

        Thanks!

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

        Comment

        Working...
        X