Dgameman1 Posted March 31, 2016 Posted March 31, 2016 Let's say this is the code I have $CurrentMatchUsername = "Dgameman1" $picklineText = "#FirstName#!! Hey, hi!" FileWrite("C:\Users\Dgameman1\Desktop\test.txt", $picklineText) How can I make it so that the file on my desktop named 'test.txt' will replace every instance of #FirstName# with `$CurrentMatchUsername`. The end result is for the text.txt file to have the sentence, Dgameman1!! Hey, hi!
Dgameman1 Posted March 31, 2016 Author Posted March 31, 2016 $picklineText = StringReplace($picklineText, "#FirstName#", $CurrentMatchUsername)
markyrocks Posted March 31, 2016 Posted March 31, 2016 (edited) $sLeft=stringleft ($picklineText,10) If $sLeft="#FirstName#" then Filewrite ($file, $CurrentMatchUsername & "!!Hey, hi!") EndIf Something like that. Edited March 31, 2016 by markyrocks ... Spoiler "I Believe array math to be potentially fatal, I may be dying from array math poisoning"
Exit Posted March 31, 2016 Posted March 31, 2016 Use the Opt("ExpandVarStrings", 1) function to replace variables. Opt("ExpandVarStrings", 1) ;0=don't expand, 1=do expand $CurrentMatchUsername = "Dgameman1" $CurrentMatchUsername = @UserName ; just to test with own osername $picklineText = "$CurrentMatchUsername$!! Hey, hi!" FileWrite("C:\Users\$CurrentMatchUsername$\Desktop\test.txt", $picklineText) Dgameman1 1 App: Au3toCmd UDF: _SingleScript()
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now