Open vanowm opened 7 months ago
Hi @vanowm,
I am confronted with such behavior all the time, because my projects often consists of different folders where the code is separated. As I remenber correctly, we had such requirement few years ago here in the project. I thought it was fixed at a certain time, but then the issue appeared again.
It would be wonderful if you or the other maintainers here see a good solution for it 🤗 .
Only as a show-case: example-project-structure
I decide which file needs to have access (#include) to a specific file (to the functions inside the file). So I can avoid issues with global variables for example.
Besides the situation of the warnings, it's also not possible to "jump to function definition" in case of such structure. Which makes me crazy sometimes. But to be honest, I am not able to extend the VSCode extension by a proper handling of this.
Best regards Sven (SOLVE-SMART)
You can do like this. Always save both files before editing
In Main.au3 :
#include-once
Global $MainVar = "This is $MainVar"
#include "secondary.au3"
Func FuncOfMain()
ConsoleWrite("This is FuncOfMain" & @CRLF )
EndFunc
Func InMain_ShowVarOfSecondary()
ConsoleWrite($SecondaryVar & @CRLF )
EndFunc
Func InMain_CallFuncOfSecondary()
FuncOfSecondary()
EndFunc
In Secondary.au3 :
#include-once
Global $SecondaryVar = "This is $SecondaryVar"
#include "main.au3"
Func FuncOfSecondary()
ConsoleWrite("This is FuncOfSecondary" & @CRLF )
EndFunc
Func InSecondary_ShowVarOfMain()
ConsoleWrite($MainVar & @CRLF)
EndFunc
Func InSecondary_CallFuncOfMain()
FuncOfMain()
EndFunc
The issue seems to be with Au3Check and its limitation of simply checking syntax and not running the scripts. I tried the syntax check in SciTE and got the same result.
Hi all,
My workaround is this one:
#noTrayIcon
#Include <AutoItConstants.au3>
consolewrite( runWaitStdout( '"C:\Program Files (x86)\AutoIt3\Au3Check.exe" D:\emie\dev\yetanotherprojekt\app\main.au3' ) )
func runWaitStdout($cmd) $process_pid = Run(@ComSpec &' /c ' & $cmd, @ScriptDir, @SW_HIDE, $STDERR_MERGED) processWaitClose($process_pid) return stdoutRead($process_pid) endfunc
- Then i modify the workspace config in vscode, changing the value "Check path" to point to my wrapper
![image](https://github.com/user-attachments/assets/edce0e5e-8fc2-401b-8eb4-2151f8a7f153)
Now in this workspace, no matter what file is open, au3check will be called with the "entrypoint" of the project
I'm trying to simplify my script by splitting it into multiple files. Each file may access global variables/function from other files. For example,
main.au3
file:secondary.au3
:The code works fine when
main.au3
executed, but when I editsecondary.au3
vscode complains that$myVar
is not declared.What could we do about this?
Possible solutions: