Sign in to follow this  
Followers 0
gcue

INI check before guicreate

3 posts in this topic

#1 ·  Posted (edited)

my gui builds out icons based on whats in an INI. if the INI is badly formatted, the app gets an error which isnt clear that the INI is the problem and the user isnt able to load the program.

heres an example of a good INI:

[LOCATIONS]
TEST_LOCATION=TEST_LOCATION_ASSETS

[TEST_LOCATION_ASSETS]
INITIALS=D0000000

each location is listed under locations section along with a pointer to its PCs (assets)

if theres a mismatch (misspelling or lack of) between location list and corresponding location_asset list then id like to inform the user

hope im making sense..........

heres what i have so far (not working obviously):

$LOCS=IniReadSectionNames($ini)
$loc_assts=IniReadSection($ini, "Locations")
For $LOC in $LOCS
If $loc_assts<>$LOC Then
$answer = MsgBox(16, "Dashboard", "Badly formatted assets.ini." & @CRLF & _
                                  "Application will now exit.")
Exit
EndIf
Next
Edited by gcue

Share this post


Link to post
Share on other sites



my gui builds out icons based on whats in an INI. if the INI is badly formatted, the app gets an error which isnt clear that the INI is the problem and the user isnt able to load the program.

heres an example of a good INI:

[LOCATIONS]
TEST_LOCATION=TEST_LOCATION_ASSETS

[TEST_LOCATION_ASSETS]
INITIALS=D0000000

each location is listed under locations section along with a pointer to its PCs (assets)

if theres a mismatch (misspelling or lack of) between location list and corresponding location_asset list then id like to inform the user

hope im making sense..........

heres what i have so far (not working obviously):

$LOCS=IniReadSectionNames($ini)
$loc_assts=IniReadSection($ini, "Locations")
For $LOC in $LOCS
If $loc_assts<>$LOC Then
$answer = MsgBox(16, "Dashboard", "Badly formatted assets.ini." & @CRLF & _
                                  "Application will now exit.")
Exit
EndIf
Next
You are treating $LOCS as an array, which is correct, but you are not treating $loc_assts as the 2D array that it is.

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

my gui builds out icons based on whats in an INI. if the INI is badly formatted, the app gets an error which isnt clear that the INI is the problem and the user isnt able to load the program.

heres an example of a good INI:

[LOCATIONS]
TEST_LOCATION=TEST_LOCATION_ASSETS

[TEST_LOCATION_ASSETS]
INITIALS=D0000000

each location is listed under locations section along with a pointer to its PCs (assets)

if theres a mismatch (misspelling or lack of) between location list and corresponding location_asset list then id like to inform the user

hope im making sense..........

heres what i have so far (not working obviously):

$ini = "settings.ini"
$LOCS = IniReadSection($ini,"LOCATIONS");read all the loactions
If @error Or Not IsArray($LOCS) Then
    MsgBox(262144, "ERROR 20", "No data in ini file!")
    Exit
EndIf

For $n = 1 To $LOCS[0][0];for each location
    $temp = IniReadSection($ini, $LOCS[$n][1]);is there a section for the location?
    If @error Then
        MsgBox(262144, "Error 21 in ini file", "Section '" & $LOCS[$n][1] & "' is corrupt or missing.")
        If MsgBox(262144 + 4, "Choose option", "Do you want to remove references to " & $LOCS[$n][1] & "?") = 6 Then
            IniDelete($ini, "LOCATIONS", $LOCS[$n][0])
        EndIf
        
    EndIf
Next
I think you need something like this.

$LOCS = IniReadSection("LOCATIONS");read all the loactions
If @error Or Not IsArray($LOCS) Then
    MsgBox(262144, "ERROR 20", "No data in ini file!")
    Exit
EndIf

For $n = 1 To $LOCS[0][0];for each location
    $temp = IniReadSection($ini, $LOCS[$n][1]);is there a section for the location?
    If @error Then
        MsgBox(262144, "Error 21 in ini file", "Section '" & $LOCS[$n][1] & "' is corrupt or missing.")
        If MsgBox(262144 + 4, "Choose option", "Do you want to remove references to " & $LOCS[$n][1] & "?") = 6 Then
            IniDelete($ini, "LOCATIONS", $LOCS[$n][0])
        EndIf
        
    EndIf
Next

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

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
Sign in to follow this  
Followers 0