Jump to content

Recommended Posts

  • Developers
Posted

Is this a request for me?

If so, I am not sure how you would see this should work as I doubt we would want an option in Tidy that would remove all comments from the original script.

Obfuscator does what you want, but that will also insert all #include files, so it would be easier to implement it in there.

Anyway, let me first understand what it is you want and how this is useful for a larger group of people.

Jos

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.
  :)

Posted
  Quote
Is this a request for me?

Yes. Because you author.

  Quote
If so, I am not sure how you would see this should work as I doubt we would want an option in Tidy that would remove all comments from the original script.

The key doesn't oblige to delete comments, but gives a choice to the user.

When I post on the forum, many Russian comments are garbage.

  • Developers
Posted

Ok, so how do you feel about the comment I made on wanting to update the original script when removing all comments?

That is something I will never implement as that is wide open for people to screw up their script and blaming me for making that possible.
I am also reluctant to implement functions that only serves a few people.

It should be fairly easy for you to take one of the several posted scripts and modify it to facilitate what you want. I have posted an ExpanderAU3Script script before that generates a similar script as included in the compiled EXE generated by aut2exe. It is pretty easy to use that and only process the mainscript, ignoring the #include statements.

Agree?

Jos

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.
  :)

Posted (edited)

I have a usual script, it solves the problem. I thought it would be useful to many. Just a lot of scripts are in my folder, and if it was in one EXE, then it would be orderly.

  Quote
Ok, so how do you feel about the comment I made on wanting to update the original script when removing all comments?

I think the user before use any script processing should first read the description of the key, or test option to see the result. It is impossible to apply thoughtlessly, and then to bring accusations.

Yes. Replace the original script. By default, make a backup copy

Edited by AZJIO
Posted (edited)

Jos

I think the idea AZJIO in some cases it may also be useful for me.
However, I support your position with regard to the fact that someone less smart when using this option may be to you later objections.
 
Therefore, I propose a different solution.
Can you prepare a script LUA and add it to PersonalTools.lua?
 
EDIT:
something like here
Edited by mlipok

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:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted (edited)
I think the fact that someone will be able to use this script by adding it to the SciTE is good enough proof that he knew what he was doing.
Even more so if the script shall post a comment with a warning.
Edited by mlipok

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:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted

Or we can make the tool itself

We can use RegExp

StringRegExpReplace($sString,'(?i).*?(;.*\r\n)','')
StringRegExpReplace($sString,'#cs.*#ce','')

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:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted
  On 8/17/2013 at 8:47 PM, mlipok said:

 

Or we can make the tool itself

We can use RegExp

StringRegExpReplace($sString,'(?i).*?(;.*\r\n)','')
StringRegExpReplace($sString,'#cs.*#ce','')

Something like StringRegExpReplace($sString,'#cs.*#ce','') is not the best idea... you should use

StringRegExpReplace($sString,'#cs.*?#ce','')

Instead since that will cause it to stop when it finds #ce rather than continue and remove everything inbetween two comments....

Posted (edited)

second FULL example

$sString = ClipGet()
StringRegExpReplace($sString,'(?i).*?(;.*\r\n)','')
StringRegExpReplace($sString,'#cs.*?#ce','')
ClipPut($sString) 

Are these second examples of the use RegExp effectively perform what was Your idea?

EDIT:

UberFoX

You're right. Thank you.
Already have modified the second example.
Edited by mlipok

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:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted
  On 8/17/2013 at 8:52 PM, mlipok said:

 

second FULL example

$sString = ClipGet()
StringRegExpReplace($sString,'(?i).*?(;.*\r\n)','')
StringRegExpReplace($sString,'#cs.*?#ce','')
ClipPut($sString) 

Are these second examples of the use RegExp effectively perform what was Your idea?

EDIT:

UberFoX

You're right. Thank you.
Already have modified the second example.

 

I'm an expert with Regexp in my language I had to create Perl compatible regexp from scratch

'?do=embed' frameborder='0' data-embedContent>>

Your second function becomes  $string =~ s/#cs.*?#ce//; in Sputnik/Perl languages.

  • Developers
Posted

It is indeed something you can easily make with an Autoit3 script or LUA.

I would use an Autoit3Script which read the original script, process it and put it into the ClipBoard to allow for posting it easily in the Forum, given that is the goal.

Jos

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.
  :)

Posted (edited)

The Clipboard is a good idea.

If you make in SciTE, then I have to leave my option for Notepad++. But I would like to see your version as a script.

I use this function

Func _stripComments(ByRef $string)
    $string = StringRegExpReplace($string, "(?s)\r(?!\n)", '\r\n') ; ??? добавляем @LF в строку, если его нет (AZJIO)
    ;Author: Prog@ndy
    $string = StringReplace(StringReplace($string, "#comments-start", "#cs", 0, 2), "#comments-end", "#ce", 0, 2)
    ; $string = StringRegExpReplace($string, "(?si)(\v|\A)\h*#cs\b.*?\v\h*#ce\b", '') ; remove simple block comments (mod AZJIO)
    #region remove nested block-comments
    Local $match, $depth, $offset, $start, $CommentsAfterce
    While 1
        $depth = 0
        $match = StringRegExp($string, "(?im)^\h*#cs\b", 1)
        $start = @extended
        If @error Then ExitLoop
        Do
            $match = StringRegExp($string, "(?im)^\h*#c([se])\b", 1, $offset)
            $offset = @extended
            Select
                Case @error
                    Return False
                Case $match[0] = "e"
                    $depth -= 1
                Case Else
                    $depth += 1
            EndSelect
        Until $depth < 1

        $string = StringLeft($string, $start - 4) & StringRegExpReplace(StringMid($string, $offset), ".*", '', 1)
;~         $string = StringLeft($string, $start-4) & StringMid($string, $offset)
    WEnd
    #endregion remove nested block-comments
    $string = StringRegExpReplace($string & @CRLF, '(?m)^((?:[^''";]*([''"]).*?\2)*[^;]*)\h*;.*$', '\1') ; remove one-line comments (недостаток - не работает если @CR без @LF)
    $string = StringRegExpReplace($string, '\s+\z', '') ; удалить пустое в конце
    Return True
EndFunc   ;==>_stripComments
Edited by AZJIO
  • Developers
Posted (edited)

Put this is a file:

; mod "Organize Includes"
If $cmdline[0] > 0 Then
    $Filename = $cmdline[1]
Else
    ; No commandline specified
    ConsoleWrite("! File not Specified." & @CRLF)
    Exit
EndIf
If FileExists($Filename) Then
Else
    ; File doesn;t exists
    ConsoleWrite("! File not found:" & $Filename & @CRLF)
    Exit
EndIf
$ScriptSource = FileRead($Filename)
_stripComments($ScriptSource)
ClipPut($ScriptSource)
Exit
;
Func _stripComments(ByRef $string)
    $string = StringRegExpReplace($string, "(?s)\r(?!\n)", '\r\n') ; добавляем @LF в строку, если его нет (AZJIO)
    ;Author: Prog@ndy
    $string = StringReplace(StringReplace($string, "#comments-start", "#cs", 0, 2), "#comments-end", "#ce", 0, 2)
    $string = StringRegExpReplace($string, "(?si)(\v|\A)\h*#cs\b.*?\v\h*#ce\b", '') ; remove simple block comments (мод AZJIO)
    #region remove nested block-comments
    Local $match, $depth, $offset, $start, $CommentsAfterce
    While 1
        $depth = 0
        $match = StringRegExp($string, "(?im)^\h*#cs\b", 1)
        $start = @extended
        If @error Then ExitLoop
        Do
            $match = StringRegExp($string, "(?im)^\h*#c([se])\b", 1, $offset)
            $offset = @extended
            Select
                Case @error
                    Return False
                Case $match[0] = "e"
                    $depth -= 1
                Case Else
                    $depth += 1
            EndSelect
        Until $depth < 1

        $string = StringLeft($string, $start - 4) & StringRegExpReplace(StringMid($string, $offset), ".*", '', 1)
;~         $string = StringLeft($string, $start-4) & StringMid($string, $offset)
    WEnd
    #endregion remove nested block-comments
    $string = StringRegExpReplace($string, '(?m)^((?:[^''";]*([''"]).*?\2)*[^;]*);.*$', '\1') ; remove one-line comments (недостаток - не работает если @CR без @LF)
    Return True
EndFunc   ;==>_stripComments

and compile.

Edit SciTEUser.properties:

#---------------------------------------------------------------------------
command.47.*.au3="D:\Path to your script\YourScript.exe" "$(FilePath)"
command.name.47.*.au3=StripComments
command.save.before.47.*.au3=1
command.is.filter.47.*.au3=1
command.shortcut.47.*.au3=Ctrl+Alt+O

Now hit Alr+Ctrl+O in any autoit3 script and your clipboard contains the stripped source.

Jos :)

Edited by Jos

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.
  :)

Posted

Jos

Can You add a function that get current file edited in SciTE ?

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:

  Reveal hidden contents

Signature last update: 2023-04-24

  • Developers
Posted
  On 8/17/2013 at 9:44 PM, mlipok said:

Jos

Can You add a function that get current file edited in SciTE ?

Isn't that what the shown example does?

It will save the currently added scriptfile and process it or am I misunderstanding your question?

Jos

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.
  :)

Posted

Sorry

I was blind,

I just looked only on au3 not for this:

  Quote

 

command.47.*.au3="D:Path to your scriptYourScript.exe" "$(FilePath)"

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:

  Reveal hidden contents

Signature last update: 2023-04-24

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...