From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: * X-Spam-Status: No, score=1.3 required=5.0 tests=BAYES_00,INVALID_MSGID, MSGID_RANDY,WEIRD_QUOTING autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,cf72236526e50aab X-Google-Attributes: gid103376,public From: Robert Dewar Subject: Re: newbie question: the " character inside a string Date: 2000/05/24 Message-ID: <8ggste$fin$1@nnrp1.deja.com>#1/1 X-Deja-AN: 626700621 References: <8ggcnp$83r$1@inf2.informatik.uni-stuttgart.de> <8ggrm2$ein$1@nnrp1.deja.com> X-Http-Proxy: 1.0 x54.deja.com:80 (Squid/1.1.22) for client 205.232.38.14 Organization: Deja.com - Before you buy. X-Article-Creation-Date: Wed May 24 15:36:16 2000 GMT X-MyDeja-Info: XMYDJUIDrobert_dewar Newsgroups: comp.lang.ada X-Http-User-Agent: Mozilla/4.61 [en] (OS/2; I) Date: 2000-05-24T00:00:00+00:00 List-Id: In article <8ggrm2$ein$1@nnrp1.deja.com>, Ted Dennison wrote: > In article <8ggcnp$83r$1@inf2.informatik.uni-stuttgart.de>, > "Martin Tobisch" wrote: > > > what do i have to do if i want to include a " inside of a string? > > I know you already got a RTFM answer, but most manuals I have > seen don't properly address string handling in Ada (it really > ought to have its own chapter) I disagree, all good Ada text books quite clearly describe how to write string literals. > and the LRM seems like overkill > for such a simple question. I disagree, first, you can immediately find the section by looking for string (it is the first occurrence of the word string in the main body of the RM), and you find the statements: 4 A string_element is either a pair of quotation marks (""), or a single graphic_character other than a quotation mark. and 5 The sequence of characters of a string_literal is formed from the sequence of string_elements between the bracketing quotation marks, in the given order, with a string_element that is "" becoming a single quotation mark in the sequence of characters, and any other string_element being reproduced in the sequence. This is not difficult stuff AT ALL, and people need to be able to read paragraphs like the above and understand them. Also the suggestion of using concatenation is way off base, I strongly disagree with this because it introduces all kinds of unnecessary semantics into the discussion about bounds and the operation of concatenation. It is also ugly and has no possible advantage over the normal "" quoting mechanism. Learning to read manuals is at least as important to students as learning Ada. In fact if we really want to be honest, the ability to read manuals is probably much MORE important than learning insignificant syntactic details about how to write string literals in one particular language. Yes, you can be lazy and get an answer to simple questions on CLA, but as we very well know, when people have more complex questions, they either don't get answers, or they get completely inaccurate answers. The ability to learn for oneself from reference materials is a vital one. > > There are two simple ways (I know of) to do this: > > 1) Catenate a quotation character to your string eg: > > Value : constant String := "The name is " & '"' & > Some_String_Variable & '"'; > > 2) "Escape" the quotation character in the string literal with > another quotation character: > > Value : constant String "= The name is """ & Some_String_Variable & > """"; > > If you are using emacs, you'll probably want to stick to method 2, since > method 1 throws off Ada-mode's colorization. > > -- > T.E.D. > > http://www.telepath.com/~dennison/Ted/TED.html > > Sent via Deja.com http://www.deja.com/ > Before you buy. > Sent via Deja.com http://www.deja.com/ Before you buy.