AutoHotkey Community

It is currently May 27th, 2012, 5:59 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: Nesting script?
PostPosted: September 23rd, 2010, 5:53 pm 
Offline

Joined: February 9th, 2006, 8:01 pm
Posts: 117
Does anyone know of a configurable nesting script?
Even if it's not in AHK...

I've got to maintain a bunch of code in a proprietary database. It's got it's own functions and structure that is Vaguely SQLish but different enough that none of the SQL formating apps or adons for notepadd++ work on it. The format in the database is just one long string and completely formatted.

I can't seem to find anything that's just configurable by the user, but I can't believe no-ones run into this problem before.

I suppose I can parse through the string with AHK an replace ( and ) with line feeds and tabs... count the tabs and subtract them on the way down, etc... but I figured I'd ask here before I reinvent the wheel.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 23rd, 2010, 6:21 pm 
Offline

Joined: February 29th, 2008, 8:36 pm
Posts: 901
Location: Vault 7
I may not be understanding your question, but have you tried Regular Expressions?

And you can make your own formatting rules in Notepad++ (search for userDefineLang.xml)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 23rd, 2010, 7:26 pm 
Offline

Joined: February 9th, 2006, 8:01 pm
Posts: 117
Rapte_Of_Suzaku wrote:
I may not be understanding your question, but have you tried Regular Expressions?

And you can make your own formatting rules in Notepad++ (search for userDefineLang.xml)


I'm not understanding your question either :-p

Here's what my code comes out of the database like:
Count(Distinct if((people.initial_phone IS NULL),people.initial_phone))

and I want to script the nesting of this so it's more readable:



Code:
Count
    (
      Distinct if
      (
         (
         people.initial_phone IS NULL
         ),people.initial_phone
      )
   )



or something to that effect.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 23rd, 2010, 8:01 pm 
Offline

Joined: February 29th, 2008, 8:36 pm
Posts: 901
Location: Vault 7
Oh, I see now. The code format looks like Lisp... you might find something by searching for Lisp beautifiers and such. Then again, it'd probably be faster just to make your own reformatting script. Thankfully, the loop-through-it-and-count method isn't hard to create.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 23rd, 2010, 8:21 pm 
Offline
User avatar

Joined: November 2nd, 2008, 4:23 pm
Posts: 2906
Location: 127.0.0.1
Quote:
I suppose I can parse through the string with AHK an replace ( and ) with line feeds and tabs...
Look up StringReplace.

_________________
aboutscriptappsscripts
Any code ⇈ above ⇈ requires AutoHotkey_L to run


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 23rd, 2010, 8:35 pm 
Offline

Joined: February 9th, 2006, 8:01 pm
Posts: 117
Frankie wrote:
Quote:
I suppose I can parse through the string with AHK an replace ( and ) with line feeds and tabs...
Look up StringReplace.


Yea, I know about string replace. But if I want to keep track of the nesting I'm fairly sure I'll need to parse through the entire string one character at a time. Otherwise I'll only have a single indent for every (.

I did look up beautifiers and pretty printers... there are many... but they are sadly all command line which is about worthless.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 23rd, 2010, 10:00 pm 
Offline

Joined: February 9th, 2006, 8:01 pm
Posts: 117
I'm getting somewhere with it, but it's not adding up my tabs.

anyone know why?

Code:
AutoTrim, off
Tabs = 1
Loop, parse, clipboard, (,

{


    pretty = %pretty% %A_LoopField%   `n
      Loop 1 to %tabs%
         {
         pretty = %pretty% %A_Tab%
         }
      pretty = %pretty% (
   tabs += 1
}

Clipboard = %pretty%


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 23rd, 2010, 10:08 pm 
Offline

Joined: February 9th, 2006, 8:01 pm
Posts: 117
never mind, I just realize my approach is all wrong.


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: 0x150||ISO, batto, Bing [Bot], dra, HotkeyStick, mKnight, sjc1000, Wicked, XstatyK and 63 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