Jump to content
AndreasNWWWWW

Check if ini files contains checksum and if so do an action

Recommended Posts

AndreasNWWWWW
Posted (edited)

Hi, i'm curious if this is even possible, i want to do an action if the ini file contains current values under a section.

for my test i'm looking for 100,200,300,400,500

and if any of those excits i want to pop a msgbox with the number in the section.

i can in my example find one, but it does not check everyone. why? :( what am i missing?

Local $iscore810[5] = [100,200,300,400,500]
Local $iMax800 = 5

While 1
;~     Send("{pause}")
;;func les ini fil

    $var = IniReadSection("Area.ini", "modus")
    If @error Then
        MsgBox(4096, "Error", "Unable to read section.")
    Else
         For $number = 1 To $var[0][0]
If $var[$number][1] == $iscore810[3] Then
      MsgBox($MB_SYSTEMMODAL, "FAnt den på", $var[$number][0], 5)
EndIf

             

        Next
    EndIf
    exit
WEnd

 

Edited by AndreasNWWWWW
taggs

Share this post


Link to post
Share on other sites
AutoBert
1 hour ago, AndreasNWWWWW said:

what am i missing?

Correct data in inifile. Test changed script:

#include <MsgBoxConstants.au3>
#include <Array.au3>

Local $iscore810[5] = [100, 200, 300, 400, 500]
Local $iMax800 = 5

If Not FileExists("Area2.ini") Then IniWrite("Area2.ini","Modus","Test","400")

;While 1
    $var = IniReadSection("Area2.ini", "modus")
    If @error Then
        MsgBox(4096, "Error", "Unable to read section.")
    Else
        _ArrayDisplay($var)
        For $number = 1 To $var[0][0]
            If $var[$number][1] == $iscore810[3] Then
                MsgBox($MB_SYSTEMMODAL, "FAnt den på", $var[$number][0], 5)
            EndIf
        Next
    EndIf
    Exit
;WEnd

it's just for demonstration when inifile holds correct data the MsgBox appears.

Share this post


Link to post
Share on other sites
AndreasNWWWWW
;Thanks! helped me alot, but still abit lost.

;in my code i need to check if checksum excits, and if so i need it to rewrite that line in the ini file.

Local $arr[9] = [1218844893, 3651583250,681492513,185647069,2160709610,3972714752,3059395736,4086222246,2699877049]

;this works:
If $var[$number][1] == 1218844893 Then
IniWrite("arenatest.ini","posisjon",$var[$number][0],"500-Paid")
endif


;this does not:

If $var[$number][1] == $arr[9] Then
IniWrite("arenatest.ini","posisjon",$var[$number][0],"500-Paid")
endif

i could just do alot of manual typing those checksums, but harder to change, reason i want it in an array so i can just pull it off the excel file direcly. 

Share this post


Link to post
Share on other sites
AndreasNWWWWW

nvm this post above, when swapping the 9 number in array to 8, it worked :)

why does this number to be one lower?

Share this post


Link to post
Share on other sites
dmob

AFAIK == is used for string comparison. Try a single = 

Share this post


Link to post
Share on other sites
Subz

why does this number to be one lower?

Your array is 0 based, i.e. it counts as 0, 1, 2, 3, 4, 5, 6, 7, 8 not 1, 2, 3, ...9

Also what you could do is something like:

Local $iscore810[5] = [100,200,300,400,500]
Local $iMax800 = 5

For $i = 0 To UBound($iscore810) - 1
    If IniRead("Area.ini", "modus", $iscore810[$i], "") = "" Then ContinueLoop
    MsgBox(4096, "Number found", "Number# " & $iscore810[$i])
Next

 

Share this post


Link to post
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

  • Similar Content

    • WoodGrain
      By WoodGrain
      Hi guys,
      I'm learning about GUI's, I'm trying the below code, the idea being if I press the letter "e" while I have the GUI open I want the label color to change to green (I'm using a UDF for label colors). But every time I press "e" on my keyboard I just get a "ding" sound from my speakers and nothing changes with the label.
      I've looked at using something like "While GUIGetMsg() <> $GUI_EVENT_CLOSE" as I've seen it in other code instead of "While 1", but I don't think it's relevant.
      #include <GUIConstantsEx.au3>; for GUI... #include <GUIRichLabel.au3>; UDF for rich text label fonts #include <Misc.au3>; for _IsPressed $myLetter = "e" $hGUI = GUICreate("test", 700, 60) $lbl2 = _GUICtrlRichLabel_Create($hGUI, '<font color="purple">' & $myLetter & '</font>', 10, 10); , 260, 25 GUISetState(@SW_SHOW) Local $hDLL = DllOpen("user32.dll") While 1 if _IsPressed(Hex($myLetter), $hDLL) Then While _IsPressed(Hex($myLetter), $hDLL) Sleep(250) WEnd _GUICtrlRichLabel_SetData($lbl2, '<font color="green">' & $myLetter & '</font>') Sleep(2000) DllClose($hDLL) Exit EndIf Sleep(50) WEnd DllClose($hDLL) I am using an array of letters that I'm wanting to do this for, but as I can't get it to work I've stripped it down to the simplest code I can think of to try and get this working first. Appreciate any help.
      Thanks!
    • nacerbaaziz
      By nacerbaaziz
      hi dears
      am using an ini files as a History
      Sometimes the file size is be larger to 5 MB
      AutoIt does not recognize the full content of the file
      When I did a search to find out why, I discovered that INI files could not be read if they size larger than 64 KB.
      for that I preferred to ask here if is there any way to bypass this obstacle.
      The contents of the file are  as follows
      [filesList]
      c:\...\...\f1.mp3=00:15:20
      c:\...\...\f2.mp3=00:10:20
      c:\...\...\f3.wav=00:59:20
      ....... Etc
      This is the section for reading the file (adapted from my main script)

      case $continue     Local $aArray = IniReadSection($WaitingListFile, StringEncrypt(true, "filesList", $MyPassword))     If Not @error Then Opt("GUICloseOnESC", 1) _GUICtrlListView_DeleteAllItems($scList)         For $i = 1 To $aArray[0][0] $path = path_list(StringEncrypt(false, $aArray[$i][0], $MyPassWord), 1) if FileExists(StringEncrypt(false, $aArray[$i][0], $MyPassWord)) then GUICtrlCreateListViewItem(_GetFileName(FileGetLongName(StringEncrypt(false, $aArray[$i][0], $MyPassWord))) & Opt("GUIDataSeparatorChar") & " : " & Opt("GUIDataSeparatorChar") & FileGetLongName(StringEncrypt(false, $aArray[$i][0], $MyPassWord)), $scList) else $path = $path endIf         Next GUISetState(@sw_disable, $hGUI) GUISetState(@sw_show, $hGUI2) GUICtrlSetState($SClist, $GUI_FOCUS) else if $accessibilitymode = 1 then speak(str("listEmpty")) endIf endIf
      Is there any way to solve this problem, please?
      am waiting your answers...
      Greetings to All
    • AndreasNWWWWW
      By AndreasNWWWWW
      Hi, i'm just curious is there a way to sort an ini file after largest first?
      my inifiles writes itself like this
      14=500
      13=GREY
      12=500
      11=600
      10=600
      9=600
      8=700
      7=700
      5=600
      3=600
      2=800
      1=700
      15=GREY
      4=GREY
       
      but is there a way so i can get it sortet 
      15
      14
      13
      12 
      etc?
    • Aleksandar
      By Aleksandar
      So can anyone help me ? I need to restart program when condition is not met ...

    • Pike
      By Pike
      Hello Everyone,
      New Guy here. This is a two-part question, hopefully easy enough though. I know it's ugly coding, this is because I have only a couple hours worth of coding experience and could really use some help.
      1) When I single click the button I want one action (like playing a sound clip) and when I double click the button I want a different action (such as opening dialogue box to ask for soundclip directory address). At the bottom of the script I made a comment which one I would like single click versus double click.
      2) I can not get the FileOpenDialogue to save the file address to the config.ini file at the 'One' position on the .ini.
      #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <MsgBoxConstants.au3> #include <FileConstants.au3> #include <AutoItConstants.au3> #include <Sound.au3> Opt('MustDeclareVars', 1) Opt("GUIOnEventMode", 1) Global $OneID _Main() Func _Main() GUICreate("Form1", 156, 86, 281, 276) $OneID = GUICtrlCreateButton("Button", 15, 17, 122, 37) GUICtrlSetOnEvent($OneID, "OnOne") GUISetOnEvent($GUI_EVENT_CLOSE, "OnExit") GUISetState() While 1 While 1 Sleep(1000) WEnd WEnd EndFunc ;---------------Functions------------- While 1 Sleep(100) WEnd Func OnOne() ; ******************Single Click for this action**************** $OneID = IniRead("config.ini", "Config", "One", $OneID) If $OneID = True Then SoundPlay($OneID, @HotKeyPressed) Else ; *******Double Click for this action*****And Help Saving File Address to config.ini 'One'*********** $OneID = FileOpenDialog("Select file", @WorkingDir, "All (*.*)") IniWrite("config.ini", "Config", "One", $OneID) $OneID = InputBox("Enter Information", "Short Name for File?", "") IniWrite("config.ini", "Config", "NameOne", $OneID) EndIf EndFunc Any help would be greatly appreciated, and if you need anymore clarity as to what exactly I'm trying to do, please do not hesitate to ask. Thanks so much!
      Pike
×