Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
On Exit question
#24
1st I apologize to NasaCow, hope the discussion on Option _Explicit may help with the search for/correction of the error you were looking for help on.

2nd ... the issue/learning lesson, for me in this thread is Dimensioned variables v's UnDimensioned variables. In particular a control variable. I have often seen the use of "i" or "j" or "x" being used in many books on Qbasic where these control variables are not Dimmed. They appear to be throw away variables in terms of their use is not material to math formulas or capture of a results of a process. They can be used over and over again as a control variable because their type is defined by default and their value is clearly defined in a range (ie 1 to 10). The only time I will Dim a control variable like "x" is if I need it to carry over into a subroutine or back to the main module.

The Dimming of a control variable, in my experience just added to multiple lines of Dim and Dim Shared in a large program. Plus it doesn't help with the ending value , or limiting the control range. For example 

Code: (Select All)
Dim Shared y(1 To 10)
Dim x

For x = 1 To 10
    Print "Hello World"
Next
Print
Print x
Print
Print
For y = 1 To 10
    Print "Hello back at ya"
Next
Print
Print y

In each case x and y finished outside of the control range, so I have to be careful when I do Dim x or y to use in another sub or function. 

Not sure I see the value in Option _Explicit for control variables, nor how Dimensioning all control variables is a "Best Practice" but this old dog is definitely learning new tricks by trial and error especially when some masterfully programmers are highlighting the new trick.
Reply


Messages In This Thread
On Exit question - by NasaCow - 06-02-2023, 03:50 AM
RE: On Exit question - by mnrvovrfc - 06-02-2023, 05:29 AM
RE: On Exit question - by NasaCow - 06-02-2023, 06:00 AM
RE: On Exit question - by mnrvovrfc - 06-02-2023, 08:59 AM
RE: On Exit question - by Dimster - 06-02-2023, 11:19 AM
RE: On Exit question - by TerryRitchie - 06-02-2023, 11:27 AM
RE: On Exit question - by Dimster - 06-02-2023, 12:28 PM
RE: On Exit question - by Kernelpanic - 06-02-2023, 01:54 PM
RE: On Exit question - by TerryRitchie - 06-02-2023, 05:33 PM
RE: On Exit question - by bplus - 06-02-2023, 01:28 PM
RE: On Exit question - by bplus - 06-02-2023, 02:21 PM
RE: On Exit question - by Kernelpanic - 06-02-2023, 08:23 PM
RE: On Exit question - by bplus - 06-02-2023, 02:36 PM
RE: On Exit question - by bplus - 06-02-2023, 03:14 PM
RE: On Exit question - by bplus - 06-02-2023, 08:19 PM
RE: On Exit question - by bplus - 06-02-2023, 08:27 PM
RE: On Exit question - by Kernelpanic - 06-02-2023, 08:40 PM
RE: On Exit question - by Dimster - 06-02-2023, 09:33 PM
RE: On Exit question - by mnrvovrfc - 06-02-2023, 09:44 PM
RE: On Exit question - by TerryRitchie - 06-02-2023, 10:52 PM
RE: On Exit question - by bplus - 06-02-2023, 10:59 PM
RE: On Exit question - by TerryRitchie - 06-02-2023, 11:12 PM
RE: On Exit question - by bplus - 06-02-2023, 11:21 PM
RE: On Exit question - by Dimster - 06-03-2023, 01:29 PM
RE: On Exit question - by SMcNeill - 06-03-2023, 01:51 PM
RE: On Exit question - by Dimster - 06-03-2023, 03:10 PM
RE: On Exit question - by TerryRitchie - 06-03-2023, 07:21 PM
RE: On Exit question - by Kernelpanic - 06-03-2023, 03:26 PM
RE: On Exit question - by NasaCow - 06-04-2023, 03:03 AM
RE: On Exit question - by bplus - 06-04-2023, 03:20 PM
RE: On Exit question - by TempodiBasic - 06-04-2023, 04:05 PM
RE: On Exit question - by TempodiBasic - 06-04-2023, 05:38 PM
RE: On Exit question - by TerryRitchie - 06-04-2023, 08:35 PM
RE: On Exit question - by TempodiBasic - 06-04-2023, 10:51 PM
RE: On Exit question - by NasaCow - 06-04-2023, 11:59 PM
RE: On Exit question - by TerryRitchie - 06-05-2023, 12:31 AM
RE: On Exit question - by NasaCow - 06-05-2023, 12:50 AM
RE: On Exit question - by SMcNeill - 06-05-2023, 09:04 PM
RE: On Exit question - by bplus - 06-05-2023, 09:09 PM
RE: On Exit question - by SMcNeill - 06-05-2023, 09:17 PM
RE: On Exit question - by SMcNeill - 06-07-2023, 01:38 AM
RE: On Exit question - by TempodiBasic - 06-07-2023, 09:08 AM
RE: On Exit question - by TempodiBasic - 06-07-2023, 09:31 AM
RE: On Exit question - by NasaCow - 06-08-2023, 12:05 AM
RE: On Exit question - by mnrvovrfc - 06-09-2023, 09:31 PM
RE: On Exit question - by TempodiBasic - 06-09-2023, 09:14 PM
RE: On Exit question - by bplus - 06-10-2023, 05:24 PM
RE: On Exit question - by TempodiBasic - 06-17-2023, 12:18 AM
RE: On Exit question - by bplus - 06-17-2023, 02:29 AM
RE: On Exit question - by GareBear - 06-17-2023, 01:07 AM
RE: On Exit question - by TempodiBasic - 06-22-2023, 12:01 PM
RE: On Exit question - by bplus - 06-22-2023, 12:22 PM
RE: On Exit question - by TempodiBasic - 06-22-2023, 07:45 PM



Users browsing this thread: 71 Guest(s)