Sign in to follow this  
Followers 0
GEOSoft

add another comment character?

3 posts in this topic

I know we already have the semi-colon which will comment a line, and actually I probably mis-named this thread because in reality I don't want another comment character added. I would however welcome the addition of the FormFeed, Chr(12) added to characters that AutoIt ignores. On occasion I have the need to print a script and it is much nicer to to be able to create page breaks at logical points. For example after an EndFunc statement instead of havingit break 6 lines into the next function. If I add a page break into a script now, AutoIt throws a minor hissy fit.

It's just a thought and maybe not even a good one but I don't see why it would not be fairly straight forward to add it nor do I see where it would cause issues for a script. That doesn't mean that I have not overlooked the obvious.

Dev input?


George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

What about this solution?

Add ;###Page### in your script at the spots you want to add a pagebreak and when you want to print run this script manually or by means of a Shortcut that is define in your editor of choice (Which I know isn't SciTE for you :) ):

#include <File.au3>
If $cmdline[0] = 1 Then 
    $ScriptFile = $cmdline[1]
Else
    $ScriptFile = FileOpenDialog("Specify Script file to print","", "autoit3(*.au3)")
EndIf
; check for shell print option for AutoIt3 and set it to WordPad when its not there.
RegRead("HKCR\AutoIt3Script\Shell\Print","")
If @error Then
    ConsoleWrite('+> Added Print Option for AU3 files.' &  @crlf)
    RegWrite("HKCR\AutoIt3Script\Shell\Print","","REG_SZ", "&Print")
    RegWrite("HKCR\AutoIt3Script\Shell\Print\command","","REG_SZ", '"' & @ProgramFilesDir & '\Windows NT\Accessories\WORDPAD.EXE" /p %1')
EndIf
;Create Tempfile
$printfile = _TempFile(@TempDir,"~",".au3")
; read file
$Source = FileRead($ScriptFile)
; add FF's
$Source = StringReplace($Source,";###Page###", Chr(12))
; write to tempfile
FileWrite($printfile,$Source)
;print the tempfile
_FilePrint($printfile)
; give it a bit of time and before deleting the Tempdile.
Sleep(1000)
FileDelete($printfile)

Have fun.

Jos

Edited by Jos

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

What about this solution?

Add ;###Page### in your script at the spots you want to add a pagebreak and when you want to print run this script manual or by means of a Shortcut that is define in your editor of choice (Which I know isn't SciTE for you :) ):

#include <File.au3>
If $cmdline[0] = 1 Then 
    $ScriptFile = $cmdline[1]
Else
    $ScriptFile = FileOpenDialog("Specify Script file to print","", "autoit3(*.au3)")
EndIf
; check for shell print option for AutoIt3 and set it to WordPad when its not there.
RegRead("HKCR\AutoIt3Script\Shell\Print","")
If @error Then
    ConsoleWrite('+> Added Print Option for AU3 files.' &  @crlf)
    RegWrite("HKCR\AutoIt3Script\Shell\Print","","REG_SZ", "&Print")
    RegWrite("HKCR\AutoIt3Script\Shell\Print\command","","REG_SZ", '"' & @ProgramFilesDir & '\Windows NT\Accessories\WORDPAD.EXE" /p %1')
EndIf
;Create Tempfile
$printfile = _TempFile(@TempDir,"~",".au3")
; read file
$Source = FileRead($ScriptFile)
; add FF's
$Source = StringReplace($Source,";###Page###", Chr(12))
; write to tempfile
FileWrite($printfile,$Source)
;print the tempfile
_FilePrint($printfile)
; give it a bit of time and before deleting the Tempdile.
Sleep(1000)
FileDelete($printfile)

Have fun.

Jos

Thank you my good man. You are just too kind. I had an idea to use

#cs

Line break here because the printer knows from nothing about block comments.

#ce

That would have left the block comment markers on each page so your idea seems better.


George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


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
Sign in to follow this  
Followers 0