Jump to content

Code Organizer


Leoj
 Share

Recommended Posts

What it does: lets you make an ini file that points to all of the scripts you want to and then makes tabs for those scripts in the program with the scripts displayed in an edit area for easy copy&paste.

Example .ini and files that the ini points to included (also a compiled and source version)

You could edit the file extensions to accommodate any files you may use...

#include <GUIConstants.au3>
#include <File.au3>
#include <GuiListView.au3>

$tabsOn = 1
$k = 0
$unLoaded = 1

Dim $Tab_Item[50]
Dim $Edit_Item[50]
Dim $scriptItem[1000]

$scriptFolder = "scripts\"
$GUItitle = "codeHelper"
$GUIsize = 550
$nodeSize = $GUIsize - 550
$indentX = 32
$indentY = $indentX + 30

GUICreate($GUItitle, $GUIsize, $GUIsize)
$tab = GUICtrlCreateTab(10, 10, $GUIsize - 20, $GUIsize - 20)

GUISetState(@SW_SHOW)

;Actions Tab
$actionsTab = GUICtrlCreateTabItem("Actions")
;top (Load Code) group
GUICtrlCreateGroup("", -99, -99, 1, 1)
;$loadCodeGroup = GUICtrlCreateGroup("Load Code", $indentX, $indentY, 481, 185)
$scriptsList = GUICtrlCreateListView("Path                 |Comments|HTML|CSS|JS|PHP|XML|XLS", $indentX, $indentY, 480, 422)
$FileList = _FileListToArray($scriptFolder, "*", 1)
If @error = 1 Then
    MsgBox(0, "", "No files found in /scripts/ folder.")
EndIf
For $i = 1 To $FileList[0] ;.ini, .txt, .etc
    If StringInStr($FileList[$i], ".ini") Then ;if ini then
        $sectNames = IniReadSectionNames($scriptFolder & $FileList[$i]) ;read section names
        $type = ""
        $typeHTML = 0
        $typeCSS = 0
        $typeJS = 0
        $typePHP = 0
        $typeXML = 0
        $typeXSL = 0
        For $j = 1 To UBound($sectNames) - 1 ;for all sections...
            $fileNameLoc = ""
            $fileNameLoc = IniRead($scriptFolder & $FileList[$i], $sectNames[$j], "filenameloc", "") ;read value of filenameloc
            $comment = IniRead($scriptFolder & $FileList[$i], "comments", "comment", "") ;read value of comment
            If Not $fileNameLoc = "" Then
                If StringInStr($fileNameLoc, ".html") Then $typeHTML = $typeHTML + 1
                If StringInStr($fileNameLoc, ".css") Then $typeCSS = $typeCSS + 1
                If StringInStr($fileNameLoc, ".js") Then $typeJS = $typeJS + 1
                If StringInStr($fileNameLoc, ".php") Then $typePHP = $typePHP + 1
                If StringInStr($fileNameLoc, ".xml") Then $typeXML = $typeXML + 1
                If StringInStr($fileNameLoc, ".xsl") Then $typeXSL = $typeXSL + 1
            EndIf
        Next
        $FileItem = StringReplace($FileList[$i], ".ini", "")
        $scriptItem[$i] = GUICtrlCreateListViewItem($FileItem & "|" & $comment & "|" & $typeHTML & "|" & $typeCSS & "|" & $typeJS & "|" & $typePHP & "|" & $typeXML & "|" & $typeXSL, $scriptsList)
    EndIf
Next
$unLoadButton = GUICtrlCreateButton("UNLOAD", $indentX + 62, $indentY + 440, 57, 25, 0)
$loadButton = GUICtrlCreateButton("LOAD", $indentX, $indentY + 440, 57, 25, 0)
GUICtrlCreateTabItem("")
GUISetState()

While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    If $msg = $loadButton Then
        If $unLoaded = 1 Then
            $listItemString = GUICtrlRead(GUICtrlRead($scriptsList))
            $fileNameLoc = StringSplit($listItemString, "|")
            $tabFileName = $fileNameLoc[1]
            $filename = $scriptFolder & $fileNameLoc[1] & ".ini"
            $section = IniReadSectionNames($filename)
            For $i = 1 To UBound($section) - 1 ;for every section...
                $tabName = IniRead($filename, $section[$i], "tabname", "null") ;get the listed tab name
                $fileNameLoc = IniRead($filename, $section[$i], "filenameloc", "null") ;get the listed file name
                If $fileNameLoc = "null" Or $tabName = "null" Then
                    ;MsgBox(0,"***","doing nothing")
                Else
                    $file = FileOpen($fileNameLoc, 0) ;open that file
                    If $file = -1 Then
                        MsgBox(0, "Error", "Unable to open file " & $fileNameLoc)
                        ExitLoop
                    Else
                        $content = FileRead($file) ;read the files contents
                        $k = $k + 1
                        $Tab_Item[$k] = GUICtrlCreateTabItem($tabName) ;create the tab with appropriate tab name
                        $Edit_Item[$k] = GUICtrlCreateEdit($content, $indentX, $indentY, $GUIsize - 65, $GUIsize - 90) ;create the edit area with appropriate contents
                        GUICtrlSetState($Tab_Item[$k], $GUI_SHOW)
                    EndIf
                    FileClose($file)
                    $unLoaded = 0
                EndIf
            Next
        ElseIf $unLoaded = 0 Then
            MsgBox(0, "Alert", "You must unload current file to load another")
        EndIf
    EndIf
    If $msg = $unLoadButton Then
        If $unLoaded = 0 Then
            For $i = 1 To $k
                GUICtrlDelete($Tab_Item[$i])
                $unLoaded = 1
            Next
        EndIf
    EndIf
WEnd

Example .ini file:

[comments]
 comment=This is a test Comment that is just a bit long...
 
 [tab1]
 tabname=HTML
 filenameloc=pages\testSite\scrpt.html
 
 [tab2]
 tabname=CSS One
 filenameloc=pages\testSite\scrpt.css
 
 [tab3]
 tabname=Javascript
 filenameloc=pages\testSite\scrpt.js
 
 [tab4]
 tabname=CSS Two
 filenameloc=pages\testSite\scrpt.css

I'd imagine the functionally is very expandable from here so feel free to add stuff and then post a reply in this thread if you'd please..

I hope *anyone* enjoys this =) [also is there anything similar? I'm sure there's lots of things like this one on these forums--well, this is mine]

Edit: updated attachment with working .exe - everything else is the same =P

codeHelper.zip

Edited by Leoj
Link to comment
Share on other sites

I almost passed up this thread, but I decided to try the script.

All I can say is that this is extremely useful. I've already put it to good use for managing my web site.

Thanks for posting this.

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