Announcement

Collapse
No announcement yet.

Array Scan error

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

  • Array Scan error

    I have happily used ARRAY SCAN for years with string arrays but the following single statement straight out of the manual refuses to compile with a "Relational Operator Expected" error.

    Removing the "FOR 10," allows it to compile. I just cannot see what is wrong.

    Code:
    FUNCTION PBMAIN() AS LONG
    
    LOCAL A() AS LONG
    LOCAL I AS LONG
    
    DIM A&(10)
    
    ARRAY SCAN A&(), FOR 10, =1, TO i&
    
    END FUNCTION
    Can anyone put me out of my misery?

    Regards,

    Bern

    ------------------
    Bern

    www.insighttrading.com.au
    Bern


    http://www.insighttrader.com.au

  • #2
    A comma too many, right after A&(). The following will work:
    Code:
    ARRAY SCAN A&() FOR 10, =1, TO i&
    A tip. If you intend to scan the entire array, you can remove FOR
    and just use the following instead:
    Code:
    FUNCTION PBMAIN() AS LONG
      LOCAL I AS LONG
      REDIM A(10) AS LONG
      ARRAY SCAN A(), =1, TO I
    END FUNCTION
    ------------------

    Comment


    • #3
      I have found it.

      Looks like the examples in the manual are not consistent with the syntax statement statement which is correct.

      Removing the comma between the array and the FOR solves the problem.

      Bern

      ------------------
      Bern

      www.insighttrading.com.au
      Bern


      http://www.insighttrader.com.au

      Comment


      • #4
        Thanks Borje for your prompt reply.

        Maybe the manual has been updated since I got mine.

        It is so much easier to grab an example and modify it than to work through the syntax statment. But this has obvious dangers.

        Regards,

        Bern



        ------------------
        Bern

        www.insighttrading.com.au
        Bern


        http://www.insighttrader.com.au

        Comment


        • #5
          You are right - the examples given for ARRAY SCAN are faulty,
          since they add a comma before FOR. Manual says:
          ARRAY SCAN array([index]) [FOR count], operator expression, TO lvar

          Given examples wrongly says: ARRAY SCAN A&(), FOR 10, =1, TO I&

          In case someone has missed it - text within [] is optional - can
          be omitted, so the above can be used in four different ways:

          ARRAY SCAN array(), operator expression, TO lvar
          ARRAY SCAN array() FOR count, operator expression, TO lvar
          ARRAY SCAN array(index), operator expression, TO lvar
          ARRAY SCAN array(index) FOR count, operator expression, TO lvar


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

          Comment


          • #6
            Borje,

            While I have your ear I would like to thank you again for POFFS. I use it all the time. Absolutely marvellous!

            Regards,

            Bern

            ------------------
            Bern

            www.insighttrading.com.au
            Bern


            http://www.insighttrader.com.au

            Comment


            • #7
              Good catch on the comma's, folks!

              I'll pass that along to the Documentation Dept...


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

              Comment


              • #8
                Oops! There is also an error in the accompanying ARRAY SCAN text that refers to variable I% instead of I&.



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

                Comment


                • #9
                  Lance,
                  How can I get a job in this 'Documentation Dept.'? It's been
                  18 months since the last time they had to put anything on paper.

                  --Bob

                  ------------------
                  "It was too lonely at the top".

                  Comment

                  Working...
                  X