Announcement

Collapse
No announcement yet.

miva_array_collapse question

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

    miva_array_collapse question

    If I had:

    mivarray[1]
    mivarray[3]

    and run it thru miva_array_collapse, I get the proper count of 2. But isn't it suppose to reorder the indexes?

    mivarray[1]
    mivarray[2]

    And maybe I should also ask this first, does this work in storemorph? I didn't receive any errors, and not getting an expected result.

    Thanks,
    Scott
    Need to offer Shipping Insurance?
    Interactive Design Solutions https://www.myids.net
    MivaMerchant Business Partner | Certified MivaMerchant Web Developer
    Competitive Rates, Custom Modules and Integrations, Store Integration
    AutoBaskets|Advanced Waitlist Integration|Ask about Shipping Insurance Integration
    My T-shirt Collection is mostly MivaCon T-shirts!!

    #2
    According to mivascript.com:

    Collapses the array_variable making the indices sequential starting at 1. Returns the number of elements in the array.

    So it should reorder the indices. I'm sure I observed this when using it years ago. Are you seeing different behavior?
    Gordon Currie
    Phosphor Media - "Your Success is our Business"

    Improve Your Customer Service | Get MORE Customers | Edit Any Document Easily | Free Modules | Follow Us on Facebook
    phosphormedia.com

    Comment


      #3
      I didn't receive any errors, and not getting an expected result.

      So yes different behavior.

      More specific:

      mivarray[1]
      mivarray[3]

      has a max of 2. When cycling through starting at 1, you never reach the 3rd element because the index didn't actually get reordered.


      I think it was 5.21 Engine fixed a bug that read like it was related because it wasn't removing sparse elements.

      But, this is also in the templates not mivascript (as in a module).

      More detail in case it's important... the array I need to collapse is a global.
      Need to offer Shipping Insurance?
      Interactive Design Solutions https://www.myids.net
      MivaMerchant Business Partner | Certified MivaMerchant Web Developer
      Competitive Rates, Custom Modules and Integrations, Store Integration
      AutoBaskets|Advanced Waitlist Integration|Ask about Shipping Insurance Integration
      My T-shirt Collection is mostly MivaCon T-shirts!!

      Comment


        #4
        I've only used it in modules, in fact it is in 10 of ours. AFAIK it works fine still (although I'll verify soon).
        Gordon Currie
        Phosphor Media - "Your Success is our Business"

        Improve Your Customer Service | Get MORE Customers | Edit Any Document Easily | Free Modules | Follow Us on Facebook
        phosphormedia.com

        Comment


          #5
          Does that mean you're going to verify in a template?
          Need to offer Shipping Insurance?
          Interactive Design Solutions https://www.myids.net
          MivaMerchant Business Partner | Certified MivaMerchant Web Developer
          Competitive Rates, Custom Modules and Integrations, Store Integration
          AutoBaskets|Advanced Waitlist Integration|Ask about Shipping Insurance Integration
          My T-shirt Collection is mostly MivaCon T-shirts!!

          Comment


            #6
            No, I don't do template code, sorry.

            It doesn't make sense that it would behave differently in SMT vs. compiled module, since it calls the same function either way.
            Last edited by Gordon - Phosphor Media; 09-21-16, 05:43 PM.
            Gordon Currie
            Phosphor Media - "Your Success is our Business"

            Improve Your Customer Service | Get MORE Customers | Edit Any Document Easily | Free Modules | Follow Us on Facebook
            phosphormedia.com

            Comment


              #7
              I tried this test and it worked for me.

              Code:
              <mvt:assign name="g.array[2]" value="'TestString1'" />
              <mvt:assign name="g.array[5]" value="'TestString2'" />
              <mvt:assign name="g.count" value="miva_array_collapse( g.array )" />
              
              count = &mvt:global:count;<br>
              &mvt:global:array[1];<br>
              &mvt:global:array[2];<br>
              
              Max = <mvt:eval expr="miva_array_max(g.array)" />
              Ray Yates
              "If I have seen further, it is by standing on the shoulders of giants."
              --- Sir Isaac Newton

              Comment


                #8
                Thanks Ray.

                I am concluding a typo in my code somewhere.
                Need to offer Shipping Insurance?
                Interactive Design Solutions https://www.myids.net
                MivaMerchant Business Partner | Certified MivaMerchant Web Developer
                Competitive Rates, Custom Modules and Integrations, Store Integration
                AutoBaskets|Advanced Waitlist Integration|Ask about Shipping Insurance Integration
                My T-shirt Collection is mostly MivaCon T-shirts!!

                Comment

                Working...
                X