Robert Hodge
15-07-2013, 23:13
When issuing debugging messages of one sort or another, it's often useful to have the line number where the message originated from. C programmers are familiar with a preprocessor name of __LINE__ used for this purpose.
Lacking any support in TB for this otherwise, you have to manually enter these numbers. Example:
PRINTL "At line 123, COUNT = " & TSTR$(COUNT)
Of course, if this line got moved and was no longer at line number 123, the message produced would be misleading. Maintaining the accuracy of such messages is a thankless drudgery. It would be convenient to have a means to generate such values automatically.
Let's assume there was a built-in string constant that contained this value, and for sake of conciseness, let's call it $LN. Then, the statement above could be rewritten as,
PRINTL "At line " & $LN & ", COUNT = " & TSTR$(COUNT)
Even though $LN appears to be a "constant", it's a constant whose value is unique to the particular line number it appears on, and on every line it's different, of course.
For sake of perhaps performing line-number calculations based on the current line number, a numeric form %LN could also be available. Whereas $LN might be the same as "123" on some line, %LN would be the numeric form 123. If %LN were not made availalbe, we could use VAL($LN) instead.
Lacking any support in TB for this otherwise, you have to manually enter these numbers. Example:
PRINTL "At line 123, COUNT = " & TSTR$(COUNT)
Of course, if this line got moved and was no longer at line number 123, the message produced would be misleading. Maintaining the accuracy of such messages is a thankless drudgery. It would be convenient to have a means to generate such values automatically.
Let's assume there was a built-in string constant that contained this value, and for sake of conciseness, let's call it $LN. Then, the statement above could be rewritten as,
PRINTL "At line " & $LN & ", COUNT = " & TSTR$(COUNT)
Even though $LN appears to be a "constant", it's a constant whose value is unique to the particular line number it appears on, and on every line it's different, of course.
For sake of perhaps performing line-number calculations based on the current line number, a numeric form %LN could also be available. Whereas $LN might be the same as "123" on some line, %LN would be the numeric form 123. If %LN were not made availalbe, we could use VAL($LN) instead.