Sorting Arrays

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

  • Sorting Arrays

    I am hoping that someone has used the sorting array function in PCDMIS and can tell me why it is not working properly when I try to sort a simple array?

    the array values are .0006, .0002, .0003, -.0002, -.0006, .0002, .0002, .0004
    The SORTUP(ARRAY) returns -.0002, -.0006, .0006, .0002, .0003, .0002, .0002, .0004

    the array is obviously not sorted in asending order. Any help would be greatly appreciated.

    I have tried to contact Hexagon support but ????

    Thanks,
    Mike
    Job Function:
    Quality Engineer/Programmer
    Machine Type:
    Global
    Software Version:
    V2010 MR1
    CMM Experience:
    25+ yrs.

  • #2
    I haven't used the sortup array before but, I took a look at your profile and I notice that you are using 4.0. It could be a glitch in that version? Can you load 4.1? I have been using 4.1 for more than a month now and it has worked pretty darn well for me so far. I had to abort 4.0 immediately because of the glitches that I found while doing some very simple stuff. I downloaded 4.1 during its' "release candidate" status and have been up and running since then. Just a suggestion.
    sigpic

    James Mannes

    Comment


    • #3
      Originally posted by mchough1
      I am hoping that someone has used the sorting array function in PCDMIS and can tell me why it is not working properly when I try to sort a simple array?

      the array values are .0006, .0002, .0003, -.0002, -.0006, .0002, .0002, .0004
      The SORTUP(ARRAY) returns -.0002, -.0006, .0006, .0002, .0003, .0002, .0002, .0004

      the array is obviously not sorted in asending order. Any help would be greatly appreciated.

      I have tried to contact Hexagon support but ????

      Thanks,
      Mike

      I feel your pain, but I have no answer....SRY!

      Gabriel
      sigpic

      Comment


      • #4
        I actually talked with Doug at Hexagon this morning and he's looking into it. In the interim I was able to use the MIN/MAX Array commands and it works fine for my application I'm working on.

        Oh, by the way, I have updated to V4.1 and it has the same result. Hopefully we'll be able to use the funtions in the future they'll be great for sorting variables in sub-routines.

        Thanks guys

        Mike
        Job Function:
        Quality Engineer/Programmer
        Machine Type:
        Global
        Software Version:
        V2010 MR1
        CMM Experience:
        25+ yrs.

        Comment


        • #5
          Gotta love work-arounds

          OK I have a solution, it took me long enough didn't it (good thing Hoedemon isn't here)? I was going to write you a .bas but while playing with PCDMIS's array functions I found MAXINDEX and MININDEX both work. Just like you my SORTUP and SORTDOWN got funky. So I wrote a loop.

          If you want to sort descending, try this code:
          Code:
                      ASSIGN/AR_ORIGINAL = ARRAY(.0006, .0002, .0003, -.0002, -.0006, -.0002, .0002, .0004)
                      ASSIGN/AR_SORTED = 0
                      ASSIGN/AR_LENGTH = LEN(AR_ORIGINAL)
                      ASSIGN/AR_MIN = MIN(AR_ORIGINAL)
                      ASSIGN/LOOPCOUNT = 1
                      WHILE/AR_LENGTH > 0
                      ASSIGN/AR_MAXINDX = MAXINDEX(AR_ORIGINAL)
                      ASSIGN/AR_SORTED[LOOPCOUNT] = AR_ORIGINAL[AR_MAXINDX]
                      ASSIGN/AR_ORIGINAL[AR_MAXINDX] = AR_MIN - 1
                      ASSIGN/AR_LENGTH = AR_LENGTH - 1
                      ASSIGN/LOOPCOUNT = LOOPCOUNT + 1
                      END_WHILE/
                      COMMENT/OPER,NO,AR_SORTED
          The operator comment above returns:
          0.0006 0.0004 0.0003 0.0002 0.0002 -0.0002 -0.0002 -0.0006

          If you want to sort ascending, try this code:

          Code:
                      ASSIGN/AR_ORIGINAL = ARRAY(.0006, .0002, .0003, -.0002, -.0006, -.0002, .0002, .0004)
                      ASSIGN/AR_SORTED = 0
                      ASSIGN/AR_LENGTH = LEN(AR_ORIGINAL)
                      ASSIGN/AR_MAX = MAX(AR_ORIGINAL)
                      ASSIGN/LOOPCOUNT = 1
                      WHILE/AR_LENGTH > 0
                      ASSIGN/AR_MININDX = MININDEX(AR_ORIGINAL)
                      ASSIGN/AR_SORTED[LOOPCOUNT] = AR_ORIGINAL[AR_MININDX]
                      ASSIGN/AR_ORIGINAL[AR_MININDX] = AR_MAX + 1
                      ASSIGN/AR_LENGTH = AR_LENGTH - 1
                      ASSIGN/LOOPCOUNT = LOOPCOUNT + 1
                      END_WHILE/
                      COMMENT/OPER,NO,AR_SORTED
          The operator comment above returns:
          -0.0006 -0.0002 -0.0002 0.0002 0.0002 0.0003 0.0004 0.0006

          If anyone needs this post explained just ask and I'll break it down. I can explain my code, can Wilcox explain the behavior of SORTUP, SORTDOWN? I'm wondering if it has issues with negative numbers. I did not try SORTUP or SORTDOWN with positive numbers only. Obviously this is more code intensive than SORTUP or SORTDOWN but sometime you gotta do what you gotta do. And if you gotta sort your arrays this will work.

          This will only work on one dimensional arrays though, if you are using multiple dimension arrays you will need to bastardize this into something that will handle multiple dimensions.

          Craig
          <internet bumper sticker goes here>

          Comment

          Related Topics

          Collapse

          • Master Chief
            FYI - The Latest
            by Master Chief
            In recent dealings with BrownandSharpe, I have been told that the latest version is 3.7mr3. Does this jive with what you have been told? It seems that...
            07-10-2006, 12:14 PM
          • John Kugler
            4.1 Performance
            by John Kugler
            Is it safe to say that we could possibly download 4.1 and give it a serious run??

            I (unfortunately) installed 4.0 to play with, and I am...
            09-08-2006, 09:49 PM
          • Randy L.
            4.1 is it worth loading?
            by Randy L.
            I haven't had much time to spend on this forum lately. I was wondering is it worth loading 4.1? I'm currently using 3.5 mr2. What are the main concerns...
            11-01-2006, 12:39 PM
          • AuRules
            V4.0 versus 3.7mr2
            by AuRules
            I,m currntly running v3.7mr2 everyday, but I do have v4.0 on my PC. What shall I do with v4.0 because I heard through the grapevine that v4.0 has a few...
            12-07-2006, 04:53 PM
          • Moore Racing
            Loading a new version
            by Moore Racing
            I am running 4.0, updating to 4.1... I went to the Wilcox site and downloaded the 4.1. It came in a zipped file and now unzipped and sitting on my...
            06-10-2010, 11:58 AM
          Working...
          X