Jump to content

Recommended Posts

Posted

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

Posted

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."

 

Posted

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."

 

Posted
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

==> 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)

Posted

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."

 

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...