Jump to content

Getting tekst from 2 files


FMS
 Share

Recommended Posts

Dear reader,

I have a problem whit comparing a input whit 2 files of tekst and hoped someone can help me whit this.

First i generated 2 tekst files (VCfile.txt & TDfile.txt)

The tekst in that file's are seperated whit a "|"(pipe sign)

Iff u run the autoit script u will C that the search object is given treu a input.

Iff i type " Jan" in the input of the script it will result when i push the invetory button in 2 rows whit the info of the 2 files in a form.

note: the info of "jan.snotter.nl" isn't the same in both files

I was getting stuck whit the search of "jan" in the first piece of the text and give the rest of the information place in the form.

The script can read only 1 file en reads the whole file :S

i hope some one can help me whit these problems i have whit this:)

sorry if the explanation sounds a little noobisch but i m rather new at this .

and find it a big step for me for getting this far:)

whit kind regards FMS

VCfile.txt:

VCfile
harry.potter.nl|local street|baseball|nr.14|expert
mariska.pijnacker.nl|far out street|Soccerl|nr.14|novice
plofje.trofje.nl|duda street|baseball|nr.133|expert
hetje.fretje.nl|fre street|Soccer|nr.156|noob
blaas.kaak.nl|asdfs street|baseball|nr.34|expert
kees.kotter.nl|gsafsd street|Soccer|nr.24|novice
klaas.plotter.nl|dsfa street|baseball|nr.14|expert
jan.snotter.nl|gfdg street|football|nr.12|expert

TDfile.txt:

TDFILE
harry.snotter.nl|local street|baseball|nr.14|expert
mariska.pijnacker.nl|far out street|Soccerl|nr.14|novice
plofje.trofje.nl|duda street|baseball|nr.133|expert
hetje.fretje.nl|fre street|Soccer|nr.156|noob
blaas.kaak.nl|asdfs street|baseball|nr.34|expert
kees.kotter.nl|gsafsd street|Soccer|nr.24|novice
klaas.plotter.nl|dsfa street|baseball|nr.14|expert
jan.snotter.nl|gfdg street|Baseball|nr.12|noob

This is what i get this far:

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
;*****************************************************************************************************************************
Switch @HOUR
Case 6 To 11
    $welkom = "Goedemorgen"
Case 12 To 17
    $welkom = "Goedemiddag"
Case 18 To 21
    $welkom = "Goede avond"
Case Else
    $welkom = "Wat doe je nog hier?"
EndSwitch
;*****************************************************************************************************************************
$Form1 = GUICreate("Testje", 570, 150, 277, 322)
$Tab1 = GUICtrlCreateTab(8, 8, 545, 129)
GUICtrlSetResizing(-1, $GUI_DOCKWIDTH+$GUI_DOCKHEIGHT)
;*****************************************************************************************************************************
$TabSheet1 = GUICtrlCreateTabItem("THT")
;*****************************************************************************************************************************
$LabelNVInr = GUICtrlCreateLabel($welkom & "                                               please here your search query", 25, 50, 226, 30)
$BCancel = GUICtrlCreateButton("Cancel", 30, 89, 137, 25, $WS_GROUP)
$BInvetory = GUICtrlCreateButton("Invetory", 222, 90, 137, 25, BitOR($BS_CENTER,$BS_PUSHLIKE,$BS_MULTILINE,$WS_GROUP))
$BConnect = GUICtrlCreateButton("Connect", 400, 87, 137, 25, BitOR($BS_DEFPUSHBUTTON,$WS_GROUP))
$INVInr = GUICtrlCreateInput("klaas", 304, 56, 233, 21 )
;*****************************************************************************************************************************
$TabSheet2 = GUICtrlCreateTabItem("Setup")
;*****************************************************************************************************************************
$Checkbox1 = GUICtrlCreateCheckbox("Checkbox1", 12, 41, 17, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
$LabelTDfile = GUICtrlCreateLabel("Location of TD database file", 36, 41, 154, 17)
$InputTDfile = GUICtrlCreateInput("C:\Temp\TDfile.txt", 196, 41, 337, 21, BitOR($ES_UPPERCASE,$ES_AUTOHSCROLL))
;*****************************************************************************************************************************
$Checkbox2 = GUICtrlCreateCheckbox("Checkbox1", 12, 65, 17, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
$LabelVCfile = GUICtrlCreateLabel("Location of VC database file", 36, 65, 153, 17)
$InputVCfile = GUICtrlCreateInput("C:\Temp\VCfile.txt", 196, 65, 337, 21)
;*****************************************************************************************************************************
$InputNVItemp = GUICtrlCreateInput("Input1", 112, 101, 97, 21)
$LabelNVItemp = GUICtrlCreateLabel("NVI nr template", 16, 100, 77, 17)
;*****************************************************************************************************************************
$RadioVNC = GUICtrlCreateRadio("Radio1", 232, 104, 17, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
$Label4 = GUICtrlCreateLabel("VNC", 264, 104, 26, 17)
$RadioRDP = GUICtrlCreateRadio("Radio2", 312, 104, 17, 17)
$Label5 = GUICtrlCreateLabel("RDP (under construction)", 344, 104, 124, 17)
;*****************************************************************************************************************************
GUICtrlCreateTabItem("")
GUISetState(@SW_SHOW)
Dim $Form1_1_AccelTable[3][2] = [["^c", $BCancel],["^e", $BInvetory],["^d", $BConnect]]
GUISetAccelerators($Form1_1_AccelTable)


While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                    Exit
                Case $BCancel
                    Exit
                Case $BInvetory
                    ;#comments-start
                    $VmwareFile = FileOpen(GUICtrlRead ($InputVCfile), 0)
                    $TdwareFile = FileOpen(GUICtrlRead ($InputTDfile), 0)
                        If $VmwareFile = -1 Then
                            MsgBox(0, "Error", "Cant open " & GUICtrlRead ($InputVCfile) & " ????")
                            Exit
                        EndIf
                        If $TdwareFile = -1 Then
                            MsgBox(0, "Error", "Cant open " & GUICtrlRead ($InputTDfile) & " ????")
                            exit
                        EndIf
                        While $VmwareFile = 1
                            $lineVM = FileReadLine($VmwareFile)
                                If @error = -1 Then ExitLoop
                                        MsgBox(0, "Line read:", $lineVM)
                                        #comments-start

                                        #comments-end
                                Wend
                        While $TdwareFile = 1
                            $lineTD =  FileReadLine($TdwareFile)
                                If @error = -1 Then ExitLoop
                                    MsgBox(0, "TD read:" , $lineTD)
                                WEnd
                    FileClose($TdwareFile)
                    FileClose($VmwareFile)
                Case $BConnect
                        Exit
        EndSwitch
WEnd

as finishing touch god created the dutch

Link to comment
Share on other sites

  • Moderators

FMS,

I would read the 2 files into separate arrays and then work on them in that form. Try putting this in your script: :idea:

Case $BInvetory
    ; Read files into arrays
        Global $aVM_Array, $aTD_Array
    _FileReadToArray(GUICtrlRead ($InputVCfile), $aVM_Array)
    _FileReadToArray(GUICtrlRead ($InputTDfile), $aTD_Array)

    ; Search arrays for the key word
    $sKey = GUICtrlRead($INVInr)
    $iIndex_VM = _ArraySearch($aVM_Array, $sKey, 0, 0, 0, 1)
    If $iIndex_VM <> -1 Then
        MsgBox(0, "Found", "Found " & $sKey & " in VM file" & @CRLF & $aVM_Array[$iIndex_VM])
    EndIf
    $iIndex_TD = _ArraySearch($aTD_Array, $sKey, 0, 0, 0, 1)
    If $iIndex_TD <> -1 Then
        MsgBox(0, "Found", "Found " & $sKey & " in TD file" & @CRLF & $aTD_Array[$iIndex_VM])
    EndIf

You will have to add File.au3 and Array.au3 to your include files.

Just replace the MsgBoxes with whatever code you develop to display the contents of the information found. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Heey Melba,

how genius :)

this was just what i needed.

i tried it an works just fine :idea:

now i can go further this weekend:)

do u have also any tips i can use to read the fields between the "|"

Because in the end i want to create a field whit something like this:

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

$Form1 = GUICreate("Form1", 409, 242, 192, 124)
$Label1 = GUICtrlCreateLabel("Person :", 32, 48, 43, 17)
$Label2 = GUICtrlCreateLabel("Jan snotter", 88, 48, 43, 17)
$Label3 = GUICtrlCreateLabel("VM file output", 88, 24, 69, 17)
$Label4 = GUICtrlCreateLabel("TD file output", 256, 24, 68, 17)
$Label5 = GUICtrlCreateLabel("Jan snotter", 256, 48, 43, 17)
$Label6 = GUICtrlCreateLabel("Street :", 32, 78, 43, 17)
$Label7 = GUICtrlCreateLabel("gfdg street", 87, 76, 54, 17)
$Label8 = GUICtrlCreateLabel("gfdg street", 256, 76, 54, 17)
$Label9 = GUICtrlCreateLabel("Best in :", 32, 107, 42, 17)
$Label10 = GUICtrlCreateLabel("Street :", 32, 136, 43, 17)
$Label11 = GUICtrlCreateLabel("Footbal", 88, 109, 39, 17)
$Label12 = GUICtrlCreateLabel("nr.12", 88, 136, 28, 17)
$Label13 = GUICtrlCreateLabel("Baselball", 256, 110, 46, 17)
$Label14 = GUICtrlCreateLabel("nr.14", 256, 136, 28, 17)
$Label15 = GUICtrlCreateLabel("Skill lvl", 32, 176, 36, 17)
$Label16 = GUICtrlCreateLabel("expert", 80, 176, 33, 17)
$Label17 = GUICtrlCreateLabel("Noob", 256, 176, 30, 17)
$Button1 = GUICtrlCreateButton("OK", 32, 200, 361, 33, $WS_GROUP)
GUISetState(@SW_SHOW)


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

Thnx

Gr

Edited by FMS

as finishing touch god created the dutch

Link to comment
Share on other sites

  • Moderators

FMS,

Look at StringSplit in the Help file - it will get the values into an array. Then loop through and change the values in the labels.

Here is an example: :idea:

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

; We have got our data from the code above:
$VC_Text = "jan.snotter.nl|gfdg street|football|nr.12|expert"
$TD_Text = "jan.snotter.nl|gfdg street|Baseball|nr.12|noob"

$Form1 = GUICreate("Form1", 409, 242, 192, 124)

GUICtrlCreateLabel("VM file output", 88, 24, 69, 17)
GUICtrlCreateLabel("TD file output", 256, 24, 68, 17)
GUICtrlCreateLabel("Person :", 32, 48, 43, 17)
GUICtrlCreateLabel("Street :", 32, 78, 43, 17)
GUICtrlCreateLabel("Best in :", 32, 107, 42, 17)
GUICtrlCreateLabel("Street :", 32, 136, 43, 17)
GUICtrlCreateLabel("Skill lvl", 32, 176, 36, 17)

; VC Output labels
$VCLabel_Start = GUICtrlCreateDummy()
GUICtrlCreateLabel("Who", 88, 48, 43, 17)
GUICtrlCreateLabel("Where", 87, 76, 54, 17)
GUICtrlCreateLabel("Game", 88, 109, 39, 17)
GUICtrlCreateLabel("Number", 88, 136, 28, 17)
GUICtrlCreateLabel("?", 80, 176, 33, 17)

; TD Output labels
$TDLabel_Start = GUICtrlCreateDummy()
GUICtrlCreateLabel("Who", 256, 48, 43, 17)
GUICtrlCreateLabel("Where", 256, 76, 54, 17)
GUICtrlCreateLabel("Game", 256, 110, 46, 17)
GUICtrlCreateLabel("Number", 256, 136, 28, 17)
GUICtrlCreateLabel("?", 256, 176, 30, 17)

$Button1 = GUICtrlCreateButton("OK", 32, 200, 361, 33, $WS_GROUP)

GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            $aVC = StringSplit($VC_Text, "|")
            $aTD = StringSplit($TD_Text, "|")
            For $i = 1 To 5
                GUICtrlSetData($VCLabel_Start + $i, $aVC[$i])
                GUICtrlSetData($TDLabel_Start + $i, $aTD[$i])
            Next
    EndSwitch
WEnd

A couple of points:

Note the use of Dummy controls so you can generate the ControlIDs of your labels without having to save them in variables. But note also you need to create the labels in immediate succession. :)

If you are not very used to arrays - I recommend the tutorial in the Wiki. :)

Please ask if anything is unclear. :(

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Many kudo's comming your way :idea: rofl

I put it in the the whole script and tweeked it in some places.

this for iff in the input file (TDfile.txt or VCfile.txt) are scrambled diliverd (name location changed for street location in the file)

So iff that happen it's easy to change the location.

many thnx for this pointer from you.

Do u have also an ID if the search query result in more then 1 hit in 1 file or both file's?

(like if you look for footbal???)

here are more then 1 players in the txt file.

This is what i get this far:

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
#include <File.au3>
#include <Array.au3 >
;*****************************************************************************************************************************
Switch @HOUR
Case 6 To 11
    $welkom = "Goedemorgen"
Case 12 To 17
    $welkom = "Goedemiddag"
Case 18 To 21
    $welkom = "Goede avond"
Case Else
    $welkom = "Wat doe je nog hier?"
EndSwitch
;*****************************************************************************************************************************
$Form1 = GUICreate("Testje", 570, 150, 277, 322)
$Tab1 = GUICtrlCreateTab(8, 8, 545, 129)
GUICtrlSetResizing(-1, $GUI_DOCKWIDTH+$GUI_DOCKHEIGHT)
;*****************************************************************************************************************************
$TabSheet1 = GUICtrlCreateTabItem("THT")
;*****************************************************************************************************************************
$LabelNVInr = GUICtrlCreateLabel($welkom & @CRLF & "please here your search query", 25, 50, 226, 30)
$BCancel = GUICtrlCreateButton("Cancel", 30, 89, 137, 25, $WS_GROUP)
$BInvetory = GUICtrlCreateButton("Invetory", 222, 90, 137, 25, BitOR($BS_CENTER,$BS_PUSHLIKE,$BS_MULTILINE,$WS_GROUP))
$BConnect = GUICtrlCreateButton("Connect", 400, 87, 137, 25, BitOR($BS_DEFPUSHBUTTON,$WS_GROUP))
$INVInr = GUICtrlCreateInput("harry", 304, 56, 233, 21 )
;*****************************************************************************************************************************
$TabSheet2 = GUICtrlCreateTabItem("Setup")
;*****************************************************************************************************************************
$Checkbox1 = GUICtrlCreateCheckbox("Checkbox1", 12, 41, 17, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
$LabelTDfile = GUICtrlCreateLabel("Location of TD database file", 36, 41, 154, 17)
$InputTDfile = GUICtrlCreateInput("C:\Temp\TDfile.txt", 196, 41, 337, 21, BitOR($ES_UPPERCASE,$ES_AUTOHSCROLL))
;*****************************************************************************************************************************
$Checkbox2 = GUICtrlCreateCheckbox("Checkbox1", 12, 65, 17, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
$LabelVCfile = GUICtrlCreateLabel("Location of VC database file", 36, 65, 153, 17)
$InputVCfile = GUICtrlCreateInput("C:\Temp\VCfile.txt", 196, 65, 337, 21)
;*****************************************************************************************************************************
$InputNVItemp = GUICtrlCreateInput("Input1", 112, 101, 97, 21)
$LabelNVItemp = GUICtrlCreateLabel("NVI nr template", 16, 100, 77, 17)
;*****************************************************************************************************************************
$RadioVNC = GUICtrlCreateRadio("Radio1", 232, 104, 17, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
$Label4 = GUICtrlCreateLabel("VNC", 264, 104, 26, 17)
$RadioRDP = GUICtrlCreateRadio("Radio2", 312, 104, 17, 17)
$Label5 = GUICtrlCreateLabel("RDP (under construction)", 344, 104, 124, 17)
;*****************************************************************************************************************************
GUICtrlCreateTabItem("")
GUISetState(@SW_SHOW)
Dim $Form1_1_AccelTable[3][2] = [["^c", $BCancel],["^e", $BInvetory],["^d", $BConnect]]
GUISetAccelerators($Form1_1_AccelTable)


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

                    ; Read files into arrays
                    Global $aVM_Array, $aTD_Array
                    _FileReadToArray(GUICtrlRead ($InputVCfile), $aVM_Array)
                    _FileReadToArray(GUICtrlRead ($InputTDfile), $aTD_Array)

                    ; Search arrays for the key word
                    $sKey = GUICtrlRead($INVInr)
                    $iIndex_VM = _ArraySearch($aVM_Array, $sKey, 0, 0, 0, 1)
                    If $iIndex_VM <> -1 Then
                        ;MsgBox(0, "Found", "Found " & $sKey & " in VM file" & @CRLF & $aVM_Array[$iIndex_VM])
                    EndIf
                    $iIndex_TD = _ArraySearch($aTD_Array, $sKey, 0, 0, 0, 1)
                    If $iIndex_TD <> -1 Then
                        ;MsgBox(0, "Found", "Found " & $sKey & " in TD file" & @CRLF & $aTD_Array[$iIndex_VM])
                    EndIf
                        ; We have got our data from the code above:
                    $VC_Text = $aVM_Array[$iIndex_VM]
                    $TD_Text = $aTD_Array[$iIndex_VM]

                        $Form1 = GUICreate("Form1", 409, 242, 192, 124)

                        GUICtrlCreateLabel("VM file output", 88, 24, 69, 17)
                        GUICtrlCreateLabel("TD file output", 256, 24, 68, 17)
                        GUICtrlCreateLabel("Person :", 32, 48, 143, 17)
                        GUICtrlCreateLabel("Street :", 32, 78, 43, 17)
                        GUICtrlCreateLabel("Best in :", 32, 107, 42, 17)
                        GUICtrlCreateLabel("Number :", 32, 136, 43, 17)
                        GUICtrlCreateLabel("skill", 32, 176, 36, 17)

                        ; VC Output labels
                        $VCLabel_Start = GUICtrlCreateDummy()
                        GUICtrlCreateLabel("Who", 88, 48, 1143, 17)
                        GUICtrlCreateLabel("Where", 87, 76, 1154, 17)
                        GUICtrlCreateLabel("Game", 88, 109, 1139, 17)
                        GUICtrlCreateLabel("Number", 88, 136, 1128, 17)
                        GUICtrlCreateLabel("?", 80, 176, 1133, 17)

                        ; TD Output labels
                        $TDLabel_Start = GUICtrlCreateDummy()
                        GUICtrlCreateLabel("Who", 256, 48, 1143, 17)
                        GUICtrlCreateLabel("Where", 256, 76, 1154, 17)
                        GUICtrlCreateLabel("Game", 256, 110, 1146, 17)
                        GUICtrlCreateLabel("Number", 256, 136, 1128, 17)
                        GUICtrlCreateLabel("?", 256, 176, 1130, 17)

                        $Button1 = GUICtrlCreateButton("OK", 32, 200, 361, 33, BitOR($BS_DEFPUSHBUTTON,$WS_GROUP))

                        GUISetState(@SW_SHOW)

                        While 1
                        $nMsg = GUIGetMsg()
                        Switch $nMsg
                            Case $GUI_EVENT_CLOSE
                                Exit
                            Case $Button1
                                $aVC = StringSplit($VC_Text, "|")
                                $aTD = StringSplit($TD_Text, "|")

                                GUICtrlSetData($TDLabel_Start + 1, $aTD[1])
                                GUICtrlSetData($TDLabel_Start + 2, $aTD[2])
                                GUICtrlSetData($TDLabel_Start + 3, $aTD[3])
                                GUICtrlSetData($TDLabel_Start + 4, $aTD[4])
                                GUICtrlSetData($TDLabel_Start + 5, $aTD[5])

                                GUICtrlSetData($VCLabel_Start + 1, $aVC[1])
                                GUICtrlSetData($VCLabel_Start + 2, $aVC[2])
                                GUICtrlSetData($VCLabel_Start + 3, $aVC[3])
                                GUICtrlSetData($VCLabel_Start + 4, $aVC[4])
                                GUICtrlSetData($VCLabel_Start + 5, $aVC[5])

                                ;Next
                            EndSwitch
                        WEnd

        EndSwitch
WEnd
Edited by FMS

as finishing touch god created the dutch

Link to comment
Share on other sites

  • Moderators

FMS,

Do u have also an ID if the search query result in more then 1 hit in 1 file or both file's?

To get all the matches, you would need to search through each array until you reached the end and count the number of matches returned. You would do this by using (returned index + 1) as the start point for the next search.

As to displaying the results - I can think of 2 options:

1. Use the OK button to move through the results until all have been displayed. Not much change your GUI, but only one match per file displayed at a time.

2. Change your GUI to use ListViews and display all matches in them (my preference :idea: ).

M23

P.S. Why did you remove the loop to put the data into the labels? That was the whole point of using the Dummy controls. :)

I have put it back in and added some error-checking for you (try searching for a non-existent value :( ):

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
#include <File.au3>
#include <Array.au3 >
;*****************************************************************************************************************************
Switch @HOUR
    Case 6 To 11
        $welkom = "Goedemorgen"
    Case 12 To 17
        $welkom = "Goedemiddag"
    Case 18 To 21
        $welkom = "Goede avond"
    Case Else
        $welkom = "Wat doe je nog hier?"
EndSwitch
;*****************************************************************************************************************************
$Form1 = GUICreate("Testje", 570, 150, 277, 322)
$Tab1 = GUICtrlCreateTab(8, 8, 545, 129)
GUICtrlSetResizing(-1, $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT)
;*****************************************************************************************************************************
$TabSheet1 = GUICtrlCreateTabItem("THT")
;*****************************************************************************************************************************
$LabelNVInr = GUICtrlCreateLabel($welkom & @CRLF & "please here your search query", 25, 50, 226, 30)
$BCancel = GUICtrlCreateButton("Cancel", 30, 89, 137, 25, $WS_GROUP)
$BInvetory = GUICtrlCreateButton("Invetory", 222, 90, 137, 25, BitOR($BS_CENTER, $BS_PUSHLIKE, $BS_MULTILINE, $WS_GROUP))
$BConnect = GUICtrlCreateButton("Connect", 400, 87, 137, 25, BitOR($BS_DEFPUSHBUTTON, $WS_GROUP))
$INVInr = GUICtrlCreateInput("harry", 304, 56, 233, 21)
;*****************************************************************************************************************************
$TabSheet2 = GUICtrlCreateTabItem("Setup")
;*****************************************************************************************************************************
$Checkbox1 = GUICtrlCreateCheckbox("Checkbox1", 12, 41, 17, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
$LabelTDfile = GUICtrlCreateLabel("Location of TD database file", 36, 41, 154, 17)
$InputTDfile = GUICtrlCreateInput("TDfile.txt", 196, 41, 337, 21, BitOR($ES_UPPERCASE, $ES_AUTOHSCROLL))
;*****************************************************************************************************************************
$Checkbox2 = GUICtrlCreateCheckbox("Checkbox1", 12, 65, 17, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
$LabelVCfile = GUICtrlCreateLabel("Location of VC database file", 36, 65, 153, 17)
$InputVCfile = GUICtrlCreateInput("VCfile.txt", 196, 65, 337, 21)
;*****************************************************************************************************************************
$InputNVItemp = GUICtrlCreateInput("Input1", 112, 101, 97, 21)
$LabelNVItemp = GUICtrlCreateLabel("NVI nr template", 16, 100, 77, 17)
;*****************************************************************************************************************************
$RadioVNC = GUICtrlCreateRadio("Radio1", 232, 104, 17, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
$Label4 = GUICtrlCreateLabel("VNC", 264, 104, 26, 17)
$RadioRDP = GUICtrlCreateRadio("Radio2", 312, 104, 17, 17)
$Label5 = GUICtrlCreateLabel("RDP (under construction)", 344, 104, 124, 17)
;*****************************************************************************************************************************
GUICtrlCreateTabItem("")
GUISetState(@SW_SHOW)
Dim $Form1_1_AccelTable[3][2] = [["^c", $BCancel],["^e", $BInvetory],["^d", $BConnect]]
GUISetAccelerators($Form1_1_AccelTable)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE, $BCancel
            Exit
        Case $BInvetory
            Exit
        Case $BConnect

            ; Read files into arrays
            Global $aVC_Array, $aTD_Array
            _FileReadToArray(GUICtrlRead($InputVCfile), $aVC_Array)
            _FileReadToArray(GUICtrlRead($InputTDfile), $aTD_Array)

            ; Search arrays for the key word
            $sKey = GUICtrlRead($INVInr)
            $iIndex_VC = _ArraySearch($aVC_Array, $sKey, 0, 0, 0, 1)
            If $iIndex_VC <> -1 Then
                $VC_Text = $aVC_Array[$iIndex_VC]
            Else
                $VC_Text = "Not Found VC"
            EndIf

            $iIndex_TD = _ArraySearch($aTD_Array, $sKey, 0, 0, 0, 1)
            If $iIndex_TD <> -1 Then
                $TD_Text = $aTD_Array[$iIndex_TD]
            Else
                $TD_Text = "Not Found TD"
            EndIf

            ConsoleWrite($VC_Text & " - " & $TD_Text & @CRLF)

            $Form1 = GUICreate("Form1", 409, 242, 192, 124)

            GUICtrlCreateLabel("VC file output", 88, 24, 69, 17)
            GUICtrlCreateLabel("TD file output", 256, 24, 68, 17)
            GUICtrlCreateLabel("Person :", 32, 48, 143, 17)
            GUICtrlCreateLabel("Street :", 32, 78, 43, 17)
            GUICtrlCreateLabel("Best in :", 32, 107, 42, 17)
            GUICtrlCreateLabel("Number :", 32, 136, 43, 17)
            GUICtrlCreateLabel("skill", 32, 176, 36, 17)

            ; VC Output labels
            $VCLabel_Start = GUICtrlCreateDummy()
            GUICtrlCreateLabel("Who", 88, 48, 1143, 17)
            GUICtrlCreateLabel("Where", 87, 76, 1154, 17)
            GUICtrlCreateLabel("Game", 88, 109, 1139, 17)
            GUICtrlCreateLabel("Number", 88, 136, 1128, 17)
            GUICtrlCreateLabel("?", 80, 176, 1133, 17)

            ; TD Output labels
            $TDLabel_Start = GUICtrlCreateDummy()
            GUICtrlCreateLabel("Who", 256, 48, 1143, 17)
            GUICtrlCreateLabel("Where", 256, 76, 1154, 17)
            GUICtrlCreateLabel("Game", 256, 110, 1146, 17)
            GUICtrlCreateLabel("Number", 256, 136, 1128, 17)
            GUICtrlCreateLabel("?", 256, 176, 1130, 17)

            $Button1 = GUICtrlCreateButton("OK", 32, 200, 361, 33, BitOR($BS_DEFPUSHBUTTON, $WS_GROUP))

            GUISetState(@SW_SHOW)

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

                        Local $aVC[6] = ["", "Not found"], $aTD[6] = ["", "Not found"]
                        If $VC_Text <> "Not Found VC" Then $aVC = StringSplit($VC_Text, "|")
                        If $TD_Text <> "Not Found TD" Then $aTD = StringSplit($TD_Text, "|")

                        For $n = 1 To 5
                            GUICtrlSetData($VCLabel_Start + $n, $aVC[$n])
                            GUICtrlSetData($TDLabel_Start + $n, $aTD[$n])
                        Next

                EndSwitch
            WEnd

    EndSwitch
WEnd

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

heey melba,

That whas very nice of you to think of that (the error checking)

I treid the whole day in making the output in a "listview" :)

haven't come up whit something usefull :)

the problem is in changing the fields in listvieuw.

This is what i get this far:

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
#include <File.au3>
#include <Array.au3 >
;*****************************************************************************************************************************

#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>
;*****************************************************************************************************************************
Switch @HOUR
    Case 6 To 11
        $welkom = "Goedemorgen"
    Case 12 To 17
        $welkom = "Goedemiddag"
    Case 18 To 21
        $welkom = "Goede avond"
    Case Else
        $welkom = "Wat doe je nog hier?"
EndSwitch
;*****************************************************************************************************************************
$Form1 = GUICreate("Testje", 570, 150, 277, 322)
$Tab1 = GUICtrlCreateTab(8, 8, 545, 129)
GUICtrlSetResizing(-1, $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT)
;*****************************************************************************************************************************
$TabSheet1 = GUICtrlCreateTabItem("THT")
;*****************************************************************************************************************************
$LabelNVInr = GUICtrlCreateLabel($welkom & @CRLF & "please here your search query", 25, 50, 226, 30)
$BCancel = GUICtrlCreateButton("Cancel", 30, 89, 137, 25, $WS_GROUP)
$BInvetory = GUICtrlCreateButton("Invetory", 222, 90, 137, 25, BitOR($BS_CENTER, $BS_PUSHLIKE, $BS_MULTILINE, $WS_GROUP))
$BConnect = GUICtrlCreateButton("Connect", 400, 87, 137, 25, BitOR($BS_DEFPUSHBUTTON, $WS_GROUP))
$INVInr = GUICtrlCreateInput("harry", 304, 56, 233, 21)
;*****************************************************************************************************************************
$TabSheet2 = GUICtrlCreateTabItem("Setup")
;*****************************************************************************************************************************
$Checkbox1 = GUICtrlCreateCheckbox("Checkbox1", 12, 41, 17, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
$LabelTDfile = GUICtrlCreateLabel("Location of TD database file", 36, 41, 154, 17)

$InputTDfile = GUICtrlCreateInput("C:\Temp\TDfile.txt", 196, 41, 337, 21, BitOR($ES_UPPERCASE, $ES_AUTOHSCROLL))
;*****************************************************************************************************************************
$Checkbox2 = GUICtrlCreateCheckbox("Checkbox1", 12, 65, 17, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
$LabelVCfile = GUICtrlCreateLabel("Location of VC database file", 36, 65, 153, 17)

$InputVCfile = GUICtrlCreateInput("C:\Temp\VCfile.txt", 196, 65, 337, 21)
;*****************************************************************************************************************************
$InputNVItemp = GUICtrlCreateInput("Input1", 112, 101, 97, 21)
$LabelNVItemp = GUICtrlCreateLabel("NVI nr template", 16, 100, 77, 17)
;*****************************************************************************************************************************
$RadioVNC = GUICtrlCreateRadio("Radio1", 232, 104, 17, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
$Label4 = GUICtrlCreateLabel("VNC", 264, 104, 26, 17)
$RadioRDP = GUICtrlCreateRadio("Radio2", 312, 104, 17, 17)
$Label5 = GUICtrlCreateLabel("RDP (under construction)", 344, 104, 124, 17)
;*****************************************************************************************************************************
GUICtrlCreateTabItem("")
GUISetState(@SW_SHOW)
Dim $Form1_1_AccelTable[3][2] = [["^c", $BCancel],["^e", $BInvetory],["^d", $BConnect]]
GUISetAccelerators($Form1_1_AccelTable)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE, $BCancel
            Exit
        Case $BInvetory
            Exit
        Case $BConnect

            ; Read files into arrays
            Global $aVC_Array, $aTD_Array
            _FileReadToArray(GUICtrlRead($InputVCfile), $aVC_Array)
            _FileReadToArray(GUICtrlRead($InputTDfile), $aTD_Array)

            ; Search arrays for the key word
            $sKey = GUICtrlRead($INVInr)
            $iIndex_VC = _ArraySearch($aVC_Array, $sKey, 0, 0, 0, 1)
            If $iIndex_VC <> -1 Then
                $VC_Text = $aVC_Array[$iIndex_VC]
            Else;*********************************************************************************zo file niet gevonden geef dit weer
                $VC_Text = "Not Found VC"
            EndIf

            $iIndex_TD = _ArraySearch($aTD_Array, $sKey, 0, 0, 0, 1)
            If $iIndex_TD <> -1 Then
                $TD_Text = $aTD_Array[$iIndex_TD]
            Else
                $TD_Text = "Not Found TD"
            EndIf
        Example_UDF_Created() ;use UDF built listview

            ConsoleWrite($VC_Text & " - " & $TD_Text & @CRLF)
#comments-start
            $Form1 = GUICreate("Form1", 409, 242, 192, 124)

            GUICtrlCreateLabel("VC file output", 88, 24, 69, 17)
            GUICtrlCreateLabel("TD file output", 256, 24, 68, 17)
            GUICtrlCreateLabel("Person :", 32, 48, 143, 17)
            GUICtrlCreateLabel("Street :", 32, 78, 43, 17)
            GUICtrlCreateLabel("Best in :", 32, 107, 42, 17)
            GUICtrlCreateLabel("Number :", 32, 136, 43, 17)
            GUICtrlCreateLabel("skill", 32, 176, 36, 17)

            ; VC Output labels
            $VCLabel_Start = GUICtrlCreateDummy()
            GUICtrlCreateLabel("Who", 88, 48, 1143, 17)
            GUICtrlCreateLabel("Where", 87, 76, 1154, 17)
            GUICtrlCreateLabel("Game", 88, 109, 1139, 17)
            GUICtrlCreateLabel("4444", 88, 136, 1128, 17)
            GUICtrlCreateLabel("?", 80, 176, 1133, 17)

            ; TD Output labels
            $TDLabel_Start = GUICtrlCreateDummy()
            GUICtrlCreateLabel("Who", 256, 48, 1143, 17)
            GUICtrlCreateLabel("Where", 256, 76, 1154, 17)
            GUICtrlCreateLabel("Game", 256, 110, 1146, 17)
            GUICtrlCreateLabel("Number", 256, 136, 1128, 17)
            GUICtrlCreateLabel("?", 256, 176, 1130, 17)

            $Button1 = GUICtrlCreateButton("OK", 32, 200, 361, 33, BitOR($BS_DEFPUSHBUTTON, $WS_GROUP))

            GUISetState(@SW_SHOW)

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


                        Local $aVC[6] = ["", "Not found"], $aTD[6] = ["", "Not found"]
                        If $VC_Text <> "Not Found VC" Then $aVC = StringSplit($VC_Text, "|")
                        If $TD_Text <> "Not Found TD" Then $aTD = StringSplit($TD_Text, "|")

                        For $n = 1 To 5
                            GUICtrlSetData($VCLabel_Start + $n, $aVC[$n])
                            GUICtrlSetData($TDLabel_Start + $n, $aTD[$n])
                        Next


                EndSwitch
            WEnd
#comments-end
    EndSwitch
WEnd



Func Example_UDF_Created()
    Local $GUI, $hImage, $aImage, $hListView
    Local $exStyles = BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_DOUBLEBUFFER)

    $GUI = GUICreate("(UDF Created) ListView Set Background Image", 600, 550)

    ;=========================================================================================================
    $hListView = _GUICtrlListView_Create($GUI, "", 2, 2, 596, 500, -1, -1, True) ; Last option Calls CoInitializeEx
    ;=========================================================================================================
    _GUICtrlListView_SetExtendedListViewStyle($hListView, $exStyles)
    ; Load images
    $hImage = _GUIImageList_Create()
    _GUICtrlListView_SetImageList($hListView, $hImage, 1)

    ; Add columns
    _GUICtrlListView_InsertColumn($hListView, 0, "Person", 100)
    _GUICtrlListView_InsertColumn($hListView, 1, "Best in", 100)
    _GUICtrlListView_InsertColumn($hListView, 2, "playing nr", 100)
    _GUICtrlListView_InsertColumn($hListView, 3, "degree", 100)
    _GUICtrlListView_InsertColumn($hListView, 4, "Tab Collum 5", 100)
    _GUICtrlListView_InsertColumn($hListView, 5, "Tab Collumn 6", 100)

    ; Add items
    _GUICtrlListView_AddItem($hListView, "Row 1: Col 1", 0)
    _GUICtrlListView_AddSubItem($hListView, 0, "Row 1: Col 2", 1)
    _GUICtrlListView_AddSubItem($hListView, 0, "Row 1: Col 2" , 2)
    _GUICtrlListView_AddSubItem($hListView, 0, "Row 1: Col 4", 3)
    _GUICtrlListView_AddSubItem($hListView, 0, "Row 1: Col 4", 4)
    _GUICtrlListView_AddItem($hListView, "Row 2: Col 1", 1)
    _GUICtrlListView_AddSubItem($hListView, 1, "Row 2: Col 2", 1)
    _GUICtrlListView_AddSubItem($hListView, 1, "Row 2: Col 3", 2)
    _GUICtrlListView_AddSubItem($hListView, 1, "Row 2: Col 4", 3)


    ; Build groups
    _GUICtrlListView_EnableGroupView($hListView)
    _GUICtrlListView_InsertGroup($hListView, -1, 1, "Group 1")
    _GUICtrlListView_InsertGroup($hListView, -1, 2, "Group 2")
    _GUICtrlListView_SetItemGroupID($hListView, 0, 1)
    _GUICtrlListView_SetItemGroupID($hListView, 1, 2)
    _GUICtrlListView_SetItemGroupID($hListView, 2, 2)
    _GUICtrlListView_SetItemGroupID($hListView, 3, 2)

;~  _GUICtrlListView_SetBkColor ($hListView, $CLR_NONE)
;~  _GUICtrlListView_SetTextColor ($hListView, $CLR_NONE)
;~  _GUICtrlListView_SetTextBkColor ($hListView, $CLR_NONE)

    ; Get the Image
    Local $sURL = "http://www.astrocenter.com/us/images/wallpaper/Leo_800x600.jpg"
    Local $sFilePath = @ScriptDir & "\Leo.jpg"
    InetGet($sURL, $sFilePath)

    ; Set the Background Image
    _GUICtrlListView_SetBkImage($hListView, $sFilePath)
    $aImage = _GUICtrlListView_GetBkImage($hListView)

    GUISetState()

    ;MsgBox(4160, "Information", "Background Image: " & $aImage[1])

    ; Loop until user exits
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    ;=========================================================================================================
    DllCall('ole32.dll', 'long', 'CoUinitialize') ; Must call for each CoInitializeEx call made
    ;=========================================================================================================

    GUIDelete()
    FileDelete($sFilePath)
EndFunc   ;==>Example_UDF_Created

It seem's realy nice output but cant make a start whit it...

I hope iff u have any pointers or template?

(i thaught off _GUICtrlListView_SetItem($hListView, "New Item 2", 2) ????

thnx for helping me this far

learned a lot of it :idea:

gr FMS

PS: mine bad i saw it:) thought i removed only the messagebox :(

Edited by FMS

as finishing touch god created the dutch

Link to comment
Share on other sites

  • Moderators

FMS,

I am feeling generous today: :(

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
#include <File.au3>
#include <Array.au3 >
;*****************************************************************************************************************************

#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>
;*****************************************************************************************************************************
Switch @HOUR
    Case 6 To 11
        $welkom = "Goedemorgen"
    Case 12 To 17
        $welkom = "Goedemiddag"
    Case 18 To 21
        $welkom = "Goede avond"
    Case Else
        $welkom = "Wat doe je nog hier?"
EndSwitch
;*****************************************************************************************************************************
$Form1 = GUICreate("Testje", 570, 150, 277, 322)
$Tab1 = GUICtrlCreateTab(8, 8, 545, 129)
GUICtrlSetResizing(-1, $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT)
;*****************************************************************************************************************************
$TabSheet1 = GUICtrlCreateTabItem("THT")
;*****************************************************************************************************************************
$LabelNVInr = GUICtrlCreateLabel($welkom & @CRLF & "please here your search query", 25, 50, 226, 30)
$BCancel = GUICtrlCreateButton("Cancel", 30, 89, 137, 25, $WS_GROUP)
$BInvetory = GUICtrlCreateButton("Invetory", 222, 90, 137, 25, BitOR($BS_CENTER, $BS_PUSHLIKE, $BS_MULTILINE, $WS_GROUP))
$BConnect = GUICtrlCreateButton("Connect", 400, 87, 137, 25, BitOR($BS_DEFPUSHBUTTON, $WS_GROUP))
$INVInr = GUICtrlCreateInput("harry", 304, 56, 233, 21)
;*****************************************************************************************************************************
$TabSheet2 = GUICtrlCreateTabItem("Setup")
;*****************************************************************************************************************************
$Checkbox1 = GUICtrlCreateCheckbox("Checkbox1", 12, 41, 17, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
$LabelTDfile = GUICtrlCreateLabel("Location of TD database file", 36, 41, 154, 17)

$InputTDfile = GUICtrlCreateInput("TDfile.txt", 196, 41, 337, 21, BitOR($ES_UPPERCASE, $ES_AUTOHSCROLL))
;*****************************************************************************************************************************
$Checkbox2 = GUICtrlCreateCheckbox("Checkbox1", 12, 65, 17, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
$LabelVCfile = GUICtrlCreateLabel("Location of VC database file", 36, 65, 153, 17)

$InputVCfile = GUICtrlCreateInput("VCfile.txt", 196, 65, 337, 21)
;*****************************************************************************************************************************
$InputNVItemp = GUICtrlCreateInput("Input1", 112, 101, 97, 21)
$LabelNVItemp = GUICtrlCreateLabel("NVI nr template", 16, 100, 77, 17)
;*****************************************************************************************************************************
$RadioVNC = GUICtrlCreateRadio("Radio1", 232, 104, 17, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
$Label4 = GUICtrlCreateLabel("VNC", 264, 104, 26, 17)
$RadioRDP = GUICtrlCreateRadio("Radio2", 312, 104, 17, 17)
$Label5 = GUICtrlCreateLabel("RDP (under construction)", 344, 104, 124, 17)
;*****************************************************************************************************************************
GUICtrlCreateTabItem("")
GUISetState(@SW_SHOW)
Dim $Form1_1_AccelTable[3][2] = [["^c", $BCancel],["^e", $BInvetory],["^d", $BConnect]]
GUISetAccelerators($Form1_1_AccelTable)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE, $BCancel
            Exit
        Case $BInvetory
            Exit
        Case $BConnect

            ; Read files into arrays
            Global $aVC_Array, $aTD_Array
            _FileReadToArray(GUICtrlRead($InputVCfile), $aVC_Array)
            _FileReadToArray(GUICtrlRead($InputTDfile), $aTD_Array)

            ; Search arrays for the key word
            $sKey = GUICtrlRead($INVInr)
            $aIndex_VC = _ArrayFindAll($aVC_Array, $sKey, 0, 0, 0, 1)
            If Not IsArray($aIndex_VC) Then Global $aIndex_VC[1] = ["Not Found VC"]

            $aIndex_TD = _ArrayFindAll($aTD_Array, $sKey, 0, 0, 0, 1)
            If Not IsArray($aIndex_TD) Then Global $aIndex_TD[1] = ["Not Found TD"]

            Example_UDF_Created() ;use UDF built listview

    EndSwitch
WEnd



Func Example_UDF_Created()
    Local $GUI, $hImage, $aImage, $hListView
    Local $exStyles = BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_DOUBLEBUFFER)

    $GUI = GUICreate("(UDF Created) ListView Set Background Image", 574, 520)

    ; Create VC LV
    GUICtrlCreateLabel("VC Results", 10, 10, 100, 20)
    $hVC_ListView = GUICtrlCreateListView("Person|Street|Best in|Number|Skill", 10, 30, 554, 200)
    ; Set widths
    For $i = 0 To 4
        _GUICtrlListView_SetColumnWidth($hVC_ListView, $i, 110)
    Next
    ; Fill elements
    If $aIndex_VC[0] = "Not Found VC" Then
        GUICtrlCreateListViewItem("Not found", $hVC_ListView)
    Else
        ; Extract the lines from the file
        For $i = 0 To UBound($aIndex_VC) - 1
            ; For each index in the array
            GUICtrlCreateListViewItem($aVC_Array[$aIndex_VC[$i]], $hVC_ListView)
        Next
    EndIf

    ; Create TD LV
    GUICtrlCreateLabel("TD Results", 10, 250, 100, 20)
    $hTD_ListView = GUICtrlCreateListView("Person|Street|Best in|Number|Skill", 10, 270, 554, 200)
    ; Set widths
    For $i = 0 To 4
        _GUICtrlListView_SetColumnWidth($hTD_ListView, $i, 110)
    Next
    ; Fill elements
    If $aIndex_TD[0] = "Not Found TD" Then
        GUICtrlCreateListViewItem("Not found", $hTD_ListView)
    Else
        ; Extract the lines from the file
        For $i = 0 To UBound($aIndex_TD) - 1
            ; For each index in the array
            GUICtrlCreateListViewItem($aTD_Array[$aIndex_TD[$i]], $hTD_ListView)
        Next
    EndIf

    $hOK_Button = GUICtrlCreateButton("OK", 480, 480, 80, 30)

    GUISetState()

    While 1
        If GUIGetMsg() = $hOK_Button Then
            GUIDelete($GUI)
            Return
        EndIf
    WEnd

EndFunc   ;==>Example_UDF_Created

I found a nice little function _ArrayFindAll to do the multiple search in an array. And as you can see the ListViews are not that difficult. :)

Please ask if anything is unclear. :idea:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Heey Melba,

Very nice:)

and indeed not that hard(iff u know it :idea: )

The thing is, I think to hard so want it to complex.

U show me a lot of easyer way's to get the same output :)

Realy mush thnx's for that :(

It's only a pitty that the background picture isn't working anymore:(

I've treid to put in a diffrent picture in both listvieuw's

but wasn't able to do that:)

Do u know why?

i tweeked it a little at the bottom

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
#include <File.au3>
#include <Array.au3 >
;*****************************************************************************************************************************

#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>
;*****************************************************************************************************************************
Switch @HOUR
    Case 6 To 11
        $welkom = "Goedemorgen"
    Case 12 To 17
        $welkom = "Goedemiddag"
    Case 18 To 21
        $welkom = "Goede avond"
    Case Else
        $welkom = "Wat doe je nog hier?"
EndSwitch
;*****************************************************************************************************************************
$Form1 = GUICreate("Testje", 570, 150, 277, 322)
$Tab1 = GUICtrlCreateTab(8, 8, 545, 129)
GUICtrlSetResizing(-1, $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT)
;*****************************************************************************************************************************
$TabSheet1 = GUICtrlCreateTabItem("THT")
;*****************************************************************************************************************************
$LabelNVInr = GUICtrlCreateLabel($welkom & @CRLF & "please here your search query", 25, 50, 226, 30)
$BCancel = GUICtrlCreateButton("Cancel", 30, 89, 137, 25, $WS_GROUP)
$BInvetory = GUICtrlCreateButton("Invetory", 222, 90, 137, 25, BitOR($BS_CENTER, $BS_PUSHLIKE, $BS_MULTILINE, $WS_GROUP))
$BConnect = GUICtrlCreateButton("Connect", 400, 87, 137, 25, BitOR($BS_DEFPUSHBUTTON, $WS_GROUP))
$INVInr = GUICtrlCreateInput("harry", 304, 56, 233, 21)
;*****************************************************************************************************************************
$TabSheet2 = GUICtrlCreateTabItem("Setup")
;*****************************************************************************************************************************
$Checkbox1 = GUICtrlCreateCheckbox("Checkbox1", 12, 41, 17, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
$LabelTDfile = GUICtrlCreateLabel("Location of TD database file", 36, 41, 154, 17)

$InputTDfile = GUICtrlCreateInput("c:\Temp\TDfile.txt", 196, 41, 337, 21, BitOR($ES_UPPERCASE, $ES_AUTOHSCROLL))
;*****************************************************************************************************************************
$Checkbox2 = GUICtrlCreateCheckbox("Checkbox1", 12, 65, 17, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
$LabelVCfile = GUICtrlCreateLabel("Location of VC database file", 36, 65, 153, 17)

$InputVCfile = GUICtrlCreateInput("c:\Temp\VCfile.txt", 196, 65, 337, 21)
;*****************************************************************************************************************************
$InputNVItemp = GUICtrlCreateInput("Input1", 112, 101, 97, 21)
$LabelNVItemp = GUICtrlCreateLabel("NVI nr template", 16, 100, 77, 17)
;*****************************************************************************************************************************
$RadioVNC = GUICtrlCreateRadio("Radio1", 232, 104, 17, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
$Label4 = GUICtrlCreateLabel("VNC", 264, 104, 26, 17)
$RadioRDP = GUICtrlCreateRadio("Radio2", 312, 104, 17, 17)
$Label5 = GUICtrlCreateLabel("RDP (under construction)", 344, 104, 124, 17)
;*****************************************************************************************************************************
GUICtrlCreateTabItem("")
GUISetState(@SW_SHOW)
Dim $Form1_1_AccelTable[3][2] = [["^c", $BCancel],["^e", $BInvetory],["^d", $BConnect]]
GUISetAccelerators($Form1_1_AccelTable)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE, $BCancel
            Exit
        Case $BInvetory
            Exit
        Case $BConnect
            ;Read_file()
;#comments-start
            ; Read files into arrays
            Global $aVC_Array, $aTD_Array
            _FileReadToArray(GUICtrlRead($InputVCfile), $aVC_Array)
            _FileReadToArray(GUICtrlRead($InputTDfile), $aTD_Array)

            ; Search arrays for the key word
            $sKey = GUICtrlRead($INVInr)
            $aIndex_VC = _ArrayFindAll($aVC_Array, $sKey, 0, 0, 0, 1)
            If Not IsArray($aIndex_VC) Then Global $aIndex_VC[1] = ["Not Found VC"]

            $aIndex_TD = _ArrayFindAll($aTD_Array, $sKey, 0, 0, 0, 1)
            If Not IsArray($aIndex_TD) Then Global $aIndex_TD[1] = ["Not Found TD"]
;#comments-end
            form_output() ;use UDF built listview

    EndSwitch
WEnd
#comments-start
Func Read_file()
        ;Read files into arrays
        Global $aVC_Array, $aTD_Array
        _FileReadToArray(GUICtrlRead($InputVCfile), $aVC_Array)
        _FileReadToArray(GUICtrlRead($InputTDfile), $aTD_Array)

        ;Sarch arrays for the key word
        $sKey = GUICtrlRead($INVInr)
        $aIndex_VC = _ArrayFindAll($aVC_Array, $sKey, 0, 0, 0, 1)
        If Not IsArray($aIndex_VC) Then Global $aIndex_VC[1] = ["Not Found VC"]

        $aIndex_TD = _ArrayFindAll($aTD_Array, $sKey, 0, 0, 0, 1)
        If Not IsArray($aIndex_TD) Then Global $aIndex_TD[1] = ["Not Found TD"]
    EndFunc
#comments-end
Func form_output()
    Local $GUI, $hImage, $aImage, $hListView
    Local $exStyles = BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_DOUBLEBUFFER)

    $GUI = GUICreate("(UDF Created) ListView Set Background Image", 574, 520)

    ; Create VC LV
    GUICtrlCreateLabel("VC Results", 10, 10, 100, 20)
    $hVC_ListView = GUICtrlCreateListView("Person|Street|Best in|Number|Skill", 10, 30, 554, 200)
    ; Set widths
    For $i = 0 To 4
        _GUICtrlListView_SetColumnWidth($hVC_ListView, $i, 110)
    Next
    ; Fill elements
    If $aIndex_VC[0] = "Not Found VC" Then
        GUICtrlCreateListViewItem("Not found", $hVC_ListView)
    Else
        ; Extract the lines from the file
        For $i = 0 To UBound($aIndex_VC) - 1
            ; For each index in the array
            GUICtrlCreateListViewItem($aVC_Array[$aIndex_VC[$i]], $hVC_ListView)
        Next
    EndIf

    ; Create TD LV
    GUICtrlCreateLabel("TD Results", 10, 250, 100, 20)
    $hTD_ListView = GUICtrlCreateListView("Person|Street|Best in|Number|Skill", 10, 270, 554, 200)
    ; Set widths
    For $i = 0 To 4
        _GUICtrlListView_SetColumnWidth($hTD_ListView, $i, 110)
    Next
    ; Fill elements
    If $aIndex_TD[0] = "Not Found TD" Then
        GUICtrlCreateListViewItem("Not found", $hTD_ListView)
    Else
        ; Extract the lines from the file
        For $i = 0 To UBound($aIndex_TD) - 1
            ; For each index in the array
            GUICtrlCreateListViewItem($aTD_Array[$aIndex_TD[$i]], $hTD_ListView)
        Next
    EndIf

    $hOK_Button = GUICtrlCreateButton("OK", 480, 480, 80, 30 ,BitOR($BS_DEFPUSHBUTTON , $WS_GROUP))
;**********************************************************************************************************************adding a internet image or local image
;**********************************************************************************************************************
    ;Local $sURL = "http://www.astrocenter.com/us/images/wallpaper/Leo_800x600.jpg"
    Local $sFilePath = "C:\Temp\background.jpg"
    ;InetGet($sURL, $sFilePath)

    ; Set the Background Image
    _GUICtrlListView_SetBkImage($hTD_ListView, $sFilePath)
    $aImage = _GUICtrlListView_GetBkImage($hTD_ListView)
    _GUICtrlListView_SetBkImage($hVC_ListView, $sFilePath)
    $hImage = _GUICtrlListView_GetBkImage($hVC_ListView)

    GUISetState()

    While 1
        If GUIGetMsg() = $hOK_Button Then
            GUIDelete($GUI)
            Return
        EndIf
    WEnd

EndFunc   ;==>Example_UDF_Created

as finishing touch god created the dutch

Link to comment
Share on other sites

  • Moderators

FMS,

You need to read that Help file more: :)

"At this time this function only works with _GUICtrlListView_Create or External ListViews."

So as I used the built-in GUICtrlCreateListView you are out of luck! :(

Why did I use the built-in version? Because it lets you fill the columns with a single command if the items are separated by "|" - which yours were. if you use the UDF _GUICtrlListView_Create then you have to set all the items and subitems yourself - which is tedious. :idea:

So it is up to you. If you want the background images, you have to use the UDF function to create the ListViews - and then rewrite the code to use the _GUICtrlListView_AddItem and _GUICtrlListView_AddSubItem lines to populate them.

Good Luck! :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Heey Melba,

Thnx for your help :idea:

I'll look into it and post the outcome :) (iff I get it working:)whit background and all)

I'm realy thankfull for this:)It make mine life a little bit easyer an know a little bit more:)

whit kind gerards,

FMS

as finishing touch god created the dutch

Link to comment
Share on other sites

Heey Melba,

Hummm isn't that easy getting it done:)

I've tried it in a lot of way's and all din't run:S

(to noob to be treu ... :idea: )

the thing is i don't mind in putting the fields in there myself,

because the 2 inputfile's VM & TD might be scrambled in the second info query.

then is it easyer to change the code....

this way iff in the inputfile the name isn't in the 1 row i could change it to the first row

(and a picture possible in the background:))

Or to left out some info for other users.

I hope it isn't hard for you but could u help me on the way?

whit kind regards,

FMS

PS. i've read your " Extended Message Box " topic.

nice job :)

Edited by FMS

as finishing touch god created the dutch

Link to comment
Share on other sites

  • Moderators

FMS,

Flattery always works! :)

Try this function in your script:

Func Example_UDF_Created()
    Local $GUI, $hImage, $aImage, $hListView
    Local $exStyles = BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_DOUBLEBUFFER)

    $GUI = GUICreate("(UDF Created) ListView Set Background Image", 574, 520)

    ; Create VC LV
    GUICtrlCreateLabel("VC Results", 10, 10, 100, 20)
    $hVC_ListView = _GUICtrlListView_Create($GUI, "Person|Street|Best in|Number|Skill", 10, 30, 554, 200)
    ; Set widths
    For $i = 0 To 4
        _GUICtrlListView_SetColumnWidth($hVC_ListView, $i, 110)
    Next
    ; Fill elements
    If $aIndex_VC[0] = "Not Found VC" Then
        _GUICtrlListView_AddItem($hVC_ListView, "Not found")
    Else
        ; Extract the lines from the file
        For $i = 0 To UBound($aIndex_VC) - 1
            ; For each index in the array
            $aItems = StringSplit($aVC_Array[$aIndex_VC[$i]], "|")
            $iLine = _GUICtrlListView_AddItem($hVC_ListView, $aItems[1])
            For $j = 2 To $aItems[0]
                _GUICtrlListView_AddSubItem($hVC_ListView, $iLine, $aItems[$j], $j - 1)
            Next
        Next
    EndIf
    ; Set background image
    _GUICtrlListView_SetBkImage($hVC_ListView, "Your_Image_Path")

    ; Create TD LV
    GUICtrlCreateLabel("TD Results", 10, 250, 100, 20)
    $hTD_ListView = _GUICtrlListView_Create($GUI, "Person|Street|Best in|Number|Skill", 10, 230, 554, 200)
    ; Set widths
    For $i = 0 To 4
        _GUICtrlListView_SetColumnWidth($hTD_ListView, $i, 110)
    Next
    ; Fill elements
    If $aIndex_TD[0] = "Not Found TD" Then
        _GUICtrlListView_AddItem($hTD_ListView, "Not found")
    Else
        ; Extract the lines from the file
        For $i = 0 To UBound($aIndex_TD) - 1
            ; For each index in the array
            $aItems = StringSplit($aTD_Array[$aIndex_TD[$i]], "|")
            $iLine = _GUICtrlListView_AddItem($hTD_ListView, $aItems[1])
            ConsoleWrite($iLine & @CRLF)
            For $j = 2 To $aItems[0]
                _GUICtrlListView_AddSubItem($hTD_ListView, $iLine, $aItems[$j], $j - 1)
            Next
        Next
    EndIf
    ; Set background image
    _GUICtrlListView_SetBkImage($hTD_ListView, "Your_Image_Path")

    $hOK_Button = GUICtrlCreateButton("OK", 480, 480, 80, 30)

    GUISetState()

    While 1
        If GUIGetMsg() = $hOK_Button Then
            GUIDelete($GUI)
            Return
        EndIf
    WEnd

EndFunc   ;==>Example_UDF_Created

Just replace "Your_Image_Path" with your image path. :idea:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Heey Melba,

once again thnx :)

i've tried it and works great:)

now i'll try to change the collom's of the output.

i'll post the script when it's completed :idea:

gr.

FMS

as finishing touch god created the dutch

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