AutoHotkey Community

It is currently May 26th, 2012, 8:46 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: August 28th, 2009, 3:34 am 
Offline

Joined: November 10th, 2007, 3:30 am
Posts: 93
Location: Second star to the right.... watching you.
Takes a script as an argument and capitalizes its syntax. I wrote this so i can code in lowercase and then fix it later on.

For example, stringreplace will become StringReplace... #ifwinexist will become #IfWinExist, etc...

I whipped this up pretty quick and I realize its flawed and at a later time I will get around to making it so it doesn't erroneously capitalize words which shouldn't be.


Code:
#NoEnv
#SingleInstance force
SetBatchLines -1
SetWorkingDir %A_ScriptDir%

If 1 =
   ExitApp

SplitPath, A_AhkPath,, AHKPath

; store file into a variable
FileRead f, %1%

;; Fix "If" statements
StringReplace f, f, if%A_Space%, If%A_Space%, A

;; CommandNames.txt
Loop read, %ahkpath%\Extras\Editors\Syntax\CommandNames.txt
   StringReplace f, f, %A_LoopReadLine%, %A_LoopReadLine%, A

;; Variables
Loop read, %ahkpath%\Extras\Editors\Syntax\Variables.txt
   StringReplace f, f, %A_LoopReadLine%, %A_LoopReadLine%, A

   
;; Keys
Loop read, %ahkpath%\Extras\Editors\Syntax\Keys.txt
{
   
   If (SubStr(A_LoopReadLine, 1,1) = A_Space)
   Or (SubStr(A_LoopReadLine, 1,1) = ";")
   Or StrLen(A_LoopReadLine) = 1
      Continue

   StringReplace f, f, %A_LoopReadLine%%A_Space%&, %A_LoopReadLine%%A_Space%&, A   
   StringReplace f, f, %A_LoopReadLine%::, %A_LoopReadLine%::, A   
   StringReplace f, f, {%A_LoopReadLine%}, {%A_LoopReadLine%}, A   
      
}

;; Functions
Loop read, %ahkpath%\Extras\Editors\Syntax\Functions.txt
{
   StringSplit line, A_LoopReadLine, (
   StringReplace f, f, %line1%(, %line1%(, A   
}

;; Create new file
FileDelete %1%
FileAppend %f%, %1%


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 28th, 2009, 8:15 am 
Offline

Joined: June 17th, 2008, 7:51 am
Posts: 243
You invented the Wheel again.
Auto-Syntax-Tidy v12

_________________
Greetings
Rog


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 30th, 2009, 1:36 am 
Offline

Joined: November 10th, 2007, 3:30 am
Posts: 93
Location: Second star to the right.... watching you.
ruespe wrote:
You invented the Wheel again.
Auto-Syntax-Tidy v12


Yes and no.

My problem with that script is that it also reformats your indentation. It does not simply allow you to change the syntax and preserve whatever indentation you've done yourself.

I spent a few hours with that script trying to extract just the functionality to properly capitalize the AHK syntax but gave up after a while. It was too confusing for me.

If you were to look on page#4 of that thread, you would see that I had asked, weeks ago, if someone knew a means to allow the functionality that I have preliminarily supplied in this thread. Hopefully it will expand into something more complete for my own needs.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], Blackholyman, RoAltmann and 11 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group