Jump to content

Addition value ini file


Recommended Posts

Hello autoit lovers. I am trying to find the total value of certain data within an ini file. Thanks in advance to anyone who can help. Bye.

CardID.ini

[   0010171165  ]   
    Value1  =George Russell
    Value2  =17
    Value3  =120
    Value4  =25
            
[   0010171588  ]   
    Value1  =Sergio Perez
    Value2  =25
    Value3  =100
    Value4  =25
            
[   0010171166  ]   
    Value1  =Max Verstappen
    Value2  =17
    Value3  =85
    Value4  =25
            
[   0010171524  ]   
    Value1  =Daniel Ricciardo
    Value2  =17
    Value3  =300
    Value4  =0
            
[   0010171533  ]   
    Value1  =Lando Norris
    Value2  =17
    Value3  =102
    Value4  =25
            
[   0010171534  ]   
    Value1  =Lance Stroll
    Value2  =17
    Value3  =340
    Value4  =25
            
[   0010184458  ]   
    Value1  =Sebastian Vettel
    Value2  =25
    Value3  =80
    Value4  =25

GUİ Trial

#include <GUIConstants.au3>

GUICreate("", 350, 700, -1, -1)
GUISetBkColor(0x00E0FFFF)

$ltview = GUICtrlCreateListView("CARD-ID'S|NAME AND SURNAME|REMAIN", 10, 10, 330, 600) ;,$LVS_SORTDESCENDING)
$VButt = GUICtrlCreateButton("VALUE", 20, 630, 80, 20)
$TButt = GUICtrlCreateButton("TOTAL", 120, 630, 80, 20)
$input = GUICtrlCreateInput("", 220, 630, 80, 20)

GUICtrlSetState(-1, $GUI_DROPACCEPTED)
GUISetState()

$nArray = IniReadSectionNames('CardID.ini')
If Not @error Then
    Dim $item[UBound($nArray) + 1]
    For $i = 1 To UBound($nArray) - 1
        $kArray = IniReadSection('CardID.ini', $nArray[$i])
        If Not @error Then
            $V1 = ''
            $V3 = ''
            For $k = 1 To UBound($kArray, 1) - 1
                If StringLower($kArray[$k][0]) = 'Value1' Then $V1 = $kArray[$k][1]
                If StringLower($kArray[$k][0]) = 'Value3' Then $V3 = $kArray[$k][1]
        $Total = $V3 + $kArray[$k][0]
            Next
        EndIf
        $item[$i] = GUICtrlCreateListViewItem($nArray[$i] &'|'& $V1 &"|"& $V3, $ltview)
    Next
EndIf

Do
    $msg = GUIGetMsg()
    Select
        Case $msg = $VButt
            MsgBox(0, "DETAIL", GUICtrlRead(GUICtrlRead($ltview)), 2)
        Case $msg = $TButt
            GUICtrlRead($Total)
            GUICtrlSetData($input,$Total)
    EndSelect
Until $msg = $GUI_EVENT_CLOSE

:bye:

Link to comment
Share on other sites

Total results of all data for example:

#include <GUIConstants.au3>
Local $iTotal = 0, $vValue1, $vValue3

GUICreate("", 350, 700, -1, -1)
GUISetBkColor(0x00E0FFFF)
Local $idListView = GUICtrlCreateListView("CARD-ID'S|NAME AND SURNAME|REMAIN", 10, 10, 330, 600) ;,$LVS_SORTDESCENDING)
Local $idValue = GUICtrlCreateButton("VALUE", 20, 630, 80, 20)
Local $idTotal = GUICtrlCreateButton("TOTAL", 120, 630, 80, 20)
Local $idTotalInput = GUICtrlCreateInput("", 220, 630, 80, 20)

GUISetState()

Local $nArray = IniReadSectionNames('CardID.ini')
If Not @error Then
    For $i = 1 To $nArray[0]
        $vValue1 = IniRead("CardID.ini", $nArray[$i], "Value1", "")
        $vValue3 = IniRead("CardID.ini", $nArray[$i], "Value3", "")
        If Number($vValue3) > 0 Then $iTotal += $vValue3
        GUICtrlCreateListViewItem($nArray[$i] &'|'& $vValue1 &"|"& $vValue3, $idListView)
    Next
    GUICtrlSetData($idTotalInput, $iTotal)
EndIf

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $idValue
            MsgBox(0, "DETAIL", GUICtrlRead(GUICtrlRead($idListView)), 2)
        Case $idTotal
            GUICtrlSetData($idTotalInput,$iTotal)
    EndSwitch
WEnd

 

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