Wizardry Posted 13 hours ago Posted 13 hours ago I am trying to use a variable path to open my anglefinder program. The program is installed on multiple computers but the autoit scripts are in different locations: I have tried the following script but it can't open the script Named: Open the Angle Finder Program.au3 ;Setting the Path for the scripts If @ComputerName = "ICORE7WIN7ULT" Then $MyPath = "E:\AutoIt-Scripts\" Else $MyPath = "C:\Users\Jim\Desktop\Autoit-Scripts\" EndIf The following is the command line which does not work: RunWait('"' & @AutoItExe & '" /AutoIt3ExecuteScript & $MyPath & "Open the Angle Finder Program.au3"') If I change the command to the following it works fine: RunWait('"' & @AutoItExe & '" /AutoIt3ExecuteScript "C:\Users\Jim\Desktop\AutoIt-Scripts\Open the Angle Finder Program.au3"') Any help is greatly appreciated. Jim
donnyh13 Posted 13 hours ago Posted 13 hours ago In your example you are missing some quotations, so that $MyPath is being treated as a string. Try this: RunWait('"' & @AutoItExe & '" /AutoIt3ExecuteScript "' & $MyPath & 'Open the Angle Finder Program.au3"') LibreOffice UDF ; Scite4AutoIt Spell-Checker Using LibreOffice Spoiler "Life is chiefly made up, not of great sacrifices and wonderful achievements, but of little things. It is oftenest through the little things which seem so unworthy of notice that great good or evil is brought into our lives. It is through our failure to endure the tests that come to us in little things, that the habits are molded, the character misshaped; and when the greater tests come, they find us unready. Only by acting upon principle in the tests of daily life can we acquire power to stand firm and faithful in the most dangerous and most difficult positions."
Wizardry Posted 13 hours ago Author Posted 13 hours ago Many Thanks donnyh13, this solved the problem. I must have looked at it too long to miss those quote marks. Jim donnyh13 1
donnyh13 Posted 12 hours ago Posted 12 hours ago No problem Jim, glad it worked. 43 minutes ago, Wizardry said: I must have looked at it too long I can totally relate to you here. I have done this MANY times also. LibreOffice UDF ; Scite4AutoIt Spell-Checker Using LibreOffice Spoiler "Life is chiefly made up, not of great sacrifices and wonderful achievements, but of little things. It is oftenest through the little things which seem so unworthy of notice that great good or evil is brought into our lives. It is through our failure to endure the tests that come to us in little things, that the habits are molded, the character misshaped; and when the greater tests come, they find us unready. Only by acting upon principle in the tests of daily life can we acquire power to stand firm and faithful in the most dangerous and most difficult positions."
SOLVE-SMART Posted 11 hours ago Posted 11 hours ago 31 minutes ago, donnyh13 said: I have done this MANY times also. Me too few years ago. That's why I use StringFormat() nowadays to avoid concatination by & between strings and variables. RunWait('"' & @AutoItExe & '" /AutoIt3ExecuteScript "' & $MyPath & 'Open the Angle Finder Program.au3"') ; versus RunWait(StringFormat('"%s" /AutoIt3ExecuteScript "%sOpen the Angle Finder Program.au3"', @AutoItExe, $MyPath)) ; My personal conclusion: ; Always use single quotes instead of double quotes. ; Concat with StringFormat(), especially with large string <==> variable combinations. It might be detrimental to readability at first, but after a short period of getting used to it, it increases it and prevents precisely such errors. Best regards Sven donnyh13 1 ==> AutoIt related: 🔗 GitHub, 🔗 Discord Server, 🔗 Cheat Sheet, 🔗 autoit-webdriver-boilerplate Spoiler 🌍 Au3Forums 🎲 AutoIt (en) Cheat Sheet 📊 AutoIt limits/defaults 💎 Code Katas: [...] (comming soon) 🎭 Collection of GitHub users with AutoIt projects 🐞 False-Positives 🔮 Me on GitHub 💬 Opinion about new forum sub category 📑 UDF wiki list ✂ VSCode-AutoItSnippets 📑 WebDriver FAQs 👨🏫 WebDriver Tutorial (coming soon)
donnyh13 Posted 11 hours ago Posted 11 hours ago Very nice @SOLVE-SMART, I will have to get used to that. It looks much easier. Thank you! Best regards, LibreOffice UDF ; Scite4AutoIt Spell-Checker Using LibreOffice Spoiler "Life is chiefly made up, not of great sacrifices and wonderful achievements, but of little things. It is oftenest through the little things which seem so unworthy of notice that great good or evil is brought into our lives. It is through our failure to endure the tests that come to us in little things, that the habits are molded, the character misshaped; and when the greater tests come, they find us unready. Only by acting upon principle in the tests of daily life can we acquire power to stand firm and faithful in the most dangerous and most difficult positions."
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