Jump to content

Issuse with GuiList


Recommended Posts

Hello guys im tring to make a program that reads line after line (in the bsn.txt file) and it shows up in the GUICtrlCreateList and in a .txt file (log.txt) or later in a xml file(log.xml) but i have some issues

1) I can't make it show up in the GuiCtrlCreateList

2) I have no clue how can i make the program that each time that i introduce/reads a new BSN code to show the last one that i introduce in the GUI LIST

Example: if the program reads first this bsn BSN 1056009617 and after that this BSN 1056009888 it will show up like in this code

BSN 1056009617
BSN 1056009888

and i want to make it like this

BSN 1056009888
BSN 1056009617

So can you guide me to solve this problems ?

The program code

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>


$Form1 = GUICreate("Form1", 507, 441, 413, 353)
$Nume = GUICtrlCreateLabel("BSN Reader", 128, 16, 216, 33)
GUICtrlSetFont(-1, 18, 800, 0, "MS Sans Serif")
$InputBSN = GUICtrlCreateInput("", 16, 120, 425, 21)
$ListaBSN = GUICtrlCreateList("", 16, 152, 425, 253)
$Button1 = GUICtrlCreateButton("Read BSN", 64, 80, 105, 25, 0)
$Button2 = GUICtrlCreateButton("Generate Log", 304, 80, 105, 25, 0)
GUISetState(@SW_SHOW)

$fileRead = FileOpen("bsn.txt", 0)

If $fileRead = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
    Exit
EndIf

While 1
        
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

        Case $Button1
            $line = FileReadLine($fileread)
            If @error = -1 Then ExitLoop
            ;MsgBox(0, "Line read:", $line)
            ;filewriteline("log.txt",$line) <-- Acesta e pentru Generate Log buton / This is for Generate log button
            
    EndSwitch
WEnd
Link to comment
Share on other sites

This is to load the content of file in your list:

Case $Button1
     $index = 1
     While True
        $line = FileReadLine($fileread,$index)
        If @error Then ExitLoop
        GUICtrlSetData($ListaBSN,$line,1)
        $index += 1
     WEnd

PS: totdeauna o sa fie ordonate datele intr-un listbox normal daca nu scoti stilul $LBS_SORT, poti folosi listview daca vrei sa nu le aranjeze automat

Edited by Andreik

When the words fail... music speaks.

Link to comment
Share on other sites

  • 3 weeks later...

Hello guys, seems im stuck again with some problems

1) Can i make the program to read inside .zip files? I want to make him read a xml file.

- I used the fileopen example.zip/file.xml but it didn't work for me is there other command that i can use?

2) How can i make the program open and read lines in the GuiCtrlsetData ?

I used the GuiCtrlRead but no succes,

3) Is there a way to make the program to show the last file that have bin saved in the folder?

Ex:

Report[1054525346][3 27 09 PM][4 7 2011].txt

Report[1051525356][3 27 53 PM][4 7 2011].txt

And i want to make it show the last one that have bin introduced in that folder

I have thinked at something like this but im lost from there on

$FileSearch = FileFindFirstFile("C:\rim\test\*.*")
$Fileline = Filefindnextfile($fileSearch)

for $Filesearch in $FileLine

I hope you can guide me trying to fix this.

Thank you very much

Here is the full code

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <IE.au3>
#include <_XmlDomWrapper.au3> ;Pentru fisiere xml 



$Form1 = GUICreate("BSN Pass Reader", 507, 441, 413, 353)
$Nume = GUICtrlCreateLabel("BSN Error Reader", 128, 16, 216, 33, 0)
GUICtrlSetFont(-1, 18, 800, 0, "MS Sans Serif")
$InputBSN = GUICtrlCreateInput("", 16, 120, 425, 21, $GUI_SS_DEFAULT_INPUT)
$ListaBSN = GUICtrlCreateList("", 16, 152, 425, 253, BitOR($LBS_NOTIFY,$LBS_DISABLENOSCROLL,$WS_VSCROLL,$WS_BORDER))
$Button1 = GUICtrlCreateButton("Read BSN", 64, 80, 105, 25, $BS_NOTIFY)
$Button2 = GUICtrlCreateButton("Open", 304, 80, 105, 25, $BS_NOTIFY)
GUISetState(@SW_SHOW)

$FileSearch = FileFindFirstFile("C:\rim\test\*.*") 


While 1
    
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

        Case $Button1 ; butonul responsabil care citeste codurile bsn 
            $index = 1
            While True
            $line = FileFindNextFile($FileSearch) 
            If @error Then ExitLoop
            GUICtrlSetData($ListaBSN,$line,1)
            $index += 1
        WEnd
        
        Case $Button2
            $Citestefisieru = Guictrlread($ListaBsn)
            $Deschide =fileopen($CitesteFisieru)
            If $Deschide = -1 Then
                Msgbox(0, "Error", "unable to open file.")
                Exit
            EndIf 
            Msgbox(0,"citit", $ReadLine)
            ;$scrielog = guictrlread($ListaBSN)
            ;$Deschideweb = _IECreate("http://elqweb/pls/clsoradeaweb/rpt_unit.unitinformation?ex_id=" & $scrielog & "&unitrpt=history", 1, 1, 0)
            


        EndSwitch
WEnd
Link to comment
Share on other sites

I found how to fix problem number 2.

I have thinked to use a .ini file so i can store there any settings that i want to add (directory change and so on) but now the program dosen't want to read the .ini settings that i apply.

Can somoene tell me were did i made the mistake?

Later edit:

The problems it seems to be at $fileSearch if i replace the $searching var with the C:\rim\test\*.* (this is the location), it seems to be working

;Setarile .Ini
$txt = IniReadSection("setari.ini","Locatia")
$Searching = IniReadSection("setari.ini","SearchLocation")


;Location were the the program start to search
$FileSearch = FileFindFirstFile($Searching) 


While 1
    
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

        Case $Button1 ; butonul responsabil care citeste codurile bsn 
            $index = 1
            While True
            $line = FileFindNextFile($FileSearch) 
            If @error Then ExitLoop
            GUICtrlSetData($ListaBSN,$line,1)
            $index += 1
        WEnd
        
        Case $Button2
            $Citestefisieru = Guictrlread($ListaBsn)
            $scrie = iniwrite("test.ini","Adresa","adresa", $CitesteFisieru)
            $Deschide = fileopen("C:\rim\test\"& $CitesteFisieru)
            If $Deschide = -1 Then
                Msgbox(0, "Error", "unable to open file.")
                Exit
            EndIf 
            $a = Filereadline($Deschide,4)
            Msgbox(0,"Merge?",$a)
            ;$scrielog = guictrlread($ListaBSN)
            ;$Deschideweb = _IECreate("http://elqweb/pls/clsoradeaweb/rpt_unit.unitinformation?ex_id=" & $scrielog & "&unitrpt=history", 1, 1, 0)
            


        EndSwitch
WEnd
Edited by mircea
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...