Hi,
I have a programme which displays a list of image files in a listbox. There is also a static LABEL control which shows a description of the selected image...
Or it should, at least. This is the function which is supposed to update the description:
Descriptions reside in a text file, the format of which is as follows:
Film1-Image17.jpg Freshwater West 11 June 2000
Film1-Image18.jpg Skokholm Island 11 June 2000
i.e. filename then description, then a date, with tabs as delimiters and one line per image. The file currently contains 37 entries.
The first time the SUB is called, it sets flag to true, and fills desclist$(). The array is static, so it only needs to be filled once.
Then, when the selected image in the listbox changes, I scan through the array to find the right description, and put that text into the LABEL.
(At present, the date included in the text file isn't actually used.)
The problem is that I get a GPF, and I'm not sure why. The error message box says:
This appears to be occuring on either the first or possibly the second pass through the WHILE... loop.
I'm probably missing something obvious, but it's one of the simplest pieces of code I've written, and I can't see any (more!) bugs. Suggestions would be greatly appreciated!
------------------
--Dan
I have a programme which displays a list of image files in a listbox. There is also a static LABEL control which shows a description of the selected image...
Or it should, at least. This is the function which is supposed to update the description:
Code:
SUB UpdateDesc 'retrieve description of file$ 'and put it into %DESCRIPTION LOCAL file$, text$ LOCAL count AS LONG, lp AS LONG, CDImDesc AS LONG STATIC flag AS LONG, desclist$() IF ISFALSE(flag) THEN flag = %TRUE Count = 1 CDImDesc = FREEFILE OPEN $CDImList FOR INPUT AS CDImDesc DIM desclist$(1 TO 3, 1 TO 1) LINE INPUT #CDImDesc, text$ desclist$(1, Count) = PARSE$(text$, $TAB, 1) 'filename desclist$(2, Count) = PARSE$(text$, $TAB, 2) 'description desclist$(3, Count) = PARSE$(text$, $TAB, 3) 'date WHILE NOT EOF(CDImDesc) INCR Count REDIM PRESERVE desclist$(1 TO 3, 1 TO Count) LINE INPUT #CDImDesc, text$ desclist$(1, Count) = PARSE$(text$, $TAB, 1) 'filename desclist$(2, Count) = PARSE$(text$, $TAB, 2) 'description desclist$(3, Count) = PARSE$(text$, $TAB, 3) 'date WEND CLOSE CDImDesc END IF LISTBOX GET TEXT hDlg, %CDList TO file$ text$ = $NoDesc IF LEN(file$) THEN FOR lp = 1 TO Count IF file$ = desclist$(1, lp) THEN text$ = desclist$(2, lp) EXIT FOR END IF NEXT END IF CONTROL SET TEXT hDlg, %DESCRIPTION, text$ END SUB
Film1-Image17.jpg Freshwater West 11 June 2000
Film1-Image18.jpg Skokholm Island 11 June 2000
i.e. filename then description, then a date, with tabs as delimiters and one line per image. The file currently contains 37 entries.
The first time the SUB is called, it sets flag to true, and fills desclist$(). The array is static, so it only needs to be filled once.
Then, when the selected image in the listbox changes, I scan through the array to find the right description, and put that text into the LABEL.
(At present, the date included in the text file isn't actually used.)
The problem is that I get a GPF, and I'm not sure why. The error message box says:
SELECTOR caused an invalid page fault in
module OLEAUT32.DLL at 0167:7fe81543...
module OLEAUT32.DLL at 0167:7fe81543...
I'm probably missing something obvious, but it's one of the simplest pieces of code I've written, and I can't see any (more!) bugs. Suggestions would be greatly appreciated!
------------------
--Dan
Comment