Announcement

Collapse
No announcement yet.

random memory error in PB win 10.04

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

  • #21

    Your analysis may be wrong or it may have discovered a parsing error in the compliler
    Code:
      MSGBOX FORMAT$(LBOUND(mSkin()))+$CRLF+FORMAT$(UBOUND(mSkin()))
    According to the 10.0.4 help, the LBOUND function does not accept empty parentheses following arrayname

    Then again, I don't get the same results you did.. Click image for larger version  Name:	LBOUND_TEST.PNG Views:	1 Size:	27.3 KB ID:	756152
    Michael Mattias
    Tal Systems Inc.
    Racine WI USA
    mmattias@talsystems.com
    http://www.talsystems.com

    Comment


    • #22
      The above snippet always returns an UBOUND of 0 when an negative value is used as the upper bound.
      Problem not with UBOUND either as far as I can tell with PBWin10.04 on Windows Vista.
      Code:
      #compile exe
      #dim all
      function pbmain () as long
        local ndx as long
        dim mSkin(-10 to -0) as global long
        for ndx=-10 to -5
          mSkin(ndx)=ndx+11
        next ndx
        msgbox format$(lbound(mSkin()))+$crlf+format$(ubound(mSkin()))
      end function
      Returns -10 and 0 here (duh, upper bound is 0)
      Code:
      #compile exe
      #dim all
      function pbmain () as long
        local ndx as long
        dim mSkin(-10 to -1) as global long
        for ndx=-10 to -5
          mSkin(ndx)=ndx+11
        next ndx
        msgbox format$(lbound(mSkin()))+$crlf+format$(ubound(mSkin()))
      end function
      Returns -10 and -1 (humm, not 0)
      Code:
      #compile exe
      #dim all
      function pbmain () as long
        local ndx as long
        dim mSkin(-10 to -2) as global long
        for ndx=-10 to -5
          mSkin(ndx)=ndx+11
        next ndx
        msgbox format$(lbound(mSkin()))+$crlf+format$(ubound(mSkin()))
      end function
      Returns -10 and -2 (no incorrect 0 yet)
      Code:
      #compile exe
      #dim all
      function pbmain () as long
        local ndx as long
        dim mSkin(-10 to -3) as global long
        for ndx=-10 to -5
          mSkin(ndx)=ndx+11
        next ndx
        msgbox format$(lbound(mSkin()))+$crlf+format$(ubound(mSkin()))
      end function
      Returns -10 and -3 (need I continue?)

      I have also read the thread Paul linked to. Two conclusions - 1. An error exists in some verions of Windows (no surprise) 2. Question should have remained on other web site.

      Cheers,
      Dale

      Comment


      • #23
        Well done, Dale!

        Michael, regarding the empty parenthesis after the array name, I seem to recall Bob stating somewhere that they could be used for code clarity, perhaps in an older version of PB.
        Last edited by Rodney Hicks; 23 Dec 2016, 12:04 PM.
        Rod
        "To every unsung hero in the universe
        To those who roam the skies and those who roam the earth
        To all good men of reason may they never thirst " - from "Heaven Help the Devil" by G. Lightfoot

        Comment


        • #24
          According to the 10.0.4 help, the LBOUND function does not accept empty parentheses following arrayname.
          Not true..
          The first syntax in LBOUND Help shows parentheses, and the note following demension states first demension used if not specified, ie "empty". Also code shown in post 22 (and before) works with empty parentheses after the array name in lbound.

          Also checked PBWin 9.04, and it says the same thing,
          Dale

          Comment


          • #25
            The first syntax in LBOUND Help shows parentheses, and the note following demension states first demension used if not specified, ie "empty"

            I read that differently..
            Syntax
            y& = LBOUND(array [(dimension)])

            y& = LBOUND(array, dimension)
            I read that as "(dimension)" (the whole thing with the parens) is optional (square brackets).

            If the parens even if empty were required we'd see
            Code:
            Y% =  LBOUND (array ([,dimension])
            If parens are optional, and optionally empty as well we'd see
            Code:
            Y% =  LBOUND (array [([,dimension]])
            So, either the compiler is wrong (accepting non-documented syntax) or the help is wrong. Either way, a bug.

            But it 'seems' to work any which way so it's probably not material here anyway. .

            MCM
            Michael Mattias
            Tal Systems Inc.
            Racine WI USA
            mmattias@talsystems.com
            http://www.talsystems.com

            Comment

            Working...
            X