Archive: Possible bug


Possible bug
Using the following INI file (lines marked by >):

>; Title
>;
>; Header block.
>
>[Settings]
>NumFields=1
>
>; Description.
>
>[Field 1]
>Type=Checkbox
>Text=Use it
>Flags=NOTIFY
>State=1
>Left=10
>Right=100
>Top=20
>Bottom=30
>
>; Terminal text, for whatever purpose.
>
>

If the above INI file is used, examination of the working copy during processing shows that the HWND keyword shows up as so:

>Right=100
>Top=20
>Bottom=30
>
>; Terminal text, for whatever purpose.
>
>HWND=14681514

However, subsequent reads via:

ReadINIStr ${hWND} "${Temp}" "Field 1" "HWND"

will not find it, as far as I can tell. I used:

MessageBox MB_ICONEXCLAMATION|MB_OK \
"hWND = ${hWND}"

to try to see the results, but I got nothing.

Changing the end of the INI file to:

>Right=100
>Top=20
>Bottom=30
>
>[End]
>; Terminal text, for whatever purpose.
>
>

results in the HWND keyword showing in the correct location, but I'm still seeing nothing with my MessageBox.


However, subsequent reads via:

ReadINIStr ${hWND} "${Temp}" "Field 1" "HWND"

will not find it, as far as I can tell. I used:

MessageBox MB_ICONEXCLAMATION|MB_OK \
"hWND = ${hWND}"
this will never work.

this one will:

ReadINIStr $hWND "$PLUGINSDIR\yourini.ini" "Field 1" "HWND"
MessageBox MB_ICONEXCLAMATION|MB_OK \
"hWND = $hWND"


you mixed up runtime ($variable) with compile time (${define}).

also, you set the wrong path to your ini file. (you should always extract your installer related files, like installoption files, plugins, pictures and other stuff just needed in the installer, not in the installed application, to $PLUGINSDIR, not to $TEMP!!!)

!define hWND $0
!define TempA "$PLUGINSDIR\TempA.ini"

ReadINIStr ${hWND} "${TempA}" "Field 1" "HWND"
MessageBox MB_ICONEXCLAMATION|MB_OK \
"hWND = ${hWND}"

These are the original lines from the code in question. The two defines I removed while chopping down to the relevant lines. The TempA I reduced to Temp figuring that it would be clearer.

I found the actual reason the Read/Msg was failing while I was chopping the above out for you; I had TempB where I should have had TempA. I was reading from the wrong INI file.

The possible bug as described still exists; the HWND keyword is being misplaced if there are blank or comment lines following the last keyword in the last section of the INI file.

Interestingly, if there are blank and comment lines between sections, it gets it right; it steps back to the last line of the previous section and puts the HWND in the correct spot.


As far as I know WriteINIStr (and ReadINIStr) just call a Windows API to do the job. If this is the case (I'm pretty sure it is because the programmers would have wanted to cut down on as much overhead as possible) then you shouldn't have comments in between section key values. I for one have never seen an INI file like this. Comments have always appeared above section tags. Then again I could be wrong :)

What happens if you call the Windows API's (whatever they are!)?

-Stu