Jump to content

Remove line bevor Compile


Go to solution Solved by SOLVE-SMART,

Recommended Posts

  • Solution

Hi @Floooooo24,

you can call another program in the "before directive". So you could call a script/exe with your script full path as parameter. This script/exe would search and remove your #include <_Dbug.au3> line, then this program is done and the compiling process proceeds without your specific line 😀 .

This is at least one way that should fit your requirement 🤝 .

Best regards
Sven

Edited by SOLVE-SMART

Stay innovative!

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)

Link to comment
Share on other sites

Not sure how you run the debugging but if any functions in there are called by your main script then it will error if you don't include that.

You might just want to include If Not @Compiled before any line that uses the debug stuff.  that way including it will not cause an issue, it just won't run debug if it's compiled.

Link to comment
Share on other sites

Hi Together,

 

@BigDaddyO I only call this UDF, which then copies the Code, an Create a seperate Window, in which you can controll the Programm (Step-by-Step, Run-to-Cursor, ...)

I think (I'm not sure) I use this one:

 

@SOLVE-SMART thank you, I wrote a little script, which you can control by the parameter:

#AutoIt3Wrapper_Run_After=start "" "<Path to the exe>" [MSG] [Path:%in%] [Comment:"<StringToCommet>"] [Uncomment:"<StringToUncmmet>"] [Add:<LineToAdd>:"<StringToAdd>"] [Remove:<LineToRemove>:"<StringToRemove>"]

[MSG]: Musst be the first parameter, opens an Messagebox at the start and the end of the Programm.

[Path:%in%]: gives the Programm Path to the skript.

[Comment:"<StringToCommet>"] : Search all occorrence of the String an adds ";### " at the start of the line.

==>Example: [Comment:"#include <_Dbug.au3>"]

[Uncomment:"<StringToUncommet>"] : Search all occorrence of the String an removes ";### " from the start of the line if there is one.

==> Example: [Uncomment:"#include <_Dbug.au3>"]

[Add:<LineToAdd>:"<StringToAdd>"]: Adds the <StringToAdd> to the Line <LineToAdd> if it is empty, if it isn't empty a line will be inserted above.

==> Example: [Add:10:"#include <_Dbug.au3>"]

[Remove:<LineToRemove>:"<StringToRemove>"]:

1.Removes alle occurece <StringToRemove> from the Line <LineToRemove>

==> Example: [Add:10:"#include <_Dbug.au3>"]

2. If <LinetoRemove> isn't given, then the whole Script will searched an all occurence of <StringToRemove> will be removed

==> Example: [Add::"#include <_Dbug.au3>"]

3. If <StringToRemove> isn't given, then the whole Line <LineToRemove> will be deeleted

==> Example: [Add:10:]

 

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Res_Fileversion=1.0.1.3
#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y
#AutoIt3Wrapper_Res_SaveSource=y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <Array.au3>

Local $MSG = False
If $CmdLine[1] = "MSG" Then
    MsgBox(0, "Info", "Start")
    $MSG = True
    _ArrayDelete($CmdLine, 1)
Endif

;Emergency stop
HotKeySet("{ESC}", "Exit_Programm")
Func Exit_Programm()
    Exit
EndFunc

;Header Variables
Local $sPathToAu3 = ""
Local $aStringsToComment[0]
Local $aStringsToUncomment[0]
Local $aStringsToAdd[0][2]
Local $aStringsToRemove[0][2]

;Cut Header
For $i = 1 To Ubound($CmdLine) - 1
    Select
        Case StringInStr($CmdLine[$i], "Path:")
            $sPathToAu3 = StringTrimLeft($CmdLine[$i], 5)

        Case StringInStr($CmdLine[$i], "Uncomment:")
            _ArrayAdd($aStringsToUncomment, StringTrimLeft($CmdLine[$i], 10))

        Case StringInStr($CmdLine[$i], "Comment:")
            _ArrayAdd($aStringsToComment, StringTrimLeft($CmdLine[$i], 8))

        Case StringInStr($CmdLine[$i], "Add:")
            Local $iSeperator2 = StringInStr($CmdLine[$i], ":", 0, 2)
            Local $iLine = StringMid($CmdLine[$i], 5, $iSeperator2-5)
            Local $sString = StringMid($CmdLine[$i], $iSeperator2+1)

            _ArrayAdd($aStringsToAdd, $iLine & "|" & $sString)

        Case StringInStr($CmdLine[$i], "Remove:")
            Local $iSeperator2 = StringInStr($CmdLine[$i], ":", 0, 2)
            If $iSeperator2 = 0 Then
                Local $iLine = StringMid($CmdLine[$i], 8)
                _ArrayAdd($aStringsToRemove, $iLine)
            Else
                Local $iLine = StringMid($CmdLine[$i], 8, $iSeperator2-8)
                Local $sString = StringMid($CmdLine[$i], $iSeperator2+1)
                _ArrayAdd($aStringsToRemove, $iLine & "|" & $sString)
            EndIf

        Case Else
    EndSelect
Next

;Check Input
If Not FileExists($sPathToAu3) Then
    MsgBox($MB_ICONERROR, "Error", "File To '.au3' doesn't exists")
    Exit
EndIf

;Read File
Local $aText = FileReadToArray($sPathToAu3)

;Comment Strings
For $i = 0 To Ubound($aText) - 1
    For $x = 0 To Ubound($aStringsToComment) - 1
        If Not(StringLeft($aText[$i], 15) = "#AutoIt3Wrapper") And StringInStr($aText[$i], $aStringsToComment[$x]) Then
            $aText[$i] = ";### " & $aText[$i]
        EndIf
    Next
Next

;Uncomment Strings
For $i = 0 To Ubound($aText) - 1
    For $x = 0 To Ubound($aStringsToUncomment) - 1
        If Not(StringLeft($aText[$i], 15) = "#AutoIt3Wrapper") And StringInStr($aText[$i], $aStringsToUncomment[$x]) Then
            If StringLeft($aText[$i], 5) = ";### " Then $aText[$i] = StringTrimLeft($aText[$i], 5)
        EndIf
    Next
Next

;Add Strings
For $i = 0 To Ubound($aStringsToAdd) - 1
    If $aText[$aStringsToAdd[$i][0]-1] = "" Then
        $aText[$aStringsToAdd[$i][0]-1] = $aStringsToAdd[$i][1]
    Else
        _ArrayInsert($aText, $aStringsToAdd[$i][0]-1, $aStringsToAdd[$i][1])
    EndIf
Next

;StringRemove
For $i = 0 To Ubound($aStringsToRemove) - 1
    Select
        Case $aStringsToRemove[$i][1] = "" ;delete whole line
            _ArrayDelete($aText, $aStringsToRemove[$i][0]-1)

        Case $aStringsToRemove[$i][0] = "" ;Delete every occurrence of the String in the whole text
            For $x = 0 To Ubound($aText) - 1
                If StringInStr($aText[$x], "#AutoIt3Wrapper") Then ContinueLoop

                $aText[$x] = StringReplace($aText[$x], $aStringsToRemove[$i][1], "")
            Next

        Case Else ;Delete every occurrence of the String in the specific Line
            $aText[$aStringsToRemove[$i][0]-1] = StringReplace($aText[$aStringsToRemove[$i][0]-1], $aStringsToRemove[$i][1], "")
    EndSelect
Next


;Write File
Local $iFilehandle = FileOpen($sPathToAu3, 2)
FileWrite($iFilehandle, _ArrayToString($aText, @CRLF))
FileClose($iFilehandle)

If $MSG Then MsgBox(0, "Info", "End")

 

of course you can use it in

#AutoIt3Wrapper_Run_After=

as well.

Edited by Floooooo24
Errors in source code
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...