Line return in a (constant) string 
Author Message
 Line return in a (constant) string

Hi.

Here is my problem:
I want to create a Constant (in a Module) as String, and I want this
string to contain a line return (Chr(13), you see what I mean? Like
"There are"+Chr(13)+"two lines".).
How can I do this?

Thanks in advance!
Pascal.

PS (maybe it can help to answer): I saw that REALglot extracted text
into its .const file with "\r" in place of line returns, but I didn't
take time to see how it behaves when it reimports strings if I put a
"\r" in them by myself...



Wed, 20 Jul 2005 00:32:25 GMT  
 Line return in a (constant) string

Quote:

> I want to create a Constant (in a Module) as String, and I want this
> string to contain a line return (Chr(13), you see what I mean? Like
> "There are"+Chr(13)+"two lines".).
> How can I do this?

ConstanteDeuxLignes=Chr(13)+Chr(13)+Chr(13)

--
"On se persuade mieux, pour l'ordinaire, par les raisons
 qu'on a soi-mme trouves, que par celles
 qui sont venues dans l'esprit des autres"



Wed, 20 Jul 2005 00:46:52 GMT  
 Line return in a (constant) string

Quote:

> I want to create a Constant (in a Module) as String, and I want this
> string to contain a line return (Chr(13), you see what I mean? Like
> "There are"+Chr(13)+"two lines".).
> How can I do this?

The only way is to type the lines you want somewhere (e.g. in the code
editor), copy them, and then paste them into the value field for the
constant.

I don't really recommend this, though, as I'm not sure whether the line
ending will get properly converted for other platforms.  I frankly doubt
it.  This is not an officially supported trick.

Cheers,
- Joe

,------------------------------------------------------------------.
|    Joseph J. Strout         Check out the Mac Web Directory:     |

`------------------------------------------------------------------'



Wed, 20 Jul 2005 03:01:27 GMT  
 Line return in a (constant) string

Quote:



>>I want to create a Constant (in a Module) as String, and I want this
>>string to contain a line return (Chr(13), you see what I mean? Like
>>"There are"+Chr(13)+"two lines".).
>>How can I do this?

> The only way is to type the lines you want somewhere (e.g. in the code
> editor), copy them, and then paste them into the value field for the
> constant.

> I don't really recommend this, though, as I'm not sure whether the line
> ending will get properly converted for other platforms.  I frankly doubt
> it.  This is not an officially supported trick.

> Cheers,
> - Joe

I too have muttered at this feature, it would be nice to be able to include
constants within a constant definition.

Thus I would define cr as a string equal to CHR(13) or CHR(13)+CHR(10)
platform dependent. Then I could define another constant as:
                "There are"+cr+"two lines"

I guess I can dream, and use my other work rounds.

Mike



Wed, 20 Jul 2005 06:04:49 GMT  
 Line return in a (constant) string

Quote:



> > I want to create a Constant (in a Module) as String, and I want this
> > string to contain a line return (Chr(13), you see what I mean? Like
> > "There are"+Chr(13)+"two lines".).
> > How can I do this?

> The only way is to type the lines you want somewhere (e.g. in the code
> editor), copy them, and then paste them into the value field for the
> constant.

> I don't really recommend this, though, as I'm not sure whether the line
> ending will get properly converted for other platforms.  I frankly doubt
> it.  This is not an officially supported trick.

You can make a little program that does this:

Clipboard.Text = chr(13)

...then paste that into the constant dialog.

Use the same trick for LF and CRLF.

It sure would be handy to have a '\n' for REALbasic, though it's pretty
easy to make a cross-platform Newline() as String global method.



Wed, 20 Jul 2005 06:28:32 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Stylistic question: returning strings vs. pointers to strings

2. Tkinter wart: returned texts are sometimes strings, sometime Unicode strings

3. Initialising a constant with a return value from a function

4. constant definition doesn't return value?

5. Constants for catch return values?

6. remove blank lines before lines beginning with string

7. Defining string constant with ASCII Code Under 32

8. Q:working with constants and strings

9. constant string in report

10. Constant objects (Was: Proposal: cleanup manifest strings!)

11. String Array Constant Addition

12. string constants, waveform charts and microsoft

 

 
Powered by phpBB® Forum Software