Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
IDE - just a thought on Next and Out of Subscript
#7
(05-14-2023, 05:40 PM)bplus Wrote: Hi Dimster,

As KernelPanic has shown, the regular Subscript error shows the line number at fault but I added it to our little error handler code because there is the codeword _ErrorLine
Code: (Select All)
On Error GoTo ehandle
Dim a(1 To 15)
For i = 1 To 20
    a(i) = i ' error at i = 16
Next
End

ehandle:
Print "Index i is"; i
Print "Error line "; _ErrorLine
Print "Error: "; Err
End

Yeah also your error could occur way up the line of code and not effect anything until the rubber meets the road like a subscript error. IDE would have to be pretty darn smart to say, "Hey dude, that's a typo or the wrong variable on line xxx, you should fix it before you get a subscript out of range error on line yyy."

Even then, the IDE can't catch a runtime error.  For example, have the IDE tell you what's wrong with the  following:

DIM foo(100)
INPUT "Which foo do you want?"; query
PRINT foo(query)

Now, enter -1 as an user input.  Or 102.  Or 3.6...  Or "football"...

How's the IDE going to tell you the code is wrong, when there's technically nothing invalid to it?  It's only at runtime where the user can enter an invalid response that the program glitches.
Reply


Messages In This Thread
RE: IDE - just a thought on Next and Out of Subscript - by SMcNeill - 05-14-2023, 05:53 PM



Users browsing this thread: 2 Guest(s)