Jump to content

HTML to AWS


DirtDBaK
 Share

Recommended Posts

I'm cleaning out my projects folder...

Get rid of 2007's scripts and make room for 2008

Needed this a while back and it's just been sitting around on my server.

Maybe it will help someone...

Enjoy

Posted Image

;HTML to AWS
#include <GUIConstants.au3>
#include <File.au3>

#Region ### START Koda GUI section ### Form=
Global $Form1 = GUICreate("AWS & HTML tools || By DBaK ||", 633, 90)
Global $File = GUICtrlCreateInput("In File", 8, 8, 585, 21)
Global $Button1 = GUICtrlCreateButton("...", 600, 8, 27, 17, 0)
Global $Button2 = GUICtrlCreateButton("HTML to AWS", 8, 32, 193, 17, 0)
Global $Button3 = GUICtrlCreateButton("AWS to HTML", 400, 32, 193, 17, 0)
GUICtrlSetState(-1,$GUI_DISABLE)
Global $Save_as = GUICtrlCreateInput("Out File", 8, 56, 585, 21)
Global $Button4 = GUICtrlCreateButton("...", 600, 56, 25, 17, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button2
            HTML2AWS( GuiCtrlRead( $file ), GuiCtrlRead( $Save_as ) )
        Case $button1
            GuiCtrlSetData($file, File(0))
        Case $button4
            GuiCtrlSetData($save_as, File(1))
    EndSwitch
WEnd


Func HTML2AWS( $in, $out )
    If Not FileExists($in) Then 
        MsgBox(64, "Error", "File doesn't exist!")
        Return(0)
    Else
        ProgressOn( "HTML >> AWS", "Reading File", "Opening File", 0, 0 )
        $inhand = FileOpen($in, 0 )
        $lines = _FileCountLines( $in )
        If @Error = 1 then
            Msgbox(16, "Error", "File could not be opened or doesn't exist" )
            ProgressOff()
            Return(0)
        EndIf
        $outHand = FileOpen($out, 10 )
        $buffer = ''
        For $i = 1 to $lines step 1
            ProgressSet( $i/$lines*50, "Line "&$i&" of "&$lines)
            $tmp = FileReadLine( $inhand, $i )
            If $tmp <> "" or $tmp <> ' ' then $buffer = $buffer & "`" & $tmp
        Next
        If StringInStr( $buffer, "'") then
            ProgressSet( 50, "Replacing Single Quotes", "Checking File" )
            $buffer = StringReplace( $buffer, "'", '"' )
        Endif
        $a = StringSplit($buffer,"`")   ;Splippt up the file
        If Not ISArray( $a ) then 
            MsgBox(16, "Error", "Error Spliting File" )
            ProgressOff()
            Return(0)
        Else
            ProgressSet(50, "Writing Header", "Checking File" )
            FileWriteLine( $outhand, '#include <web.au3>'&@CRLF&'_StartWebApp_Session("Email Login")'&@CRLF )
            ;MsgBox(0, 'Number Of lines after SrtingSplit', "StringSplit Lines: "&$a[0] & " Actual Lines: " & $lines ) ;This wil check to see if the number of lines is the same
            For $x = 1 to $a[0] step 1
                if StringLen($a[$x]) >= 1 Then
                    FileWriteLine( $outhand, "Echo('"&$a[$x]&"')")
                Endif
            ProgressSet((($x/$a[0])*50)+50, "Writing File", "Creating AWS file" )
            Next
            ProgressSet(100, "Wrote "&$x&" lines of AWS code" )
        Endif
    Endif
    ProgressOff()
EndFunc    

Func File($typ = '0')
If $typ = '0' then
    Return(FileOpenDialog( "Select File", "Desktop", "Valid Files(*.html;*.htm;*.au3;*.aws;*.txt)|All(*.*)" ))
Endif
Return(FileSaveDialog( "Select File", "Desktop", "Valid Files(*.html;*.htm;*.au3;*.aws;*.txt)|All(*.*)" ))
EndFunc
Edited by DBak

[center][/center]

Link to comment
Share on other sites

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

AutoIt Web Script....

It just makes the HTML change from

<b>this is html</b>

into

Echo('<b>this is html</b>')

and it will also add this to the file

#include <web.au3>
_StartWebApp(' ')

Thought it might help out some web scripters that use frontpage/dreamweaver to generate thire HTML.

[center][/center]

Link to comment
Share on other sites

I did the same thing a while ago. But yours looks much better. It's in my sig.

http://www.autoitking.co.nr Site is DOWN | My deviantART | No Topic Topic - Don't do it!-------------------- UDF's/Scripts:AutoIt: [BenEditor 3.6] [_ShutDown()]PHP: [CommentScript]Web Based AutoIt: [MemStats] [HTML to AU3] [User LogIn and SignUp script]
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...