here is a code that i simplified
with Ada.Text_Io;
procedure Help
is
Double_Quote : constant String(1 .. 1) := (others => '"' );
Data : constant String := " PLUS_STRING : CONSTANT STRING(1..3) :=(1 =>'" & Double_Quote & "' , 2 =>'+' , 3 =>'" & Double_Quote & ");";
begin
Ada.Text_Io.Put_Line(" 05 10 15 20 25 30 35 40 45 50 55 65 70 75 80 85 90");
Ada.Text_Io.Put_Line(" ....|....!....|....!....|....!....|....!....|....!....|....!....|....!....|....!....|....!");
Ada.Text_Io.Put_Line("»" & Data & "« " & Data'Last'Img);
end Help;
but the data'last seems not to match the string size
However, it's important to remember that 'Last is not necessarily the
same as 'Length because 'First is not necessarily one. This is
especially important in subprograms that take String parameters, as they
are often passed slices.
Ada.Text_Io.Put_Line(" 05 10 15 20 25 30 35 40 45 50 55 65 70 75 80 85 90");
Ada.Text_Io.Put_Line(" ....|....!....|....!....|....!....|....!....|....!....|....!....|....!....|....!....|....!");
Ada.Text_Io.Put_Line("»" & Data & "« " & Data'Last'Img);
Double_Quote : constant String(1 .. 1) := (others => '"' );
Data : constant String := " PLUS_STRING : CONSTANT STRING(1..3) :=(1 =>'" & Double_Quote & "' , 2 =>'+' , 3 =>'" & Double_Quote & ");";
On 2023-05-05 11:51, Daniel Gaudry wrote:
Data : constant String := " PLUS_STRING :
CONSTANT STRING(1..3) :=(1 =>'" & Double_Quote & "' , 2 =>'+' , 3 =>'"
& Double_Quote & ");";
Wouldn't it be simpler and clearer to write this as
Data : constant String := " PLUS_STRING : CONSTANT STRING := " & '"' &
'+' & '"';
? Note also that you seem to be missing an apostrophe (''') before the
right parenthesis if you intend Data to be a valid Ada declaration.
Or like this (doubling the quotes, which is the way to _escape_ the
double quote inside Ada strings):
Data : constant String := " PLUS_STRING :
CONSTANT STRING(1..3) :=(1 =>'""' , 2 =>'+' , 3 =>'""');";
Manuel Gomez <mgrojo@gmail.com> writes:
Or like this (doubling the quotes, which is the way to _escape_ the
double quote inside Ada strings):
Data : constant String := " PLUS_STRING :
CONSTANT STRING(1..3) :=(1 =>'""' , 2 =>'+' , 3 =>'""');";
'"' is a single quote character.
"""" is a string containing one quote character.
Yes, and "'""'" is a string containing a quote as an Ada character (when displayed).
El 5/5/23 a las 18:33, Simon Wright escribió:
Manuel Gomez <mgrojo@gmail.com> writes:
Or like this (doubling the quotes, which is the way to _escape_ the'"' is a single quote character.
double quote inside Ada strings):
Data : constant String := " PLUS_STRING :
CONSTANT STRING(1..3) :=(1 =>'""' , 2 =>'+' , 3 =>'""');";
"""" is a string containing one quote character.
Yes, and "'""'" is a string containing a quote as an Ada character
(when displayed).
Manuel Gomez <mgrojo@gmail.com> writes:
El 5/5/23 a las 18:33, Simon Wright escribió:
Manuel Gomez <mgrojo@gmail.com> writes:
Data : constant String := " PLUS_STRING :'"' is a single quote character.
CONSTANT STRING(1..3) :=(1 =>'""' , 2 =>'+' , 3 =>'""');";
"""" is a string containing one quote character.
Yes, and "'""'" is a string containing a quote as an Ada character
(when displayed).
Oh, I see. Ugh.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 349 |
Nodes: | 16 (0 / 16) |
Uptime: | 142:37:02 |
Calls: | 7,613 |
Calls today: | 1 |
Files: | 12,790 |
Messages: | 5,684,458 |