Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Project aware #213

Open
vanowm opened this issue Feb 11, 2024 · 3 comments
Open

Project aware #213

vanowm opened this issue Feb 11, 2024 · 3 comments

Comments

@vanowm
Copy link

vanowm commented Feb 11, 2024

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:

Global $myVar = "foo"
#include "secondary.au3"

secondary.au3:

ConsoleWrite($myVar)

The code works fine when main.au3 executed, but when I edit secondary.au3 vscode complains that $myVar is not declared.

What could we do about this?

Possible solutions:

  • setting where we can specify "root" files
  • a comment inside included file with a name of the parent file
@Sven-Seyfert
Copy link

Sven-Seyfert commented Feb 11, 2024

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

grafik

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)

@Comemhome
Copy link

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

@loganch
Copy link
Owner

loganch commented Jul 3, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants