Jump to content

i used while to display images but it went wrong

Recommended Posts

i used this code to take names for a text file called data and put the info of the image and it location from the data file into the gui interface but it only detect the lines with the info and it do not show the images . here is the code 

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>
#include <AVIConstants.au3>
#include <TreeViewConstants.au3>
#include <GuiComboBox.au3>
#include <GuiTab.au3>
#include <file.au3>
#include <array.au3>


Func _Main()

Local $idTab1

$Form1 = GUICreate("Form1", 500, 334, 240, 182)
$Group1 = GUICtrlCreateGroup("Group1", 20, 12, 249, 314)
$idButton6 = GUICtrlCreateButton("Info", 50, 270, 185, 49)

GUICtrlCreateGroup("", -99, -99, 1, 1)

Global $fileMPA = "C:\T-in\MPA\data.txt"

FileOpen($fileMPA, 0)

   Global $line1 = FileReadLine($fileMPA , 1)

$imp = 0

$idTab1 = GUICtrlCreateTab(300, -3, 180, 330)
GUICtrlSetTip(-1, '#Region TAB1')
GUICtrlSetTip(-1, '#Region LIST')
Local $imglist1 = GUICtrlCreateList("", 307, 26, 164, 304)

$cline =_FileCountLines($fileMPA)

 While  $imp < $cline

$line2 = FileReadLine($fileMPA , $imp + 2)
 $imp = $imp + 7

if $line2 = ""  then



 GUICtrlSetData(-1, ""& $line2 &"", "")



GUICtrlSetTip(-1, '#Region TAB2')
GUICtrlSetTip(-1, '#Region TAB3')

While 1
    $Msg = GUIGetMsg()
        Case $Msg = $GUI_EVENT_CLOSE
            Global $whatnow = GUICtrlRead($imglist1)
Case $Msg = $idButton6

            $imp2 = 0
             While  $imp2 < 30

$line2 = FileReadLine($fileMPA ,$imp2 + 2)
$line3 = FileReadLine($fileMPA , $imp2 + 3)
$line7 = FileReadLine($fileMPA , 7)

 $imp2 = $imp2 + 7

if $line2 = ""  then  ExitLoop
            If GUICtrlRead($imglist1) = ""& $line2 &""  Then MsgBox($MB_SYSTEMMODAL, "img info" , $line3)
$imp2 = 0
             While  $imp2 < 30

$line2 = FileReadLine($fileMPA ,$imp2 + 2)
$line3 = FileReadLine($fileMPA , $imp2 + 3)
$line7 = FileReadLine($fileMPA , 7)

 $imp2 = $imp2 + 7

Case GUICtrlRead($imglist1) = ""& $line2 &""
if $line2 = "" then ExitLoop
    $Pic1 = GUICtrlCreatePic(""& $line7 &"", 185, 28, 233, 230)

If GUICtrlRead($imglist1) then  ExitLoop


 EndFunc   ;==>_Main

i wish some one can help me fix this without having to choose the images manually and i know that the script is messy but am still new in the world of autoit some bear with me . thanks for your time

Link to comment
Share on other sites

the data.txt file content is 

Hibiscus is a hardy perennial which grows in variety of colors, sizes and fragrances. Actually they are tropical flowers which require ample sunlight and moisture to grow well. These flowers start blooming in late spring and continuously bloom through July and August.


There are different types of lily flowers which bloom in August including water lilies, tiger lilies and gold band lilies. Tiger lilies generate orange flowers having black spots. This lily blooms in delayed July and beginning of August. Gold band lily produce exotic white blooms. All varieties of lilies need enough space to grow and protection from summer sun.


Growing in humid areas, turtleheads are small flowers which bloom from July to September. They mostly produce flowers of white and pink color.


These are ever green bushes which produce flowers in different colors including white, purple, blue and pink. They are easy to grow bushes and can grow 3 to 10 feet tall. They require morning sun to grow but they should be protected from noon and afternoon sun.


August proves to be the peak blooming season for dahlias. Dahlias come in colors like white, orange, yellow, red and purple. They can tolerate all types of soil and require full sun to grow.

thank you so much AutoBert for answering . somehow this post have few views so i was thinking that no one will notice me


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

  • Create New...