Functions and description of lines

Status
Not open for further replies.

Binome

Full Member level 3
Joined
Nov 16, 2009
Messages
152
Helped
2
Reputation
4
Reaction score
2
Trophy points
1,298
Location
Lyon, France
Activity points
2,405
Hi,
I've downloaded a project with a testbench where LINE type is used.
I read
Code:
variable line_in : line
then
Code:
if(line_in(1)='.') then...
I don't understand this handling very well. The line_in object is a pointer to a characters string, right? Then line_in(1) means the first character?
I'd like a precise description of that.
 

using the
USE std.textio.ALL;
for text related operations,

variable line_in:line;
makes the text buffer line_in of 'line' type

and line_in(1) points to the specified character in the buffer.
 


Yes, you are correct. But be aware that because it's a pointer then line_in(1) may not exist and you'll get a bad pointer reference error during runtime.
For example:
Accessing a line thats been used already in writeline, as writeline deallocations the pointer
Accessing a line that hasnt been created from a readline
Createing the pointer manually, that doesnt have index 1:

line_in := new string(2 to 10);
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…