I try to create a program that read Unbounded strings from a file in the loop:
Open(C_File, In_File, To_String(Inp_File));
while not End_of_File(C_File) loop
str_line_n := To_Unbounded_String(Get_Line(C_File));
Buffer_GL.Set_Buffer(str_line_n); -- breakpoint on this line
glade_lines := glade_lines + 1;
end loop;
Close(C_File);
where str_line_n is of the type Unbounded_String.
I used a test file with the below presented three text lines:
Line 1 abcdef9876543210
Line 2 " abcdef"9876543210
Line 3 "abc"de"f"9876543210
In the debugger the results were:
"Line 1 abcdef 9876543210"
"Line 2 "" abcdef"" 98765432"
"Line 3 ""abc""de ""f""987654"
On 2023-01-10 15:16, ldries46 wrote:
I try to create a program that read Unbounded strings from a file in
the loop:
Open(C_File, In_File, To_String(Inp_File));
while not End_of_File(C_File) loop
str_line_n := To_Unbounded_String(Get_Line(C_File));
Buffer_GL.Set_Buffer(str_line_n); -- breakpoint on this line
glade_lines := glade_lines + 1;
end loop;
Close(C_File);
where str_line_n is of the type Unbounded_String.
I used a test file with the below presented three text lines:
Line 1 abcdef9876543210
Line 2 " abcdef"9876543210
Line 3 "abc"de"f"9876543210
In the debugger the results were:
"Line 1 abcdef 9876543210"
"Line 2 "" abcdef"" 98765432"
"Line 3 ""abc""de ""f""987654"
It seems that the debugger displays the strings in the form of Ada
string literals, which are enclosed in quotes (") and within which
each quote character has to be duplicated (to show that it is not the terminating quote). So the duplication of the quotes is nothing to
worry about. If you were to print out the strings (with Ada.Text_IO)
they should appear just as in the input, with only the original quote characters.
However, your example also shows some extra blank spaces in the
debugger output, for example:
Input : Line 1 abcdef9876543210
Debugger: "Line 1 abcdef 9876543210"
Op 10-1-2023 om 19:12 schreef Niklas Holsti:In the mean time by inserting a write command to a Gtk window I found
On 2023-01-10 15:16, ldries46 wrote:Not only that but also some of the last characters disappear in line
I try to create a program that read Unbounded strings from a file in
the loop:
Open(C_File, In_File, To_String(Inp_File));
while not End_of_File(C_File) loop
str_line_n := To_Unbounded_String(Get_Line(C_File));
Buffer_GL.Set_Buffer(str_line_n); -- breakpoint on this line
glade_lines := glade_lines + 1;
end loop;
Close(C_File);
where str_line_n is of the type Unbounded_String.
I used a test file with the below presented three text lines:
Line 1 abcdef9876543210
Line 2 " abcdef"9876543210
Line 3 "abc"de"f"9876543210
In the debugger the results were:
"Line 1 abcdef 9876543210"
"Line 2 "" abcdef"" 98765432"
"Line 3 ""abc""de ""f""987654"
It seems that the debugger displays the strings in the form of Ada
string literals, which are enclosed in quotes (") and within which
each quote character has to be duplicated (to show that it is not the
terminating quote). So the duplication of the quotes is nothing to
worry about. If you were to print out the strings (with Ada.Text_IO)
they should appear just as in the input, with only the original quote
characters.
However, your example also shows some extra blank spaces in the
debugger output, for example:
Input : Line 1 abcdef9876543210
Debugger: "Line 1 abcdef 9876543210"
2 the 10 and in line 3 3210
Op 10-1-2023 om 19:12 schreef Niklas Holsti:
On 2023-01-10 15:16, ldries46 wrote:Not only that but also some of the last characters disappear in line 2
I try to create a program that read Unbounded strings from a file in
the loop:
Open(C_File, In_File, To_String(Inp_File));
while not End_of_File(C_File) loop
str_line_n := To_Unbounded_String(Get_Line(C_File));
Buffer_GL.Set_Buffer(str_line_n); -- breakpoint on this line
glade_lines := glade_lines + 1;
end loop;
Close(C_File);
where str_line_n is of the type Unbounded_String.
I used a test file with the below presented three text lines:
Line 1 abcdef9876543210
Line 2 " abcdef"9876543210
Line 3 "abc"de"f"9876543210
In the debugger the results were:
"Line 1 abcdef 9876543210"
"Line 2 "" abcdef"" 98765432"
"Line 3 ""abc""de ""f""987654"
It seems that the debugger displays the strings in the form of Ada
string literals, which are enclosed in quotes (") and within which
each quote character has to be duplicated (to show that it is not the
terminating quote). So the duplication of the quotes is nothing to
worry about. If you were to print out the strings (with Ada.Text_IO)
they should appear just as in the input, with only the original quote
characters.
However, your example also shows some extra blank spaces in the
debugger output, for example:
Input : Line 1 abcdef9876543210
Debugger: "Line 1 abcdef 9876543210"
the 10 and in line 3 3210
On 2023-01-11 0:17, ldries46 wrote:
Op 10-1-2023 om 19:12 schreef Niklas Holsti:
On 2023-01-10 15:16, ldries46 wrote:Not only that but also some of the last characters disappear in line
I try to create a program that read Unbounded strings from a file
in the loop:
Open(C_File, In_File, To_String(Inp_File));
while not End_of_File(C_File) loop
str_line_n := To_Unbounded_String(Get_Line(C_File)); >>>> Buffer_GL.Set_Buffer(str_line_n); -- breakpoint on this line
glade_lines := glade_lines + 1;
end loop;
Close(C_File);
where str_line_n is of the type Unbounded_String.
I used a test file with the below presented three text lines:
Line 1 abcdef9876543210
Line 2 " abcdef"9876543210
Line 3 "abc"de"f"9876543210
In the debugger the results were:
"Line 1 abcdef 9876543210"
"Line 2 "" abcdef"" 98765432"
"Line 3 ""abc""de ""f""987654"
It seems that the debugger displays the strings in the form of Ada
string literals, which are enclosed in quotes (") and within which
each quote character has to be duplicated (to show that it is not
the terminating quote). So the duplication of the quotes is nothing
to worry about. If you were to print out the strings (with
Ada.Text_IO) they should appear just as in the input, with only the
original quote characters.
However, your example also shows some extra blank spaces in the
debugger output, for example:
Input : Line 1 abcdef9876543210
Debugger: "Line 1 abcdef 9876543210"
2 the 10 and in line 3 3210
My guess is that these differences are bugs in the debugger's display
of strings with embedded quote characters. For Line 1, which has no
embedded quotes, the full string is displayed (though with an inserted blank). For Line 2, with two embedded quotes, two of the last
characters are not displayed. For Line 3, with four embedded quotes,
four of the last characters are not displayed. It seems that the
debugger does not realize that doubling the quote characters makes the displayed string longer...
Try to print the strings with Ada.Text_IO instead, that should give
the right result. In other words, your code reading the strings works,
but the debugger is probably buggy. (One reason why I avoid debuggers whenever I can.)
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 379 |
Nodes: | 16 (2 / 14) |
Uptime: | 44:10:46 |
Calls: | 8,141 |
Calls today: | 4 |
Files: | 13,085 |
Messages: | 5,857,953 |