Built-in macros: $line

The $line macro is replaced by an unsigned integer literal identifying the number of the current code line where the macro appears.

Content

unsigned integer literal

Discussion

The numbering of code lines starts always with the value 1 for every first line within the body of a method or an inline code. The line numbering of one method is thus not affected by the content of another methods. After the first line all following code lines are numbered consecutively with the values 2, 3, 4, ...

The macro $line can be used inside a regular Chora expression wherever an unsigned integer operand is allowed. For example, you can set a variable of a just created object to the current line number allowing you later to determine the location where the object has been created:

var SomeUnit::SomeClass theObject = new SomeUnit::SomeClass; theObject.CreatedAtLine = $line; theObject.CreatedInMethod = "$path";

It is also possible to use the macro directly within a string literal to format e.g. a trace debug message:

trace "Error at the $line in method $path";