Sign in to follow this  
Followers 0

multiple lines in MsgBox?

21 posts in this topic

Posted

how do I get formatted text into a message box?

I can get a single line however I would like to be able to give multiple lines of information. ie:

Welcome (username)

todays date is (date)

it is about (time)

(OK)

can this be done? I've searched the help and looked at topics in here. don't see any direct examples.. perhaps I'm blind?

moo

Share this post


Link to post
Share on other sites



Posted (edited)

Just because I already had the file open, here's a freebee:

MsgBox(0, "Load Forecast Tool options", "/i or /install to install" & @CRLF &  "/u or /uninstall to uninstall" & @CRLF & @CRLF & "Load Forecast Tool written June '04 by Emmanuel Pleshe" & @CRLF & "©2004 Puget Sound Energy. All rights reserved.")

I had underscores at the end of each line, I took them out so as not to confuse you...

Edited by emmanuel

Share this post


Link to post
Share on other sites

Posted

ok so @CRLF is the carriage return and line break together.. I didn't know you could combine them. That's cool .. should have figured this one out. up untill now I was making a txt file reading from it and the deleting it. I figured there had to be a better way!

One other thing I noticed is that you have a lot of "" & however when I try to do more than 3 &'s I get an error. I'll have to try again.

thanks for the info!

Share this post


Link to post
Share on other sites

Posted

Many text based applications (such as notepad.exe and MS Word) require the user of both the @CR and @LF character, which AutoIt calls @CRLF. However, when talking about message boxes, you can just use @LF if you would prefer. Or @CR, it doesn't really matter.

Share this post


Link to post
Share on other sites

Posted

ok so @CRLF is the carriage return and line break together.. I didn't know you could combine them. That's cool .. should have figured this one out. up untill now I was making a txt file reading from it and the deleting it. I figured there had to be a better way!

One other thing I noticed is that you have a lot of "" & however when I try to do more than 3 &'s I get an error. I'll have to try again.

thanks for the info!

the & combines strings (there's a word for it, I've seen it here a couple times, can't spell it for the damned of me, coconate?) you should be able to do as many as you want, just be sure you don't have any without anything between them... show us the code that errors?

Share this post


Link to post
Share on other sites

Posted

Concatenate.

Share this post


Link to post
Share on other sites

Posted

One of the few words I can spell. It's not because I'm that great of a speller (because I am the polar opisite) but because it's a common command in Linux/ Unix. How's that for pathetic?

Share this post


Link to post
Share on other sites

Posted

Please tell me you spelled "opposite" wrong intentionally, otherwise, that's too ironic.

Share this post


Link to post
Share on other sites

Posted (edited)

Yes and no. I spelled it wrong the first time arround, and choose to leave it when my spell check told me it was incorrect. It was too amusing not to leave :D

[Edit]: You know your a bad speller when you use a spell check before posting to forums, heh.

Edited by pekster

Share this post


Link to post
Share on other sites

Posted

Oh I found the issue I had 2 &'s together without anything between them.. I think I had edited out something and missed one.. didn't notice untill after..

moo

Share this post


Link to post
Share on other sites

Posted

Oh I found the issue I had 2 &'s together without anything between them.. I think I had edited out something and missed one.. didn't notice untill after..

moo

I wonder if this is something that Tidy could check?

Share this post


Link to post
Share on other sites

Posted

I wonder if this is something that Tidy could check?

Why would you want this when Autoit it reports these errors ?

Tidy up till now only reports errors when it gets confused with the indenting...

Share this post


Link to post
Share on other sites

Posted

Why would you want this when Autoit it reports these errors ?

Tidy up till now only reports errors when it gets confused with the indenting...

oh, I dunno, I tidy before I compile before I test... it'd tip me off sooner... but I'm guessing most people test before they compile (I don't have the app I'm trying to automate on my pc...)

it's cool, I'm a freak, no worries.

Share this post


Link to post
Share on other sites

Posted

I'm trying to get the hang of V3, so far so good untill ...

I have to display several msg boxes based on variables, something like MsgBox(0,$Title,$Msg)

Both variables are being read from an ini-file.

The line reads = "Text" & @CRLF & "Text"

When I use this and call the MsgBox I get an exact quote as what I entered.

Can you tell me what I'm doing wrong ?

Share this post


Link to post
Share on other sites

Posted

when you read it from the ini file like:

$txt = iniread($file,$section,$key)

$txt contains '"Text" & @CRLF & "Text"'... in other words: one string...

You could do it this way:

$txt = 'Text\nText'  ; put \n where ever you want a newline.
$txt = stringreplace($txt,'\n',@LF) ; replace \n for @LF
MsgBox(0,'test',$txt)

Share this post


Link to post
Share on other sites

Posted

Thanks JdeB !

I will do it like that.

Share this post


Link to post
Share on other sites

Posted (edited)

when you read it from the ini file like:

$txt = iniread($file,$section,$key)

$txt contains '"Text" & @CRLF & "Text"'... in other words: one string...

You could do it this way:

$txt = 'Text\nText'  ; put \n where ever you want a newline.
$txt = stringreplace($txt,'\n',@LF) ; replace \n for @LF
MsgBox(0,'test',$txt)

I have same trouble with new line in iniread . but it happend with GUICtrlCreateLabel

Ex:

$text1 = IniRead("config.ini", "Config", "text1", "Error")

$Group_3 = GUICtrlCreateLabel($text1,15,18,210,65)

and Config.ini file :

[config]
$text1 = "line1" & @CRLF & "line2" ; << not work with new line

[config]
$text1 = "line1\line2" ; << not work too

My English not good . :D Plz help me .

Edited by Born2Try

Share this post


Link to post
Share on other sites

Posted (edited)

This post is from 2004 O_o

And to help you use stringreplace like JdeB sugested to replace \n with @CRLF (start testing from the help file on String* commands)

Edit: and next time you shud open your own topic wiht your own problem instead resurecting one that is opened from 2004

Edited by bogQ

Share this post


Link to post
Share on other sites

Posted

This post is from 2004 O_o

And to help you use stringreplace like JdeB sugested to replace \n with @CRLF (start testing from the help file on String* commands)

Edit: and next time you shud open your own topic wiht your own problem instead resurecting one that is opened from 2004

At least this shows that he used the search. :D

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0