Jump to content

"OK" Button


iceberg
 Share

Recommended Posts

Hi,

#include <GuiConstants.au3>
#include <GuiListView.au3>
#include <file.au3>
opt('MustDeclareVars', 1)
opt('WinTitleMatchMode', 0)
Dim $listview, $Btn_Exit, $msg, $Status, $Btn_Insert, $ret, $Input_Index, $listview2, $Name, $Timing, $i, $Btn_Print, $Label_1, $Label_3, $Label_7, $Label_8, $Label_9, $Input_4, $Input_5, $Input_6, $Button_10, $Button_11
Local $GUI1 = GUICreate("Team Score System 1.0", 392, 322)

$listview = GUICtrlCreateListView("Names|Timings", 0, 30, 200, 149)
$listview2 = GUICtrlCreateListView("Position|Points", (200), 30, 170, 149)
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT)
GUICtrlSendMsg($listview2, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
GUICtrlSendMsg($listview2, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT)

$i = 0
Local $str = ""
Do
    Local $GUI2 = GUICreate("Individual Score System 1.0", 400, 144, (@DesktopWidth - 400) / 2, (@DesktopHeight - 144) / 2)
    $Label_1 = GUICtrlCreateLabel("Name :", 20, 20, 40, 20)
    $Name = GUICtrlCreateInput("", 70, 15, 310, 20)
    $Label_3 = GUICtrlCreateLabel("Timing :", 20, 55, 40, 20)
    $Input_4 = GUICtrlCreateInput("", 70, 50, 20, 20, $ES_NUMBER)
    $Input_5 = GUICtrlCreateInput("", 130, 50, 20, 20, $ES_NUMBER)
    $Input_6 = GUICtrlCreateInput("", 190, 50, 20, 20, $ES_NUMBER)
    GUICtrlSetLimit($Input_4, 2, 2)
    GUICtrlSetLimit($Input_5, 2, 2)
    GUICtrlSetLimit($Input_6, 2, 2)
    $Label_7 = GUICtrlCreateLabel("mn", 100, 55, 20, 20)
    $Label_8 = GUICtrlCreateLabel("ss", 160, 55, 20, 20)
    $Label_9 = GUICtrlCreateLabel("ms", 220, 55, 20, 20)
    $Button_10 = GUICtrlCreateButton("OK", 70, 90, 100, 30)
    $Button_11 = GUICtrlCreateButton("Cancel", 230, 90, 100, 30)
    
    If @error = 1 Then Exit
    $i = $i + 1
Until $i = 8

GUICtrlCreateListViewItem("1|18", $listview2)
GUICtrlCreateListViewItem("2|14", $listview2)
GUICtrlCreateListViewItem("3|12", $listview2)
GUICtrlCreateListViewItem("4|10", $listview2)
GUICtrlCreateListViewItem("5|8", $listview2)
GUICtrlCreateListViewItem("6|6", $listview2)
GUICtrlCreateListViewItem("7|4", $listview2)
GUICtrlCreateListViewItem("8|2", $listview2)

_GUICtrlListViewSetColumnWidth ($listview, 0, 75)
_GUICtrlListViewSetColumnWidth ($listview, 1, 75)
_GUICtrlListViewSetColumnWidth ($listview, 2, 75)

$Btn_Exit = GUICtrlCreateButton("Exit", 300, 260, 70, 30)
$Btn_Print = GUICtrlCreateButton("Export", 200, 260, 70, 30)

GUISetState()

Dim $B_DESCENDING[_GUICtrlListViewGetSubItemsCount ($listview) ]

While (GUIGetMsg() <> -3)
   $msg = GUIGetMsg()
   Select
      Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
         ExitLoop
     Case $msg = $Button_11
         Exit
        Case $msg = $listview
          ; sort the list by the column header clicked on
            _GUICtrlListViewSort($listview, $B_DESCENDING, GUICtrlGetState($listview))
        Case $msg =$Btn_Print
            PrintPage()
        Case $msg = $Button_10
            $Name = GUICtrlRead($Name)
            $Input_4 = GUICtrlRead($Input_4)
            $Input_5 = GUICtrlRead($Input_5)
            $Input_6 = GUICtrlRead($Input_6)
            GUICtrlCreateListViewItem($Name & "|" & $Input_4 & ":" & $Input_5 & ":" & $Input_6, $listview)
   EndSelect
WEnd

Exit

Func PrintPage()
    Local $f = FileOpen("individual.txt", 1)
    For $i = 0 To 8
        FileWriteLine($f, _GUICtrlListViewGetItemText ($listview, $i) & "|" & _GUICtrlListViewGetItemText ($listview2, $i) & @CRLF)
    Next
    FileClose($f)
    Local $file2 = FileOpen("individual.txt", 0)
    
    If $file2 = -1 Then
        MsgBox(0, "Error", "Unable to open file.")
        Exit
    EndIf
    
    While 1
        Local $line = FileReadLine($file2)
        If @error = -1 Then ExitLoop
        Local $text = StringReplace($line, "|", @TAB)
        FileWriteLine("output.xls", $text & @CRLF)
    WEnd
    
    FileClose($file2)
    MsgBox(0, "", "Done")
    _FilePrint(@ScriptDir & "\output.xls")
EndFunc

Can someone kindly enlighten me as to why my "OK" button doesn't produce an empty GUI? And also, how do i go about validating to ensure that the input fields are not empty?

Thanks alot.

Edited by iceberg

mouse not found....scroll any mouse to continue.

Link to comment
Share on other sites

I leave the rest up to on what to do once you do hit OK

#include <GuiConstants.au3>
#include <GuiListView.au3>
#include <file.au3>
Opt('MustDeclareVars', 1)
Opt('WinTitleMatchMode', 0)
Dim $listview, $Btn_Exit, $msg, $Status, $Btn_Insert, $ret, $Input_Index, $listview2, $Name, $Timing, $i, $Btn_Print, $Label_1, $Label_3, $Label_7, $Label_8, $Label_9, $Input_4, $Input_5, $Input_6, $Button_10, $Button_11
Local $GUI1 = GUICreate("Team Score System 1.0", 392, 322)

$listview = GUICtrlCreateListView("Names|Timings", 0, 30, 200, 149)
$listview2 = GUICtrlCreateListView("Position|Points", (200), 30, 170, 149)
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT)
GUICtrlSendMsg($listview2, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
GUICtrlSendMsg($listview2, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT)

$i = 0
Local $str = ""
Do
    Local $GUI2 = GUICreate("Individual Score System 1.0", 400, 144, (@DesktopWidth - 400) / 2, (@DesktopHeight - 144) / 2)
    $Label_1 = GUICtrlCreateLabel("Name :", 20, 20, 40, 20)
    $Name = GUICtrlCreateInput("", 70, 15, 310, 20)
    $Label_3 = GUICtrlCreateLabel("Timing :", 20, 55, 40, 20)
    $Input_4 = GUICtrlCreateInput("", 70, 50, 20, 20, $ES_NUMBER)
    $Input_5 = GUICtrlCreateInput("", 130, 50, 20, 20, $ES_NUMBER)
    $Input_6 = GUICtrlCreateInput("", 190, 50, 20, 20, $ES_NUMBER)
    GUICtrlSetLimit($Input_4, 2, 2)
    GUICtrlSetLimit($Input_5, 2, 2)
    GUICtrlSetLimit($Input_6, 2, 2)
    $Label_7 = GUICtrlCreateLabel("mn", 100, 55, 20, 20)
    $Label_8 = GUICtrlCreateLabel("ss", 160, 55, 20, 20)
    $Label_9 = GUICtrlCreateLabel("ms", 220, 55, 20, 20)
    $Button_10 = GUICtrlCreateButton("OK", 70, 90, 100, 30)
    $Button_11 = GUICtrlCreateButton("Cancel", 230, 90, 100, 30)

    If @error = 1 Then Exit
    $i = $i + 1
Until $i = 8

GUICtrlCreateListViewItem("1|18", $listview2)
GUICtrlCreateListViewItem("2|14", $listview2)
GUICtrlCreateListViewItem("3|12", $listview2)
GUICtrlCreateListViewItem("4|10", $listview2)
GUICtrlCreateListViewItem("5|8", $listview2)
GUICtrlCreateListViewItem("6|6", $listview2)
GUICtrlCreateListViewItem("7|4", $listview2)
GUICtrlCreateListViewItem("8|2", $listview2)

_GUICtrlListViewSetColumnWidth($listview, 0, 75)
_GUICtrlListViewSetColumnWidth($listview, 1, 75)
_GUICtrlListViewSetColumnWidth($listview, 2, 75)

$Btn_Exit = GUICtrlCreateButton("Exit", 300, 260, 70, 30)
$Btn_Print = GUICtrlCreateButton("Export", 200, 260, 70, 30)

GUISetState()

Dim $B_DESCENDING[_GUICtrlListViewGetSubItemsCount($listview) ]

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE, $Button_11
            ExitLoop
        Case $listview
            ; sort the list by the column header clicked on
            _GUICtrlListViewSort($listview, $B_DESCENDING, GUICtrlGetState($listview))
        Case $Btn_Print
            PrintPage()
        Case $Button_10
            $Name = GUICtrlRead($Name)
            $Input_4 = GUICtrlRead($Input_4)
            $Input_5 = GUICtrlRead($Input_5)
            $Input_6 = GUICtrlRead($Input_6)
            If StringLen($Name) And StringLen($Input_4) And StringLen($Input_5) And StringLen($Input_6) Then
                GUICtrlCreateListViewItem($Name & "|" & $Input_4 & ":" & $Input_5 & ":" & $Input_6, $listview)
                GUISetState(@SW_SHOW, $GUI1)
            EndIf
    EndSwitch
WEnd

Exit

Func PrintPage()
    Local $f = FileOpen("individual.txt", 1)
    For $i = 0 To 8
        FileWriteLine($f, _GUICtrlListViewGetItemText($listview, $i) & "|" & _GUICtrlListViewGetItemText($listview2, $i) & @CRLF)
    Next
    FileClose($f)
    Local $file2 = FileOpen("individual.txt", 0)

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

    While 1
        Local $line = FileReadLine($file2)
        If @error = -1 Then ExitLoop
        Local $text = StringReplace($line, "|", @TAB)
        FileWriteLine("output.xls", $text & @CRLF)
    WEnd

    FileClose($file2)
    MsgBox(0, "", "Done")
    _FilePrint(@ScriptDir & "\output.xls")
EndFunc   ;==>PrintPage

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

thanks for the reply gafrost.

but the GUI input box needs to be displayed for 8 times, after hitting the OK button and afterwhich, finally display the ListBoxView with all the 8 entries.

pls help me again. quite desperate.

THANKS.

mouse not found....scroll any mouse to continue.

Link to comment
Share on other sites

thanks for the reply gafrost.

but the GUI input box needs to be displayed for 8 times, after hitting the OK button and afterwhich, finally display the ListBoxView with all the 8 entries.

pls help me again. quite desperate.

THANKS.

Just add a while loop in there, only increment the counter when the condition to add to the listview is true, when you get 8 entries the loop ends.

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

Hi,

tried this....doesn't work tho

include <GuiConstants.au3>
#include <GuiListView.au3>
#include <file.au3>
Opt('MustDeclareVars', 1)
Opt('WinTitleMatchMode', 0)
Dim $listview, $Btn_Exit, $msg, $Status, $Btn_Insert, $ret, $Input_Index, $listview2, $Name, $Timing, $i, $Btn_Print, $Label_1, $Label_3, $Label_7, $Label_8, $Label_9, $Input_4, $Input_5, $Input_6, $Button_10, $Button_11
Local $GUI1 = GUICreate("Team Score System 1.0", 392, 322)

$listview = GUICtrlCreateListView("Names|Timings", 0, 30, 200, 149)
$listview2 = GUICtrlCreateListView("Position|Points", (200), 30, 170, 149)
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT)
GUICtrlSendMsg($listview2, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
GUICtrlSendMsg($listview2, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT)

$i = 0
Local $str = ""
Do
    Local $GUI2 = GUICreate("Individual Score System 1.0", 400, 144, (@DesktopWidth - 400) / 2, (@DesktopHeight - 144) / 2)
    $Label_1 = GUICtrlCreateLabel("Name :", 20, 20, 40, 20)
    $Name = GUICtrlCreateInput("", 70, 15, 310, 20)
    $Label_3 = GUICtrlCreateLabel("Timing :", 20, 55, 40, 20)
    $Input_4 = GUICtrlCreateInput("", 70, 50, 20, 20, $ES_NUMBER)
    $Input_5 = GUICtrlCreateInput("", 130, 50, 20, 20, $ES_NUMBER)
    $Input_6 = GUICtrlCreateInput("", 190, 50, 20, 20, $ES_NUMBER)
    GUICtrlSetLimit($Input_4, 2, 2)
    GUICtrlSetLimit($Input_5, 2, 2)
    GUICtrlSetLimit($Input_6, 2, 2)
    $Label_7 = GUICtrlCreateLabel("mn", 100, 55, 20, 20)
    $Label_8 = GUICtrlCreateLabel("ss", 160, 55, 20, 20)
    $Label_9 = GUICtrlCreateLabel("ms", 220, 55, 20, 20)
    $Button_10 = GUICtrlCreateButton("OK", 70, 90, 100, 30)
    $Button_11 = GUICtrlCreateButton("Cancel", 230, 90, 100, 30)

    If @error = 1 Then Exit
    $i = $i + 1
Until $i = 8

GUICtrlCreateListViewItem("1|18", $listview2)
GUICtrlCreateListViewItem("2|14", $listview2)
GUICtrlCreateListViewItem("3|12", $listview2)
GUICtrlCreateListViewItem("4|10", $listview2)
GUICtrlCreateListViewItem("5|8", $listview2)
GUICtrlCreateListViewItem("6|6", $listview2)
GUICtrlCreateListViewItem("7|4", $listview2)
GUICtrlCreateListViewItem("8|2", $listview2)

_GUICtrlListViewSetColumnWidth($listview, 0, 75)
_GUICtrlListViewSetColumnWidth($listview, 1, 75)
_GUICtrlListViewSetColumnWidth($listview, 2, 75)

$Btn_Exit = GUICtrlCreateButton("Exit", 300, 260, 70, 30)
$Btn_Print = GUICtrlCreateButton("Export", 200, 260, 70, 30)

GUISetState()

Dim $B_DESCENDING[_GUICtrlListViewGetSubItemsCount($listview) ]

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE, $Button_11
            ExitLoop
        Case $listview
           ; sort the list by the column header clicked on
            _GUICtrlListViewSort($listview, $B_DESCENDING, GUICtrlGetState($listview))
        Case $Btn_Print
            PrintPage()
        Case $Button_10
            $i = 0
            While $i <= 8
            $Name = GUICtrlRead($Name)
            $Input_4 = GUICtrlRead($Input_4)
            $Input_5 = GUICtrlRead($Input_5)
            $Input_6 = GUICtrlRead($Input_6)
            If StringLen($Name) And StringLen($Input_4) And StringLen($Input_5) And StringLen($Input_6) Then
                GUICtrlCreateListViewItem($Name & "|" & $Input_4 & ":" & $Input_5 & ":" & $Input_6, $listview)
                $i = $i + 1
            EndIf
            GUISetState(@SW_SHOW, $GUI2)
            WEnd
    EndSwitch

WEnd
GUISetState(@SW_SHOW, $GUI1)
Exit

Func PrintPage()
    Local $f = FileOpen("individual.txt", 1)
    For $i = 0 To 8
        FileWriteLine($f, _GUICtrlListViewGetItemText($listview, $i) & "|" & _GUICtrlListViewGetItemText($listview2, $i) & @CRLF)
    Next
    FileClose($f)
    Local $file2 = FileOpen("individual.txt", 0)

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

    While 1
        Local $line = FileReadLine($file2)
        If @error = -1 Then ExitLoop
        Local $text = StringReplace($line, "|", @TAB)
        FileWriteLine("output.xls", $text & @CRLF)
    WEnd

    FileClose($file2)
    MsgBox(0, "", "Done")
    _FilePrint(@ScriptDir & "\output.xls")
EndFunc  ;==>PrintPage

pls help me.

mouse not found....scroll any mouse to continue.

Link to comment
Share on other sites

#include <GuiConstants.au3>
#include <GuiListView.au3>
#include <file.au3>
Opt('MustDeclareVars', 1)
Opt('WinTitleMatchMode', 0)
Dim $listview, $Btn_Exit, $msg, $Status, $Btn_Insert, $ret, $Input_Index, $listview2, $Name, $Timing, $i, $Btn_Print, $Label_1, $Label_3, $Label_7, $Label_8, $Label_9, $Input_4, $Input_5, $Input_6, $Button_10, $Button_11

Local $GUI1 = GUICreate("Team Score System 1.0", 392, 322)

$listview = GUICtrlCreateListView("Names|Timings", 0, 30, 200, 149)
$listview2 = GUICtrlCreateListView("Position|Points", (200), 30, 170, 149)
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT)
GUICtrlSendMsg($listview2, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
GUICtrlSendMsg($listview2, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT)

$i = 0
Local $str = ""

GUICtrlCreateListViewItem("1|18", $listview2)
GUICtrlCreateListViewItem("2|14", $listview2)
GUICtrlCreateListViewItem("3|12", $listview2)
GUICtrlCreateListViewItem("4|10", $listview2)
GUICtrlCreateListViewItem("5|8", $listview2)
GUICtrlCreateListViewItem("6|6", $listview2)
GUICtrlCreateListViewItem("7|4", $listview2)
GUICtrlCreateListViewItem("8|2", $listview2)

_GUICtrlListViewSetColumnWidth($listview, 0, 75)
_GUICtrlListViewSetColumnWidth($listview, 1, 75)
_GUICtrlListViewSetColumnWidth($listview, 2, 75)

$Btn_Exit = GUICtrlCreateButton("Exit", 300, 260, 70, 30)
$Btn_Print = GUICtrlCreateButton("Export", 200, 260, 70, 30)

;~ GUISetState()

Local $GUI2 = GUICreate("Individual Score System 1.0", 400, 550)
$Button_10 = GUICtrlCreateButton("OK", 70, 510, 100, 30)
$Button_11 = GUICtrlCreateButton("Cancel", 230, 510, 100, 30)
Local $y = 15
Local $Input_4[9], $Input_5[9], $Input_6[9], $Name[9]
For $i = 1 To 8
    GUICtrlCreateGroup("", 10, $y - 10, 380, 69)
    GUICtrlCreateLabel("Name :", 20, $y + 5, 40, 20)
    $Name[$i] = GUICtrlCreateInput("", 70, $y, 310, 20)
    $y += 35
    GUICtrlCreateLabel("Timing :", 20, $y + 2, 40, 20)
    GUICtrlCreateLabel("mn", 100, $y + 2, 20, 20)
    $Input_4[$i] = GUICtrlCreateInput("", 70, $y, 20, 20, $ES_NUMBER)
    GUICtrlCreateLabel("ss", 160, $y + 2, 20, 20)
    $Input_5[$i] = GUICtrlCreateInput("", 130, $y, 20, 20, $ES_NUMBER)
    GUICtrlCreateLabel("ms", 220, $y + 2, 20, 20)
    $Input_6[$i] = GUICtrlCreateInput("", 190, $y, 20, 20, $ES_NUMBER)
    GUICtrlSetLimit($Input_4[$i], 2, 2)
    GUICtrlSetLimit($Input_5[$i], 2, 2)
    GUICtrlSetLimit($Input_6[$i], 2, 2)
    GUICtrlCreateGroup("", -99, -99, 1, 1)  ;close group
    $y += 25
Next
GUISetState()

Dim $B_DESCENDING[_GUICtrlListViewGetSubItemsCount($listview) ]

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE, $Button_11, $Btn_Exit
            ExitLoop
        Case $listview
            ; sort the list by the column header clicked on
            _GUICtrlListViewSort($listview, $B_DESCENDING, GUICtrlGetState($listview))
        Case $Btn_Print
            PrintPage()
        Case $Button_10
            Local $all_filled_in = True
            Local $tName, $Input4, $Input5, $Input6
            For $x = 1 To 8
                $tName = GUICtrlRead($Name[$x])
                $Input4 = GUICtrlRead($Input_4[$x])
                $Input5 = GUICtrlRead($Input_5[$x])
                $Input6 = GUICtrlRead($Input_6[$x])
                If StringLen($tName) = 0 Or StringLen($Input4) = 0 Or StringLen($Input5) = 0 Or StringLen($Input6) = 0 Then
                    $all_filled_in = False
                    ExitLoop
                EndIf
            Next
            If $all_filled_in Then
                For $x = 1 To 8
                    $tName = GUICtrlRead($Name[$x])
                    $Input4 = GUICtrlRead($Input_4[$x])
                    $Input5 = GUICtrlRead($Input_5[$x])
                    $Input6 = GUICtrlRead($Input_6[$x])
                    GUICtrlCreateListViewItem($tName & "|" & $Input4 & ":" & $Input5 & ":" & $Input6, $listview)
                Next
                GUISetState(@SW_HIDE, $GUI2)
                GUISetState(@SW_SHOW, $GUI1)
            EndIf
    EndSwitch
WEnd

Exit

Func PrintPage()
    Local $f = FileOpen("individual.txt", 1)
    For $i = 0 To 8
        FileWriteLine($f, _GUICtrlListViewGetItemText($listview, $i) & "|" & _GUICtrlListViewGetItemText($listview2, $i) & @CRLF)
    Next
    FileClose($f)
    Local $file2 = FileOpen("individual.txt", 0)

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

    While 1
        Local $line = FileReadLine($file2)
        If @error = -1 Then ExitLoop
        Local $text = StringReplace($line, "|", @TAB)
        FileWriteLine("output.xls", $text & @CRLF)
    WEnd

    FileClose($file2)
    MsgBox(0, "", "Done")
    _FilePrint(@ScriptDir & "\output.xls")
EndFunc   ;==>PrintPage

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

sorry to trouble again...but i got 2 more questions:

1) The program reads the name list from a text file called names.txt. Why is my list being read from bottom to top? I wish to have is from top to bottom. Not sure which operator to change.

2) When I click the next button, I wish to have the GUI reread the text file for the next 8 lines, at the same time capturing the data which was entered for the previous GUI.

#include <GuiConstants.au3>
#include <GuiListView.au3>
#include <file.au3>

Opt('MustDeclareVars', 1)
Opt('WinTitleMatchMode', 0)
Dim $listview, $Btn_Exit, $msg, $Status, $Btn_Insert, $ret, $Input_Index, $listview2, $Name, $Timing, $i, $Btn_Print, $Label_1, $Label_3, $Label_7, $Label_8, $Label_9, $Input_4, $Input_5, $Input_6, $Button_10, $Button_11, $file, $readlines, $num, $line, $Button_12

Local $GUI1 = GUICreate("Team Score System 1.0", 392, 322)

$listview = GUICtrlCreateListView("Names|Timings", 0, 30, 200, 149)
$listview2 = GUICtrlCreateListView("Position|Points", (200), 30, 170, 149)
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT)
GUICtrlSendMsg($listview2, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
GUICtrlSendMsg($listview2, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT)

$i = 0
Local $str = ""

GUICtrlCreateListViewItem("1|18", $listview2)
GUICtrlCreateListViewItem("2|14", $listview2)
GUICtrlCreateListViewItem("3|12", $listview2)
GUICtrlCreateListViewItem("4|10", $listview2)
GUICtrlCreateListViewItem("5|8", $listview2)
GUICtrlCreateListViewItem("6|6", $listview2)
GUICtrlCreateListViewItem("7|4", $listview2)
GUICtrlCreateListViewItem("8|2", $listview2)

_GUICtrlListViewSetColumnWidth($listview, 0, 75)
_GUICtrlListViewSetColumnWidth($listview, 1, 75)
_GUICtrlListViewSetColumnWidth($listview, 2, 75)

$Btn_Exit = GUICtrlCreateButton("Exit", 300, 260, 70, 30)
$Btn_Print = GUICtrlCreateButton("Export", 200, 260, 70, 30)

Local $GUI2 = GUICreate("Individual Score System 1.0", 400, 550)
$Button_10 = GUICtrlCreateButton("OK", 70, 510, 50, 30)
$Button_11 = GUICtrlCreateButton("Cancel", 230, 510, 50, 30)
$Button_12 = GUICtrlCreateButton("Next", 150, 510, 50, 30)
Local $y = 15
Local $Input_4[9], $Input_5[9], $Input_6[9], $Name[9]

$file = ("names.txt")
$readlines = -1

For $i = 1 To 8
    GUICtrlCreateGroup("", 10, $y - 10, 380, 69)
    GUICtrlCreateLabel("Name :", 20, $y + 5, 40, 20)
    $Name[$i] = GUICtrlCreateLabel("", 70, $y + 5, 310, 20)
    $y += 35
    $num = _FileCountLines($file)
    $readlines += 1
    If $num - $readlines < 1 Then $readlines = 0
    $line = FileReadLine($file, $num - $readlines)
    GUICtrlSetData($Name[$i], $line, "")
    GUICtrlCreateLabel("Timing :", 20, $y + 2, 40, 20)
    GUICtrlCreateLabel("mn", 100, $y + 2, 20, 20)
    $Input_4[$i] = GUICtrlCreateInput("", 70, $y, 20, 20, $ES_NUMBER)
    GUICtrlCreateLabel("ss", 160, $y + 2, 20, 20)
    $Input_5[$i] = GUICtrlCreateInput("", 130, $y, 20, 20, $ES_NUMBER)
    GUICtrlCreateLabel("ms", 220, $y + 2, 20, 20)
    $Input_6[$i] = GUICtrlCreateInput("", 190, $y, 20, 20, $ES_NUMBER)
    GUICtrlSetLimit($Input_4[$i], 2, 2)
    GUICtrlSetLimit($Input_5[$i], 2, 2)
    GUICtrlSetLimit($Input_6[$i], 2, 2)
    GUICtrlCreateGroup("", -99, -99, 1, 1) ;close group
    $y += 25
Next
GUISetState()

Dim $B_DESCENDING[_GUICtrlListViewGetSubItemsCount($listview) ]

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE, $Button_11, $Btn_Exit
            ExitLoop
        Case $listview
           ; sort the list by the column header clicked on
            _GUICtrlListViewSort($listview, $B_DESCENDING, GUICtrlGetState($listview))
        Case $Btn_Print
            PrintPage()
        Case $Button_10
            Local $all_filled_in = True
            Local $tName, $Input4, $Input5, $Input6
            For $x = 1 To 8
                $tName = GUICtrlRead($Name[$x])
                $Input4 = GUICtrlRead($Input_4[$x])
                $Input5 = GUICtrlRead($Input_5[$x])
                $Input6 = GUICtrlRead($Input_6[$x])
               ;If StringLen($tName) = 0 Or StringLen($Input4) = 0 Or StringLen($Input5) = 0 Or StringLen($Input6) = 0 Then
               ;    $all_filled_in = False
               ;    ExitLoop
               ;EndIf
            Next
            If $all_filled_in Then
                For $x = 1 To 8
                    $tName = GUICtrlRead($Name[$x])
                    $Input4 = GUICtrlRead($Input_4[$x])
                    $Input5 = GUICtrlRead($Input_5[$x])
                    $Input6 = GUICtrlRead($Input_6[$x])
                    If StringLen($tName) = 0 Or StringLen($Input4) = 0 Or StringLen($Input5) = 0 Or StringLen($Input6) = 0 Then
                        GUICtrlCreateListViewItem($tName & "|" & $Input4 & $Input5 & $Input6, $listview)
                    Else
                        GUICtrlCreateListViewItem($tName & "|" & $Input4 & ":" & $Input5 & ":" & $Input6, $listview)
                    EndIf
                Next
            GUISetState(@SW_HIDE, $GUI2)
            GUISetState(@SW_SHOW, $GUI1)
            EndIf
        Case $Button_12
        ;
    EndSwitch
WEnd

Exit

Func PrintPage()
    Local $f = FileOpen("individual.txt", 1)
    For $i = 0 To 8
        FileWriteLine($f, _GUICtrlListViewGetItemText($listview, $i) & "|" & _GUICtrlListViewGetItemText($listview2, $i) & @CRLF)
    Next
    FileClose($f)
    Local $file2 = FileOpen("individual.txt", 0)

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

    While 1
        Local $line = FileReadLine($file2)
        If @error = -1 Then ExitLoop
        Local $text = StringReplace($line, "|", @TAB)
        FileWriteLine("output.xls", $text & @CRLF)
    WEnd

    FileClose($file2)
    MsgBox(0, "", "Done")
    _FilePrint(@ScriptDir & "\output.xls")
EndFunc  ;==>PrintPage

THANK YOU. Pls help me ONCE AGAIN.

Edited by iceberg

mouse not found....scroll any mouse to continue.

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