CX_FILE_SOURCE_RANGE
Class hierarchy
- CX_CLASS
- CX_FILE_SOURCE_RANGE
Description:
Objects of this class represent an area in a source file and provide methods to read, overwrite or open the referenced code in the editor.
The area is defined by the absolute path to the source file, as well as a start and end position. Both start and end positions are defined as (row:column), with both starting at 0. The first character of a file thus has the position (0:0).
Important: The end position defines the position of the first character that no longer belongs to the selected source code area.
This type of definition makes it possible, among other things, to select a certain line from a file without having to know how many characters this line contains at all (since the position of the last character is not needed for this).
To select the 7th line of a file, the range would be defined as follows: (start=(6:0), end=(7:0)).
Code example:
Var(sourceRange)
CreateTransObject(CX_FILE_SOURCE_RANGE) -> sourceRange
"evaluate.cxp" sourceRange Put(File())
FALSE sourceRange Call(Read) // ".... whole file content..."
// now only read the 7th line
6 sourceRange Put(StartLine())
0 sourceRange Put(StartColumn())
7 sourceRange Put(EndLine())
0 sourceRange Put(EndColumn())
FALSE sourceRange Call(Read) // "... 7th line content ... "
Function | MA* | Parameter | Return | Short description |
---|---|---|---|---|
EditSource | Opens the start position of this source range in the source code editor. | |||
EndColumn | * | INTEGER | Column of the end position (starting at 0) | |
EndLine | * | INTEGER | Line of the end position (starting at 0) | |
File | * | STRING | Read/write access to the file name/path for this source range. | |
IsValid | INTEGER | Is this a valid source range definition? | ||
IsValidRange 230223 | INTEGER | Are start & end position valid? | ||
Read | INTEGER | STRING | Reads the defined range from the source file | |
ReadFromString 230177 | STRING | STRING | Reads the defined range from the passed STRING | |
RelativeTo 230177 | CX_FILE_SOURE_RANGE | CX_FILE_SOURCE_RANGE | Computes a new source range relative to the starting position of the passed source range. | |
Rewrite | STRING | Overwrites the defined range in the source file | ||
RewriteInString 230177 | STRING, STRING | STRING | Replaces the defined range in the passed source string with the replacement string. | |
StartColumn | * | INTEGER | Start column of the source range (starting at 0) | |
StartLine | * | INTEGER | Start line of the source range (starting at 0) |
* MA = Member access function,
greyed out = inherited function
Data field | Type | Reference class | I* | Brief description |
---|---|---|---|---|
* I = Indexable data field,
greyed out = inherited data field.
Module | Brief description |
---|---|