Jump to content

Difference between #include and # include-once


Recommended Posts

Hello, I have several .au3 files and in the main script <aplicaciones.au3> I have the following set

Main Script <aplicaciones.au3>

#RequireAdmin

#include <_____.au3> ...

#include-once

#include <autocad.au3>

#include <cype.au3>

...

each script is called by the name of the included scripts function

Script ---->> autocad.au3 and there i have...

#include <______.au3> for this script

#include-once

#include <aplicaciones.au3> (for call main script with function)

Would it be the correct way to do it?

I also get errors like AutoItWrapper / run / prod / ErrorStdOut in \ applications.au3 / UserParams but I have no idea how to fix this. The problem has started to happen to me when in the while loop I have changed that instead of executing each script independently as if it were an executable to become include files and I am not very clear how I should do it for it to work correctly. I need help to be clear about this please, thank you very much

Link to post
Share on other sites

@iriash 
:welcome: to the logo_autoit_210x72.svg forum

  

56 minutes ago, iriash said:

I also get errors like AutoItWrapper

Please post here SciTE console logs (Use quotation button image.png.8e2626910997b1bff7e98e72dc0aad6b.png  )

 

btw.
Please read:
How to post code on the forum * 

Edited by mLipok

Signature beginning:
Please remember: "AutoIt".....  Wondering who uses AutoIt and what it can be used for ?
* GHAPI UDF - modest beginning - communication with GitHub REST API Forum Rules *
Include Dependency Tree (Tool for analyzing script relations)
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for 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 *

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 *

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

"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: 2021-03-17

Link to post
Share on other sites

According to the help file:

#include-once
Specifies that the current file should only be included once.

If I do correctly understand then you include autocad.au3 in aplicaciones.au3. And you include aplicaciones.au3 in autocad.au3. So you include in a loop.
You have to decide where to drop the #include.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2021-06-05 - Version 1.5.4.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2021-06-14 - Version 1.6.5.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (NEW 2021-07-28 - Version 1.1.0.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki, WebDriver - Wiki

 

Link to post
Share on other sites

>"C:\Program Files (x86)\AutoIt3\SciTE\..\AutoIt3.exe" "C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3" /run /prod /ErrorStdOut /in "\\wdsserver\cau_autoit$\scripts\aplicaciones.au3" /UserParams    
+>12:10:27 Starting AutoIt3Wrapper (19.1127.1402.0} from:SciTE.exe (4.2.0.0)  Keyboard:0000040A  OS:WIN_10/  CPU:X64 OS:X64  Environment(Language:0C0A)  CodePage:0  utf8.auto.check:4
+>         SciTEDir => C:\Program Files (x86)\AutoIt3\SciTE   UserDir => C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper
>Running AU3Check (3.3.14.5)  from:C:\Program Files (x86)\AutoIt3  input:\\wdsserver\cau_autoit$\scripts\aplicaciones.au3
+>12:10:27 AU3Check ended.rc:0
>Running:(3.3.14.5):C:\Program Files (x86)\AutoIt3\autoit3_x64.exe "\\wdsserver\cau_autoit$\scripts\aplicaciones.au3"    
+>Setting Hotkeys...--> Press Ctrl+Alt+Break to Restart or Ctrl+BREAK to Stop.
+>12:10:27 AutoIt3.exe ended.rc:0
+>12:10:27 AutoIt3Wrapper Finished.
>Exit code: 0    Time: 1.498

 

Link to post
Share on other sites

Please edit your post and use 

8 minutes ago, mLipok said:

(Use quotation button image.png.8e2626910997b1bff7e98e72dc0aad6b.png  )

 

Signature beginning:
Please remember: "AutoIt".....  Wondering who uses AutoIt and what it can be used for ?
* GHAPI UDF - modest beginning - communication with GitHub REST API Forum Rules *
Include Dependency Tree (Tool for analyzing script relations)
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for 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 *

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 *

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

"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: 2021-03-17

Link to post
Share on other sites
4 minutes ago, iriash said:
Quote

>"C:\Program Files (x86)\AutoIt3\SciTE\..\AutoIt3.exe" "C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3" /run /prod /ErrorStdOut /in "\\wdsserver\cau_autoit$\scripts\aplicaciones.au3" /UserParams    
+>12:10:27 Starting AutoIt3Wrapper (19.1127.1402.0} from:SciTE.exe (4.2.0.0)  Keyboard:0000040A  OS:WIN_10/  CPU:X64 OS:X64  Environment(Language:0C0A)  CodePage:0  utf8.auto.check:4
+>         SciTEDir => C:\Program Files (x86)\AutoIt3\SciTE   UserDir => C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper
>Running AU3Check (3.3.14.5)  from:C:\Program Files (x86)\AutoIt3  input:\\wdsserver\cau_autoit$\scripts\aplicaciones.au3
+>12:10:27 AU3Check ended.rc:0
>Running:(3.3.14.5):C:\Program Files (x86)\AutoIt3\autoit3_x64.exe "\\wdsserver\cau_autoit$\scripts\aplicaciones.au3"    
+>Setting Hotkeys...--> Press Ctrl+Alt+Break to Restart or Ctrl+BREAK to Stop.
+>12:10:27 AutoIt3.exe ended.rc:0
+>12:10:27 AutoIt3Wrapper Finished.
>Exit code: 0    Time: 1.498

 

 

 

Link to post
Share on other sites

This are ordinary informational messages. Means: All fine, no errors found.

So what do you expect and what do you get? Example: When you run your script you expect a GUI to be shown but nothing happens or an error message pops up or ...

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2021-06-05 - Version 1.5.4.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2021-06-14 - Version 1.6.5.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (NEW 2021-07-28 - Version 1.1.0.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki, WebDriver - Wiki

 

Link to post
Share on other sites

Let's see everything worked well for me when I had each script separately and compiling an executable by script and called them from "my first script" with the Run function because I did not know how the scripts were included in a nested way, so when I changed it, my first script

I paste my main script here

#RequireAdmin
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiMenu.au3>
#include <StringConstants.au3>
#include <MsgBoxConstants.au3>
#include <GuiStatusBar.au3>
#include <GUIConstants.au3>
#include <WinAPIIcons.au3>
#include <GuiButton.au3>
#include <WinAPIRes.au3>
#include <GuiIPAddress.au3>
#include-once
#include <autocad.au3>
#include <presto.au3>
#include <cype.au3>
#include <buscar_equipo.au3>
#include <buscar_equipo_ip.au3>


#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=\\wdsserver\cau_autoit$\img\iconocau.ico
#AutoIt3Wrapper_Outfile_x64=..\aplicaciones.exe
#AutoIt3Wrapper_Res_Comment=Herramientas C.A.U.
#AutoIt3Wrapper_Res_Description=Instalador Versión 1.0
#AutoIt3Wrapper_Res_Fileversion=1.0.0.0
#AutoIt3Wrapper_Res_ProductName=Aplicaciones C.A.U.
#AutoIt3Wrapper_Res_ProductVersion=1.0
#AutoIt3Wrapper_Res_CompanyName=Diputación de Cáceres
#AutoIt3Wrapper_Res_LegalCopyright=Alejandro Pastor Martín
#AutoIt3Wrapper_Res_Language=1034
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

;frm_principal()

Func frm_principal()

#Region
    Local $frm_principal=GUICreate("Aplicaciones C.A.U.", 600, 250, -1, -1,BitOR($GUI_SS_DEFAULT_GUI,$DS_MODALFRAME))
    GUISetCursor (2)
    GUISetBkColor(0xef6847)
    GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
    GUICtrlSetColor(-1, 0x000000)

    ;######################################MENU C.A.U.########################################
    Local $menu = GUICtrlCreateMenu("Archivo")
    Local $menu_aplicaciones_tecnicas = GUICtrlCreateMenu("Aplicaciones técnicas")
    Local $menu_autocad = GUICtrlCreateMenuItem("Autocad",$menu_aplicaciones_tecnicas)
    Local $menu_cype = GUICtrlCreateMenuItem("Cype",$menu_aplicaciones_tecnicas)
    Local $menu_presto = GUICtrlCreateMenuItem("Presto",$menu_aplicaciones_tecnicas)
    Local $menu_salir = GUICtrlCreateMenuItem("Salir",$menu)
    Local $menu_herramientas = GUICtrlCreateMenu("Herramientas")
    Local $menu_ItemHerramientas_buscarequipo = GUICtrlCreateMenuItem("Buscar equipo por Nombre",$menu_herramientas)
    Local $menu_ItemHerramientas_buscarequipo_ip = GUICtrlCreateMenuItem("Buscar equipo por dirección IP",$menu_herramientas)

    ;########################################################################################

    ;#################################FUNCIONES MOSTRAR IMAGENES EN FORMULARIO PRINCIPAL############
    GUICtrlCreatePic("\\wdsserver\cau_autoit$\img\frm_principal\rueda_frm_principal.bmp", 0, 100, 75, 76)
    GUICtrlCreatePic("\\wdsserver\cau_autoit$\img\frm_principal\encabezado_frm_principal.jpg", 0, 1, 600, 150)
    ;##############################################################################################
    GUISetState(@SW_SHOW)
#EndRegion

;#################################COMPORTAMIENTO FORMULARIO PRINCIPAL########################

While 1
    ;Local $user = DllOpen("user32.dll")
    $msg = GUIGetMsg()
    Switch $msg
        Case  $GUI_EVENT_CLOSE, $menu_salir
            ;GUIDelete($frm_principal)
            ExitLoop
        Case $menu_salir
            ;GUIDelete($frm_principal)
            ExitLoop
        ;Case $msg = $menu_presto
            ;GUIDelete($frm_principal)
            ;frm_presto()
            ;ExitLoop
        ;Case $msg = $menu_cype
            ;GuiDelete($frm_principal)
            ;frm_cype()
            ;ExitLoop
        ;Case $msg = $menu_autocad
            ;GuiDelete($frm_principal)
            ;frm_autocad()
            ;ExitLoop
        ;Case $msg = $menu_ItemHerramientas_buscarequipo
            ;GUIDelete($frm_principal)
            ;buscar_equipo()
            ;ExitLoop
        ;Case $msg = $menu_ItemHerramientas_buscarequipo_ip
            ;GUIDelete($frm_principal)
            ;buscar_por_ip()
            ;ExitLoop
    EndSwitch
WEnd
EndFunc

Link to post
Share on other sites

Why do you create and compile your AutoCAD (and other) functions into a separate exe? Do you need to run multiple functions at the same time?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2021-06-05 - Version 1.5.4.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2021-06-14 - Version 1.6.5.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (NEW 2021-07-28 - Version 1.1.0.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki, WebDriver - Wiki

 

Link to post
Share on other sites

A ver, soy nuevo en AutoIT y lo que hacía era crear distintos scripts y cada scripts lo compilaba y desde mi script principal solo sabia ejecutar los demas scripts usando la funcion Run() pero despues aprendi que se podian llamar los demas scripts con #require-once y ahí es donde empece a ver errores

Link to post
Share on other sites
Just now, iriash said:

Let's see, I'm new to AutoIT and what I did was create different scripts and each scripts I compiled it and from my main script I only knew how to execute the other scripts using the Run () function but later I learned that the other scripts could be called with #require -11 and that's where I started to see errors

 

Link to post
Share on other sites

You already include autocad.au3 in your main script. So you simply call the CAD functions from your main script. No need to compile them into separate exe.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2021-06-05 - Version 1.5.4.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2021-06-14 - Version 1.6.5.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (NEW 2021-07-28 - Version 1.1.0.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki, WebDriver - Wiki

 

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

    No registered users viewing this page.

×
×
  • Create New...