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

Re: [libertybasic] Re: Variable out of loop

Expand Messages
  • Henrik
    Thank you mike, your “do” code is very interested to me… ________________________________ From: green8819 To:
    Message 1 of 21 , Jan 28, 2013
    • 0 Attachment
      Thank you mike, your “do”
      code is very interested to me…


      ________________________________
      From: green8819 <mike4612@...>
      To: libertybasic@yahoogroups.com
      Sent: Tuesday, January 29, 2013 6:30 AM
      Subject: [libertybasic] Re: Variable out of loop


       
      Verdict?

      I think NEXT is 'Not Guilty'

      As Rod has pointed out, it's duty is to increment.
      The FOR...TO decides whether to execute the loop.
      We decide what should happen in between.

      for x=1 to 10
      do something
      NEXT

      Normally the value of x is not important after NEXT.
      However, to be safe, we decide to EXIT the loop when x reahes upper limit.

      For x=1 to 10
      do something
      if x=10 then EXIT for
      next

      Besides other alternatives already mentioned by contributors, the following is easy to understand:

      x=0
      do
      x=x+1
      print x
      loop until x=10
      print x

      I still prefer good old FOR...NEXT. There is no need to initialize (x=0) or increment (x=x+1).




      [Non-text portions of this message have been removed]
    • Stefan Pendl
      ... Generally speaking, every loop construct has its purpose. For finite loops, where you exactly know the limits FOR..NEXT is best used. For loops where you
      Message 2 of 21 , Jan 29, 2013
      • 0 Attachment
        Am 29.01.2013 07:54, schrieb Henrik:
        > Thank you mike, your “do”
        > code is very interested to me…
        >

        Generally speaking, every loop construct has its purpose.

        For finite loops, where you exactly know the limits FOR..NEXT is best used.

        For loops where you don't know the end limit, but an end condition, you
        use WHILE..WEND or DO..LOOP.

        Everything can be found in the help file under "Liberty BASIC v4.04 Help
        => Language Syntax and Usage => Logic and Structure => Looping Structures".

        If you just read through the help file, you will have a brief knowledge
        of the available commands, which will help you making better decisions
        for what command to use in the current situation.

        If you complain that the help file is lacking a search feature, this has
        been taking care of already, see http://basic.wikispaces.com/HelpSearch


        --
        Stefan Pendl
        http://stefanpendl.runbasichosting.com/

        LB 4.04 Pro ... http://www.libertybasic.com/assist.html
        LB 4.04 ....... http://www.libertybasic.com/lb404setup.exe

        LB Community Wiki .............. http://basic.wikispaces.com/
        LB Programmer's Encyclopedia ... http://lbpe.wikispaces.com/
        LB Bug Tracker ................. http://libertybasicbugs.wikispaces.com/

        Books at http://www.lulu.com/ and http://www.amazon.com/
        Alyce Watson ... APIs for Liberty BASIC
        Carl Gundel .... Beginning Programming with Liberty BASIC

        Windows 7 Home Premium 64-bit SP1
        AMD Turion X2 RM-70 2GHz, 4GB RAM
      • Henrik
        Thank you Stefan, I found it starts with : Looping Liberty BASIC provides three constructions for looping. One is FOR/NEXT another is WHILE/WEND, and the third
        Message 3 of 21 , Jan 29, 2013
        • 0 Attachment
          Thank you Stefan, I found it starts with :
          Looping
          Liberty BASIC provides three constructions for looping. One is
          FOR/NEXT another is WHILE/WEND, and the third is DO LOOP.
           I have to study them
          very well.
          Thanks again Stefan for the link of searching thru html.
           
           


          ________________________________
          From: Stefan Pendl <pendl2megabit@...>
          To: libertybasic@yahoogroups.com
          Sent: Tuesday, January 29, 2013 1:21 PM
          Subject: Re: [libertybasic] Re: Variable out of loop


           
          Am 29.01.2013 07:54, schrieb Henrik:
          > Thank you mike, your “do”
          > code is very interested to me…
          >

          Generally speaking, every loop construct has its purpose.

          For finite loops, where you exactly know the limits FOR..NEXT is best used.

          For loops where you don't know the end limit, but an end condition, you
          use WHILE..WEND or DO..LOOP.

          Everything can be found in the help file under "Liberty BASIC v4.04 Help
          => Language Syntax and Usage => Logic and Structure => Looping Structures".

          If you just read through the help file, you will have a brief knowledge
          of the available commands, which will help you making better decisions
          for what command to use in the current situation.

          If you complain that the help file is lacking a search feature, this has
          been taking care of already, see http://basic.wikispaces.com/HelpSearch

          --
          Stefan Pendl
          http://stefanpendl.runbasichosting.com/

          LB 4.04 Pro ... http://www.libertybasic.com/assist.html
          LB 4.04 ....... http://www.libertybasic.com/lb404setup.exe

          LB Community Wiki .............. http://basic.wikispaces.com/
          LB Programmer's Encyclopedia ... http://lbpe.wikispaces.com/
          LB Bug Tracker ................. http://libertybasicbugs.wikispaces.com/

          Books at http://www.lulu.com/ and http://www.amazon.com/
          Alyce Watson ... APIs for Liberty BASIC
          Carl Gundel .... Beginning Programming with Liberty BASIC

          Windows 7 Home Premium 64-bit SP1
          AMD Turion X2 RM-70 2GHz, 4GB RAM



          [Non-text portions of this message have been removed]
        Your message has been successfully submitted and would be delivered to recipients shortly.