Jump to content
Sign in to follow this  
t3mp3st

Add var to string

Recommended Posts

t3mp3st

Hi,

I'm pretty new to Autoit and I have a really simple question.

I have 2 Vars, $var1 and $var2

$var1 = "C:\test\" (used "@WorkingDir")

$var2 = "test.ini"

How can I add $var2 after $var1 ?

I want to have the full path =)

The way I was used to make it doesn't work for AutoIt.

Could you help me ?

Thanks in advance !

Edited by t3mp3st

Share this post


Link to post
Share on other sites
Mat

The "&" operator joins two strings. e.g. "one" & 10 (equals "one10")

Alternatively you can use the &= assignment, e.g. $var = "one", and then $var &= 10 ($var now equals "one10")

You'd use in this case:

$var1 &= $var2

See the helpfile under language reference - operators.

MDiesel

Share this post


Link to post
Share on other sites
t3mp3st

Thank you very much,

I couldn't find it in the help file nor in this forum,

Thanks !

Share this post


Link to post
Share on other sites
GEOSoft

This line bothers me a bit depending on your intent

$var1 = "C:\test\" (used "@WorkingDir")

at least the @WorkingDir part does.

You must remember that folder Macros do not contain trailing back slashes and they are not quoted. So if you really meant to use @WorkingDir instead of "C:\Test\" then it should be

$var1 = @WorkingDir & "\"

EDIT. Damn! Read the post post by @mdeisel. Closing brace removed

Edited by GEOSoft

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites
Mat

This line bothers me a bit depending on your intent

...

$var1 = @WorkingDir & "\")
I'm not sure who to be more worried about, he who actually posts working code (despite explanation being wrong), or he who puts a random closing bracket in the code...

:)

Onto a marginally more serious note, correct use of macros is very important, so you'd better fix it before you come to us saying it doesn't work.

MDiesel

Edited by mdiesel

Share this post


Link to post
Share on other sites
GEOSoft

I'm not sure who to be more worried about, he who actually posts working code (despite explanation being wrong), or he who puts a random closing bracket in the code...

:)

Onto a marginally more serious note, correct use of macros is very important, so you'd better fix it before you come to us saying it doesn't work.

MDiesel

Thats what I get for only partially editing the paste of someone elses code. I'm ordering a new brain soon.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites
Mat

Thats what I get for only partially editing the paste of someone elses code. I'm ordering a new brain soon.

Hopefully won't be worried for much longer then :) I here theyre quite cheap now!

$var1 = @WorkingDir & "\Test.ini"

MsgBox (0, $var1, FileRead ($var1))

Make sure you set @WorkingDir or something, as it is not constant.

MDiesel

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.