- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
i am using a messagebox call (to be correct the xeffort wrapper xmessagebox). i would like to add a line break to start a text in a new line.
From VBA i remember the syntax \\n. I have tested it but it do not work.
A search on the forum has no results.
Thanks in advance
Frank
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Franck,
I think that you need to add a newline character manually in your string to have the correct behavior.
Example : string = "First line" // char(#0A) // "Second line"C
Don't forget the final C to declare that it is an ansi string (i.e. terminated by a null character)
N.B: #0A is the ascii code for LineFeed character
Best regards,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I think that "c" strings are "interpreted" at compilation time.
So the string "first line\nsecond line"c will integrate a line feed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Franck,
I think that you need to add a newline character manually in your string to have the correct behavior.
Example : string = "First line" // char(#0A) // "Second line"C
Don't forget the final C to declare that it is an ansi string (i.e. terminated by a null character)
N.B: #0A is the ascii code for LineFeed character
Close, but I think that one actually needs CR+LF (char(13)//char(10)) to actually make a linebreak in a message or edit box.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Best regards,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
could you please add this information in your help file of XEffort for the XMessageBox.
An other question about XEffort. Is there a time line for a IVF 12 Release?
Thanks in advance
Frank
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks in advance
Frank
There was, but it is broken. I'm helluva busy, and can't make any promises. :( Your question is duly noted though, and I'll try to find some spare time.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The point made about the compiler interpreting C-strings at compile time only applies if it can see ALL the characters in the string at compile time. It cannot and will not 'interpret' the character pair \r\n as an escape sequence unless it can 'see' it, for example in
string='This is a very, very, very long line that I want to\r\nsplit into two lines'c
The terminal C defines the preceding character string as a C-string. This will then be hard coded at compile time with the substitution of the required control characters in place of '\r' and '\n'.
This string can be built at execution time using
splitstring=char(10)//char(13)
string1='This is a very, very, very long line that I want to'
String2='split into two lines'
string3=string1//splitstring//string2//char(0)
with char(0) adding the null terminator required by C-strings for use in Windows API calls such as MessageBox or GetOpenFileName.
If you tried
string3=String1//'\r\n'//string2//char(0)
then the string '\r\n' will NOT be interpreted as an escape sequence, but as four characters, '\r\n'.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
to understand your reply correctly, i would like to create two examples.
Does it mean:
- when ever I use a fixed character string including \r\n or char(13)//char(10) end ending up with a final c it will work [e.g. 'Hello '//char(13)//char(10)//' world'//char(0)]
- when ever i use a composite character string like trim(string1)//char(13)//char(10) //trim(string2)//char(0) it will NOT work [i will have no new line but nice additional characters]
Thanks in advance
Frank
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
to understand your reply correctly, i would like to create two examples.
Does it mean:
- when ever I use a fixed character string including \r\n or char(13)//char(10) end ending up with a final c it will work [e.g. 'Hello '//char(13)//char(10)//' world'//char(0)]
- when ever i use a composite character string like trim(string1)//char(13)//char(10) //trim(string2)//char(0) it will NOT work [i will have no new line but nice additional characters]
No. Both of your examples will work. As long as the CR+LF characters are there, and the string is char(0)-terminated, you'll be fine.
Basically, one should pick one style and stick with it. Since the "C-style" notation (\r\n) is non-standard, and only slightly shorter, I prefer always using char() and concatenation operator //. Of course, you can define a character(2), parameter:: CRLF=char(13)//char(10) and use that.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The example shown on the Microsoft reference page to MessageBox function http://msdn.microsoft.com/en-us/library/ms645505%28v=vs.85%29.aspx only mentions a \n to insert a newline :
[bash]int msgboxID = MessageBox( NULL, (LPCWSTR)L"Resource not availablenDo you want to try again?", (LPCWSTR)L"Account Details", MB_ICONWARNING | MB_CANCELTRYCONTINUE | MB_DEFBUTTON2 ); [/bash]
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Robert
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
you are correct. But because I prefer to have my source as much as possible conforming the Fortran standard I use in this case
"First line"//ACHAR(13)//"Second Line"//ACHAR(0)
in stead of
"First line\nSecond Line"C
although this will work as well!
Best regards,
Robert
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for this idea!
Best regards,
Robert

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page