Jump to content
Sign in to follow this  
jay

Format String

Recommended Posts

jay

$Message = " -serverSMTP " & (GUICtrlRead($SMTPADD)) & " -s " & (GUICtrlRead($SUBJECT)) & " -body " & (GUICtrlRead($BODY)) & " -u " & (GUICtrlRead($USERNAME)) & " -pw " & (GUICtrlRead($PASSWORD)) & " -t " & (GUICtrlRead($TO)) & " -attach " & (GUICtrlRead($var))

When this string comes out i would like it to have Double Quotes around each variable

so it would look like this.

$Message = -serverSMTP "smtp.somewhere.com" -s "TESTSUBJECT" -body "TESTBODY"

-u myuname -pw "mypassword" -t someone@somewhere.com -attach "c:\file.txt"

Share this post


Link to post
Share on other sites
SpookMeister

Does this work?

$var="test " & chr(34) & "thing" & chr(34)
MsgBox(4096,"",$var)

[u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote]

Share this post


Link to post
Share on other sites
jay

Does this work?

$var="test " & chr(34) & "thing" & chr(34)
MsgBox(4096,"",$var)
Thanks that worked good

Share this post


Link to post
Share on other sites
ioliver

Thanks that worked good

You could also use single quotes to enclose the message, and use double quotes inside the single quotes.

Example:

$message = 'This is "' & 'my" ' & 'message.'
  MsgBox(0, "Test Message", $message)

Thanks,

Ian


"Blessed be the name of the Lord" - Job 1:21Check out Search IMF

Share this post


Link to post
Share on other sites
LxP

Here's an approach using StringFormat():

Local $Skeleton = '-serverSMTP "%s" -s "%s" -body "%s" -u %s -pw "%s" -t %s -arrach "%s"'
$Message = StringFormat($Skeleton, GUICtrlRead($SMTPADD), GUICtrlRead($SUBJECT), GUICtrlRead($BODY), GUICtrlRead($USERNAME), GUICtrlRead($PASSWORD), GUICtrlRead($TO), GUICtrlRead($var))

Share this post


Link to post
Share on other sites
SmOke_N

Here's an approach using StringFormat():

Local $Skeleton = '-serverSMTP "%s" -s "%s" -body "%s" -u %s -pw "%s" -t %s -arrach "%s"'
$Message = StringFormat($Skeleton, GUICtrlRead($SMTPADD), GUICtrlRead($SUBJECT), GUICtrlRead($BODY), GUICtrlRead($USERNAME), GUICtrlRead($PASSWORD), GUICtrlRead($TO), GUICtrlRead($var))
Nice!

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

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  

×