Line Numbers: How can I put in Error line numbers? 
Author Message
 Line Numbers: How can I put in Error line numbers?

I would like to put error line numbers in my code.  How can I do that?  I
know that there are 3rd party controls that do this...but I am not
interested in those.

Any ideas?



Sun, 20 May 2001 03:00:00 GMT  
 Line Numbers: How can I put in Error line numbers?
Access uses labels rather than line numbers.

Just put the label (ending with a semicolon) on a line by itself.

HTH
        - Turtle



Quote:
> I would like to put error line numbers in my code.  How can I do that?  I
> know that there are 3rd party controls that do this...but I am not
> interested in those.

> Any ideas?



Sun, 20 May 2001 03:00:00 GMT  
 Line Numbers: How can I put in Error line numbers?

(This definitely works in VB5+)

Simply put line numbers infront of your code like so

for zz = 1 to 100
    print zz
    if zz > 50 then print "less than 50"
next zz

Becomes:

10 for zz = 1 to 100
20   print zz
30    if zz > 50 then print "less than 50"
40 next zz

Remember the old fashioned BASIC that needed this???

Then if you get a runtime error, the error line is no longer 0 but the line
it occurred on.

I think this is somewhat undocumented.

Dan


Quote:
>I would like to put error line numbers in my code.  How can I do that?  I
>know that there are 3rd party controls that do this...but I am not
>interested in those.

>Any ideas?



Sun, 20 May 2001 03:00:00 GMT  
 Line Numbers: How can I put in Error line numbers?

Quote:

> I would like to put error line numbers in my code.  How can I do that?  I
> know that there are 3rd party controls that do this...but I am not
> interested in those.

> Any ideas?

James,

I use a utility called VB Sentinel.  You can downloaded it from their
web site.  It has a whole bunch of features, including setting up error
traps for you.

I make a copy of my source code right before shipping a version.  I then
use VB Sentinel to add line numbers (I have my own error traps) to all
of the code.  Then I compile and put it into my distribution software.
It can be very useful when debugging shipped software to know exactly
what line of code generated the error.

VB Sentinel Junior is or at least was free.



Mon, 21 May 2001 03:00:00 GMT  
 Line Numbers: How can I put in Error line numbers?
On Wed, 2 Dec 1998 09:56:11 -0800, "James Anderson"

Quote:

>I would like to put error line numbers in my code.  How can I do that?  I
>know that there are 3rd party controls that do this...but I am not
>interested in those.

Then you're going to have to do them by hand.

Line numbers are ugly and unnecessary if you structure your code
right.  Take the following example:

Private Sub cmdDelete_Click()

On Error GoTo cmdDelete_Click_Error

Dim sSQL As String, sLinkToDelete As String
Dim iter As Integer, iRet As Integer
Dim rrsDelete As rdoResultset

If Len(Me.txtLinkName.Text) = 0 Then Err.Raise
UER_LINK_NAME_NOT_PROVIDED
sLinkToDelete = Me.txtLinkName.Text

If Me.lstLinkName.ListIndex = -1 Then Err.Raise UER_LINK_DNE

sSQL = ResStr(sqlMediaLinkDelete, msSportDB, _
  IIf(msSportDB = "GLF", "tournament_id", "game_id"), _
  mlGameID, DQ(sLinkToDelete), Me.lstLinkTypes.ListIndex + 1)
iRet = SetResultset(rrsDelete, sSQL)
If iRet = RETURNED_ERROR Then
    msBadQuery = sSQL
    Err.Raise UER_BAD_QUERY
End If

Call RetrieveSpecificLinks
If Me.lstLinkName.ListCount > 0 Then Me.lstLinkName.ListIndex = 1

cmdDelete_Click_Exit:
    Exit Sub

cmdDelete_Click_Error:
    msOffendingFunction = IIf(msOffendingFunction = ZLS, _
      "frmMediaLinks.cmdDelete_Click", msOffendingFunction)
    With Err
        Select Case .Number
            Case UER_BAD_QUERY
                Call HandleException(.Number, Me.OffendingFunction, _
                .Description, ResStr(ureBadQuery), _
                ResStr(urdBadQuery, msBadQuery))
            Case UER_LINK_NAME_NOT_PROVIDED
                Call HandleException(.Number, Me.OffendingFunction, _
                .Description, ResStr(ureLinkNameNotProvided), _
                ResStr(urdLinkNameNotProvided))
            Case UER_LINK_DNE
                Call HandleException(.Number, Me.OffendingFunction, _
                .Description, ResStr(urdLinkDNE), _
                ResStr(ureLinkDNE))
            Case Else
                Call HandleException(.Number, Me.OffendingFunction, _
                  .Description)
        End Select
    End With
    Resume cmdDelete_Click_Exit

End Sub

If you check for error conditions after each potential error-inducing
block, error handling becomes much more straightforward.

--Elocutus
===
"Capitalism undoubtedly has certain boils and
blotches upon it, but has it as many as government?
Has it as many as marriage? Has it as many as
religion? I doubt it. It is the only basic
institution of modern man that shows any genuine
health and vigor."  --H. L. Mencken



Mon, 21 May 2001 03:00:00 GMT  
 Line Numbers: How can I put in Error line numbers?

Quote:

> I would like to put error line numbers in my code.  How can I do that?  I
> know that there are 3rd party controls that do this...but I am not
> interested in those.

> Any ideas?

Use assert().  Or you can override it to accomplish more fancy handling.
But it does give you error line number.

---Charles



Mon, 21 May 2001 03:00:00 GMT  
 Line Numbers: How can I put in Error line numbers?

Quote:

>(This definitely works in VB5+)
...
>10 for zz = 1 to 100
>20   print zz
>30    if zz > 50 then print "less than 50"
>40 next zz
>I think this is somewhat undocumented.

Zow!  I didn't know that.

Now, can I find my 1983-vintage program for removing unreferenced line
numbers from BASCOM programs? <g>

Joshua Stern



Sat, 26 May 2001 03:00:00 GMT  
 Line Numbers: How can I put in Error line numbers?
There is a freeware application called VoodooCoder which will do all this
and more.

VoodooCoder II is also available, but this is not free.

get them both at http://www.voodoo-software.com


Quote:
>I would like to put error line numbers in my code.  How can I do that?  I
>know that there are 3rd party controls that do this...but I am not
>interested in those.

>Any ideas?



Mon, 28 May 2001 03:00:00 GMT  
 Line Numbers: How can I put in Error line numbers?
You can download an Access add-in from Dev Ashish's site
( http://home.att.net/~dashish )

Look for wzComment in the Downloads section.

It will
    Block Comment
    Block Un-Commnet
    Procedure Comment
    Insert Line numbers
    Remove line numbers
    Create a procedure skeleton (including comments and errorhandling)


Quote:
>There is a freeware application called VoodooCoder which will do all this
>and more.

>VoodooCoder II is also available, but this is not free.

>get them both at http://www.voodoo-software.com



>>I would like to put error line numbers in my code.  How can I do that?  I
>>know that there are 3rd party controls that do this...but I am not
>>interested in those.

>>Any ideas?



Tue, 29 May 2001 03:00:00 GMT  
 Line Numbers: How can I put in Error line numbers?

I put the following the the Form_Load even and it didn't do a thing.

Quote:

> for zz = 1 to 100
>     print zz
>     if zz > 50 then print "less than 50"
> next zz

What am I missing?


Thu, 31 May 2001 03:00:00 GMT  
 Line Numbers: How can I put in Error line numbers?

Quote:


>I put the following the the Form_Load even and it didn't do a thing.

>> for zz = 1 to 100
>>     print zz
>>     if zz > 50 then print "less than 50"
>> next zz
>What am I missing?

Doing Print to a form writes to the visible window, not to the image of the
form in memory that is used to repaint it when the window becomes visible.
Since you did this in form_load, the form was not visible yet so when it was
finally drawn all your changes were lost.

Three alternatives:
1. move your code to form_paint or form_activate (this will cause it to run
again whenever these events fire
2. insert "Me.Show" and "Me.Refresh" before your code in form_load to force
the window to be visible (your changes will be lost if another window covers
your form
3. set the .AutoRedraw property of the form to True.  This takes up more
memory, but forces all changes to the form to be copied to the internal
image so that it is available automatically



Thu, 31 May 2001 03:00:00 GMT  
 Line Numbers: How can I put in Error line numbers?
Hi Jim,

Jim Holloman schrieb in Nachricht ...

Quote:

>I put the following the the Form_Load even and it didn't do a thing.

>> for zz = 1 to 100
>>     print zz
>>     if zz > 50 then print "less than 50"
>> next zz

>What am I missing?

If I'm not wrong, your "Print" command wants to print to the form, which, in
the Form_Load() event isn't loaded.
This won't raise an error, but after the Form_Load() is through, the form
will be loaded entirely (and painted), and your printings are lost.
You could either use the Form_Activate() event to do the printing, or put a
Show command in front of the printing loop.

Hope this helps ...

Rene Whitworth
Whitworth Software Solutions - Germany
http://www.geocities.com/SiliconValley/8928 (under construction)
Please reply to the newsgroup :-)



Fri, 01 Jun 2001 03:00:00 GMT  
 Line Numbers: How can I put in Error line numbers?
I assume you know that VB supports line numbers already.  There is an
undocumented function (been there since Tandy Color computer Basic that I
can remember) called ERL.

For example

10 Dim x as integer
15 on error goto ErrorNumber
20 X  = 6
30 print x / 0
exit sub
ErrorNumber:
msgbox ERL

The messagebox will print 30.

Joel Hopper


Quote:
>There is a freeware application called VoodooCoder which will do all this
>and more.

>VoodooCoder II is also available, but this is not free.

>get them both at http://www.voodoo-software.com



>>I would like to put error line numbers in my code.  How can I do that?  I
>>know that there are 3rd party controls that do this...but I am not
>>interested in those.

>>Any ideas?



Mon, 18 Jun 2001 03:00:00 GMT  
 Line Numbers: How can I put in Error line numbers?
Someone probably already mentioned this, but if you'd like to use line
numbers for test purposes make a utility to add/strip the line number from
the routines within the Bas, frm, and cls files.  It'll save a LOT of pain
on your part if you're doing a large test, and makes life reeal easy for QA.
Quote:

>I assume you know that VB supports line numbers already.  There is an
>undocumented function (been there since Tandy Color computer Basic that I
>can remember) called ERL.

>For example

>10 Dim x as integer
>15 on error goto ErrorNumber
>20 X  = 6
>30 print x / 0
>exit sub
>ErrorNumber:
>msgbox ERL

>The messagebox will print 30.

>Joel Hopper



>>There is a freeware application called VoodooCoder which will do all this
>>and more.

>>VoodooCoder II is also available, but this is not free.

>>get them both at http://www.voodoo-software.com



>>>I would like to put error line numbers in my code.  How can I do that?  I
>>>know that there are 3rd party controls that do this...but I am not
>>>interested in those.

>>>Any ideas?



Wed, 20 Jun 2001 03:00:00 GMT  
 
 [ 14 post ] 

 Relevant Pages 

1. PBM: Line numbers used by Goto method do not reflect displayed line numbers in document

2. Line numbers into multi-line text box

3. Error Handler -- Getting Line Number of error

4. Error Handler - How to get line number where error occurred

5. Access 97 Error Logging - Line Number

6. Returning the line number with the error message

7. Line number or function name for an error?

8. module / function / line number information on runtime errors

9. Error handling & line numbers

10. Adding line numbers to code for error handling

11. HELP: Finding line number of error using Erl

12. Runtime error line number?

 

 
Powered by phpBB® Forum Software