Jump to content

Generating html with a for loop


Recommended Posts

Ok, i'm trying to roll out html <img> codes. I am trying to put two in a row, and then a <br>. Instead it generates the two codes, then flickers my edit box and steps the number up one every millisecond. CAn anyone help me with this code?

#include <GUIConstants.au3>
; == GUI generated with Koda ==
$Form1 = GUICreate("AForm1", 622, 441, 192, 125)
$Edit1 = GUICtrlCreateEdit("", 0, 0, 617, 385, -1, $WS_EX_CLIENTEDGE)
GUICtrlSetData($Edit1, "AEdit1")
$Button1 = GUICtrlCreateButton("Generate", 200, 400, 185, 33)
GUISetState(@SW_SHOW)
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case $msg = $Button1
        for $i = 1 to 80 step +1
            GUICtrlSetData($Edit1, "<img src="&$i&"><Img src="&$i&"><br>")
        Next
    EndSelect
WEnd
Exit

EDIT: There are 80 images just name 1.jpg, 2.jpg ect..
Edited by codemyster
Link to comment
Share on other sites

  • Moderators

Try this:

#include <GUIConstants.au3>

Opt("GuiOnEventMode", True)

$Form1 = GUICreate("AForm1", 622, 441, 192, 125)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
$Edit1 = GUICtrlCreateEdit("", 0, 0, 617, 385, -1, $WS_EX_CLIENTEDGE)
$Button1 = GUICtrlCreateButton("Generate", 200, 400, 185, 33)
GUICtrlSetOnEvent(-1, "_GenerateHTML")
GUISetState()

While 1
    Sleep(100)
WEnd

Func _GenerateHTML()
    Local $sHTML = ""
    For $i = 1 To 80
        If Mod($i, 2) Then
            $sHTML &= "<Img src=" & $i & ".jpg>"
        Else
            $sHTML &= "<Img src=" & $i & ".jpg><br>" & @CRLF
        EndIf
    Next
    GUICtrlSetData($Edit1, $sHTML, "")
EndFunc   ;==>_GenerateHTML

Func _Exit()
    Exit
EndFunc   ;==>_Exit
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...