Jump to content

@ScriptName does not use #include file


Recommended Posts

@ScriptName and @ScriptFullPath is not correct when referenced within an #include file. @ScriptLineNumber is correct in those cases and TrayIconDebug shows the correct file name.  Why aren't the others correct? Thanks!

Link to comment
Share on other sites

  • Developers

Define "not correct" please with exact information on what you do and what you get that isn't coorect!

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

For example, running "main.au3" with #include <common.au3"> ... main.au3 calls a function within common.au3. That function includes a debug statement that logs @ScriptName as "main.au3" instead of "common.au3". @ScriptLineNumber is logged as the correct line number within common.au3. And if script is paused at that point, the TrayIconDebug popup shows correct file name. Why doesn't @ScriptName have access to correct file name displayed in TrayIconDebug?

Link to comment
Share on other sites

it'd be a problem otherwise. When the script runs, it's all added together ( in AutoIt ) so the running script is the name and full path.
If you run from SciTE it'll tell you what part/script is faulty/failed but once compiled you'd go to the script line number.
In the AutoIt3Wrapper there are things you can do to have the pre-compiled script that will match the compiled script to the line number.

I hope this helps. Otherwise, explain the limitation in a running code example to take it from there :) 

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Link to comment
Share on other sites

56 minutes ago, _Ed_ said:

For example, running "main.au3" with #include <common.au3"> ... main.au3 calls a function within common.au3. That function includes a debug statement that logs @ScriptName as "main.au3" instead of "common.au3". @ScriptLineNumber is logged as the correct line number within common.au3. And if script is paused at that point, the TrayIconDebug popup shows correct file name. Why doesn't @ScriptName have access to correct file name displayed in TrayIconDebug?

Compiled ? Unclompiled ?

If you want to have this in compiled then try to use:

#AutoIt3Wrapper_Run_Au3Stripper=Y
#Au3Stripper_Parameters=/MO /RSLN

 

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 *

 

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE * IE on Windows 11

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2023-04-24

Link to comment
Share on other sites

My example above was in context of running an uncompiled script, using _DebugOut(@ScriptName&": "&@ScriptLineNumber) at line# 94 within common.au3

It produces a log statement like this:

    main.au3: 94

The line number is correct, but not the file name. I expect:

    common.au3: 94

If I put a pause right after the debug statement, i.e. "While True Sleep (100) WEnd" the AutoIt TrayIconDebug tooltip has correct file name for that paused position in script. I would expect @ScriptName or some other macro could provide same thing:

image.png.bcba93dae45c12efc2665c32f54422c0.png

The Au3Stripper tip for compilation is helpful, thanks. Running main.exe, I get:

    main.exe: common:94/19557

... or if running main_stripped.au3:

    main_stripped.au3: common:94/19557

But this seems like an inefficient extra steps that must be done with every change to original files.

Link to comment
Share on other sites

  • Developers

Looks indeed like an issue after making 2 simple replicator scripts:

Test.au3:

; Script test.au3
#include "test2.au3"
ConsoleWrite('@@> Debug(' & @ScriptLineNumber & ') : @ScriptName= ' & @ScriptName & @CRLF) ;### Debug Console
Test()
ConsoleWrite('@@> Debug(' & @ScriptLineNumber & ') : @ScriptName= ' & @ScriptName & @CRLF) ;### Debug Console

Test2.au3:

; Script test2.au3
Func test()
    ConsoleWrite('@@- Debug(' & @ScriptLineNumber & ') : @ScriptName= ' & @ScriptName & @CRLF) ;### Debug Console
    ConsoleWrite('@@- Debug(' & @ScriptLineNumber & ') : @ScriptName= ' & @ScriptName & @CRLF) ;### Debug Console
EndFunc   ;==>test

Output:

>Running:(3.3.16.1):C:\Program Files (x86)\AutoIt3\autoit3.exe "D:\Development\AutoIt3\programs\test\test\test.au3"    
+>Setting Hotkeys...--> Press Ctrl+Alt+Break to Restart. --> Press Ctrl+BREAK to Stop.
@@> Debug(2) : @ScriptName= test.au3
@@- Debug(3) : @ScriptName= test.au3
@@- Debug(4) : @ScriptName= test.au3
@@> Debug(4) : @ScriptName= test.au3
+>09:16:59 AutoIt3 ended. rc:0

 

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Ticket #3766 closed Feature Request (Duplicate)
@IncludeScriptFullPath and @IncludeScriptName

Since this is acknowledged, maybe the this ticket can serve as a solution to keep the prior scripts running. Otherwise, if fixed, would be a script breaker.
Keeping the current behavior as is and adding the fix as @IncludeScriptFullPath and @IncludeScriptName would save a world of trouble.

If the behavior is revised and fix, as it has been this way since 3.2.x.x as far as I tested. Don't know if is worth fixing.

Just an idea.

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

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