Jump to content

Text after #Region is not entirely considered a comment.


Recommended Posts

It is about the keyword #Region. In the SciTE help it says:

Quote

There is an additional folding keyword #region...#endregion to permit really large blocks of code to be compressed.  Any text following these special keywords is considered a comment:

But if I write #Region in the first line and write a space+underscore " _" at the end of the line, the compiler considers it a line continuation character. Is this a bug?

This only occurs in the first line of a script! If I write a blank line in front of it, it does not happen and the script runs without errors.

To test this example insert it into the first line of an Au3 script.

Spoiler
#Region Bug only occurs when #Region is in the first line _
Func Example()
  MsgBox(0, "", "hello")
EndFunc
#EndRegion

Example()

 

Currently I have written a function to read function heads from an Au3 script and format them in syntax notation. I discovered this behaviour when I wanted to remove the lines with #Region/#EndRegion and #Region was in the first line of a script.

My guess is that it could be a RegEx pattern. I had used this pattern first and made many attempts to fix it.

$sData = StringRegExpReplace($sData, '(?i)\n\h*(?:#Region|#EndRegion)(?!\w)[^\n]*\n', @LF)

Unfortunately, my RegEx skills are not good enough to change the pattern to make it work or to make such a fancy pattern. So I wrote a simple pattern that seems to do the job.

$sData = StringRegExpReplace($sData, '(?mi)^\h*(?:#Region|#EndRegion).*\R', "")

Can anyone confirm this, or have I done something wrong?

Bernd.

Edited by Professor_Bernd
Link to comment
Share on other sites

  • Developers
12 minutes ago, Professor_Bernd said:

Is this a bug?

I would say yes, but this is very rare it should happen as not many people use any Directive (#) on line one and an normal syntax line on line 2.

so it is not just with #region but also with #xyz, where AutoIt3 should ignore any line starting with # and not being a Directive it knows like #cs/#ce.

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

Link to comment
Share on other sites

I confirm that behaviour.

So yes, since it specifically says any text after it is considered a comment, it looks like a bug to me.

You can submit it here https://www.autoitscript.com/trac/autoit

Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Link to comment
Share on other sites

12 minutes ago, Jos said:

this is very rare it should happen

I agree. I only discovered this because I also considered absurd constellations to secure my feature. Everything that AutoIt allows can be done by the user. :D

 

19 minutes ago, careca said:

Thanks for the link. I'll try to see if I can do that.

 

Thank you both for your answers! :)

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