Loading ...
Sorry, an error occurred while loading the content.

Re: Global Variable Not Incrementing in For Loop

Expand Messages
  • carlgundel
    ... for ... the ... it ... I don t think you re missing anything. That s a bug. Thanks for reporting it. I can t believe I missed it. :-( -Carl
    Message 1 of 11 , Jul 4, 2005
    • 0 Attachment
      --- In libertybasic@yahoogroups.com, "libertybasicreo"
      <okie607@a...> wrote:
      > I set up a global variable in my main program.
      >
      > global Var1
      >
      > In a subroutine, I try to use this global variable as part of a
      for
      > loop.
      >
      > sub example
      >
      > for Var1 = 1 to 10
      > print Var1
      > next Var1
      >
      > end sub
      >
      >
      > For some strange reason, Var1 does not increment from 1 to 10 in
      the
      > for loop. It simply retains a value of zero (which is I guess what
      it
      > is initialize to).
      >
      > Does anybody know what is going on? Am I missing something obvious?

      I don't think you're missing anything. That's a bug. Thanks for
      reporting it. I can't believe I missed it. :-(

      -Carl
    • carlgundel
      ... what ... obvious? ... Okay, this also happens in v4.01, so this has been a bug in LB for a while now. At least it isn t a new bug, which is only
      Message 2 of 11 , Jul 4, 2005
      • 0 Attachment
        --- In libertybasic@yahoogroups.com, "carlgundel" <carlg@l...> wrote:
        > --- In libertybasic@yahoogroups.com, "libertybasicreo"
        > <okie607@a...> wrote:
        > > I set up a global variable in my main program.
        > >
        > > global Var1
        > >
        > > In a subroutine, I try to use this global variable as part of a
        > for
        > > loop.
        > >
        > > sub example
        > >
        > > for Var1 = 1 to 10
        > > print Var1
        > > next Var1
        > >
        > > end sub
        > >
        > >
        > > For some strange reason, Var1 does not increment from 1 to 10 in
        > the
        > > for loop. It simply retains a value of zero (which is I guess
        what
        > it
        > > is initialize to).
        > >
        > > Does anybody know what is going on? Am I missing something
        obvious?
        >
        > I don't think you're missing anything. That's a bug. Thanks for
        > reporting it. I can't believe I missed it. :-(

        Okay, this also happens in v4.01, so this has been a bug in LB for a
        while now. At least it isn't a new bug, which is only comforting in
        the sense that it doesn't break code that already works under v4.01.

        -Carl
      • carlgundel
        ... a ... in ... for ... a ... in ... v4.01. The other reason why this bug is really quite unimportant is that global variables are almost never used in this
        Message 3 of 11 , Jul 4, 2005
        • 0 Attachment
          --- In libertybasic@yahoogroups.com, "carlgundel" <carlg@l...> wrote:
          > --- In libertybasic@yahoogroups.com, "carlgundel" <carlg@l...>
          wrote:
          > > --- In libertybasic@yahoogroups.com, "libertybasicreo"
          > > <okie607@a...> wrote:
          > > > I set up a global variable in my main program.
          > > >
          > > > global Var1
          > > >
          > > > In a subroutine, I try to use this global variable as part of
          a
          > > for
          > > > loop.
          > > >
          > > > sub example
          > > >
          > > > for Var1 = 1 to 10
          > > > print Var1
          > > > next Var1
          > > >
          > > > end sub
          > > >
          > > >
          > > > For some strange reason, Var1 does not increment from 1 to 10
          in
          > > the
          > > > for loop. It simply retains a value of zero (which is I guess
          > what
          > > it
          > > > is initialize to).
          > > >
          > > > Does anybody know what is going on? Am I missing something
          > obvious?
          > >
          > > I don't think you're missing anything. That's a bug. Thanks
          for
          > > reporting it. I can't believe I missed it. :-(
          >
          > Okay, this also happens in v4.01, so this has been a bug in LB for
          a
          > while now. At least it isn't a new bug, which is only comforting
          in
          > the sense that it doesn't break code that already works under
          v4.01.

          The other reason why this bug is really quite unimportant is that
          global variables are almost never used in this way. A global
          varable is usually set with some important shared value, and not
          used as a counter variable in a FOR/NEXT loop. Nonetheless, this
          should be fixed in a subsequent release.

          -Carl
        • Chergarj@cs.com
          In a message dated 07/04/2005 6:26:48 PM Pacific Daylight Time, ... Useful to know is does GLOBAL work the way it works in other languages as it does in
          Message 4 of 11 , Jul 4, 2005
          • 0 Attachment
            In a message dated 07/04/2005 6:26:48 PM Pacific Daylight Time,
            carlg@... writes:
            > The other reason why this bug is really quite unimportant is that
            > global variables are almost never used in this way. A global
            > varable is usually set with some important shared value, and not
            > used as a counter variable in a FOR/NEXT loop. Nonetheless, this
            > should be fixed in a subsequent release.
            >

            Useful to know is does GLOBAL work the way it works in other languages as it
            does in Liberty BASIC? If this is normal for other BASIC's then maybe you
            should just put an instructive note about this in the help file for Liberty
            BASIC.

            G C


            [Non-text portions of this message have been removed]
          • carlgundel
            ... that ... this ... languages as it ... maybe you ... for Liberty ... It isn t supposed to do this, so I should just fix it in the next release. -Carl
            Message 5 of 11 , Jul 5, 2005
            • 0 Attachment
              --- In libertybasic@yahoogroups.com, Chergarj@c... wrote:
              > In a message dated 07/04/2005 6:26:48 PM Pacific Daylight Time,
              > carlg@l... writes:
              > > The other reason why this bug is really quite unimportant is
              that
              > > global variables are almost never used in this way. A global
              > > varable is usually set with some important shared value, and not
              > > used as a counter variable in a FOR/NEXT loop. Nonetheless,
              this
              > > should be fixed in a subsequent release.
              > >
              >
              > Useful to know is does GLOBAL work the way it works in other
              languages as it
              > does in Liberty BASIC? If this is normal for other BASIC's then
              maybe you
              > should just put an instructive note about this in the help file
              for Liberty
              > BASIC.

              It isn't supposed to do this, so I should just fix it in the next
              release.

              -Carl
            Your message has been successfully submitted and would be delivered to recipients shortly.