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

Re: [libertybasic] On goto

Expand Messages
  • David Speck
    Robert, I m not sure what values j can assume, and it s been a very long time since I wrote anything in that old BASIC dialect, but assuming that j can
    Message 1 of 4 , Jul 10, 2013
      Robert,

      I'm not sure what values "j" can assume, and it's been a very long time
      since I wrote anything in that old BASIC dialect, but assuming that j
      can assume numeric values from 1 to n, then in LB, the best approach
      would be:

      SELECT CASE j
      CASE 1
      'basic code
      'goes here
      CASE 2
      'basic code
      'goes here
      CASE 3
      'basic code
      'goes here
      .....
      .....
      CASE n
      'basic code
      'goes here

      CASE else 'how to handle all other undefined values of j
      'basic code
      'goes here
      END SELECT


      HTH,

      Dave


      On 7/10/2013 9:35 PM, Robert wrote:
      > I am converting an old Basic program to Liberty Basic.
      > I have a line that reads: On j goto 1012,1020,1030,1040(for about 50 branches) Any idea how to make this work in Liberty Basic?
    • Robert
      Hi Dave, Thanks for your suggestion. Someone else also suggested the case idea. It would work as would if then. Problem is, I would need a series of 50 select
      Message 2 of 4 , Jul 11, 2013
        Hi Dave,
        Thanks for your suggestion. Someone else also suggested the case idea.
        It would work as would if then. Problem is, I would need a series of 50 select case or if then. I am thinking that there is no easy way.
        Thanks again, Bob
        >
        >
        > On 7/10/2013 9:35 PM, Robert wrote:
        > > I am converting an old Basic program to Liberty Basic.
        > > I have a line that reads: On j goto 1012,1020,1030,1040(for about 50 branches) Any idea how to make this work in Liberty Basic?
        >
      • Stefan Pendl
        ... Depending on the information used to trigger the 50 On Goto cases, there might be other ways, that would be simpler now, but impossible to implement at
        Message 3 of 4 , Jul 11, 2013
          Am 11.07.2013 20:51, schrieb Robert:
          >
          > Hi Dave,
          > Thanks for your suggestion. Someone else also suggested the case idea.
          > It would work as would if then. Problem is, I would need a series of 50 select case or if then. I am thinking that there is no easy way.
          > Thanks again, Bob

          Depending on the information used to trigger the 50 "On Goto" cases,
          there might be other ways, that would be simpler now, but impossible to
          implement at the time of the creation of the listing.

          Can you show a run-able simple example duplicating the "On Goto" issue,
          so we can better help you getting rid of it.


          --
          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
        Your message has been successfully submitted and would be delivered to recipients shortly.