Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pete's Dumb Idea of the Day!
#13
(10-23-2024, 01:01 AM)Pete Wrote: Well with Select Case you would use...

Code: (Select All)
 
Rem  demo Restore : On x Restore idea    vs Select Case
For x = 1 To 4
     Select Case x
        Case 1
            Restore data1
        Case 2
            Restore data2
        Case 3
            Restore data3
        Case 4
            Restore data4
    End Select
    Print "----------------------------------------------"
    Read number, nam$, Order$
    Print number, nam$, Order$
Next
End
data1:
Data 1,one,the first
data2:
Data 2,two,the second
data3:
Data 3,three,the third
data4:
Data 4,four,the forth

Pete

Yes Pete you're right
please pay attention to the fact that the FOR loop starts with a value 0 that hasn't been managed by Select case and it triggers a runtime error, while in the complex and tortuose way of ON x GOSUB ... RESTORE /RETURN  it goes on.
In other words, 0 has been used to simulate an unpredictable value of X. Using Select case you must sure that X takes always a predictable value. Using the tortuose way you can avoid this task of predictable value.

All the good and clever ways posted here need to know how many data field are in the code and must sure that it would be used the range of that value in the code.
Please pay attention: 
the tortuose way is not better than the others, but it is nearer old fashion way of coding when DATA was a new great opportunity to bring informations into code.
And in my mind DATA is a good resource of the past.

It's fun and useful getting infos and experiences of professional coders.
Reply


Messages In This Thread
Pete's Dumb Idea of the Day! - by Pete - 10-21-2024, 07:53 PM
RE: Pete's Dumb Idea of the Day! - by TDarcos - 10-23-2024, 02:47 AM
RE: Pete's Dumb Idea of the Day! - by CharlieJV - 10-22-2024, 12:01 AM
RE: Pete's Dumb Idea of the Day! - by dano - 10-22-2024, 01:08 AM
RE: Pete's Dumb Idea of the Day! - by Pete - 10-22-2024, 05:55 AM
RE: Pete's Dumb Idea of the Day! - by bplus - 10-22-2024, 10:40 AM
RE: Pete's Dumb Idea of the Day! - by a740g - 10-22-2024, 11:46 AM
RE: Pete's Dumb Idea of the Day! - by Petr - 10-22-2024, 03:57 PM
RE: Pete's Dumb Idea of the Day! - by Pete - 10-23-2024, 01:01 AM
RE: Pete's Dumb Idea of the Day! - by TempodiBasic - 10-23-2024, 07:31 AM
RE: Pete's Dumb Idea of the Day! - by SMcNeill - 10-23-2024, 03:54 AM
RE: Pete's Dumb Idea of the Day! - by Pete - 10-23-2024, 07:59 AM
RE: Pete's Dumb Idea of the Day! - by CharlieJV - 10-23-2024, 01:07 PM
RE: Pete's Dumb Idea of the Day! - by Pete - 10-23-2024, 05:37 PM
RE: Pete's Dumb Idea of the Day! - by CharlieJV - 10-23-2024, 08:09 PM
RE: Pete's Dumb Idea of the Day! - by Pete - 10-23-2024, 10:29 PM



Users browsing this thread: 14 Guest(s)