![]() |
|
Published 2003-04-04 Printer-friendly version
Last month Clarion Magazine asked you for your nastiest GPFs. Russ Eggen had just written an article post mortem debugging, and was ready to take on all challengers. The response to the challenge was, well, underwhelming. In fact only Gordon Smith entered, with an example that demonstrates Clarion's "virtual list box" capabilities.
Gordon's entry is fairly short (you can download both the source and the PRJ at the end of this article, but it certainly demonstrates a sneaky kind of GPF. I confess that I was unable to locate the problem using the debugger, although I might have had better luck had I been able to read assembly language.
Now Russ was supposed to have written up his findings already, but he's been hunkered down doing some real work (no, really - I believe him, of course I do) and hasn't been able to find the time. Rather than wait any longer, and as the winner is, well, fairly obvious, here's Gordon's entry:
PROGRAM
MAP
END
StripedListQ QUEUE,TYPE
S STRING(20)
END
StripedList CLASS,TYPE
Init PROCEDURE(WINDOW w, SIGNED feq, StripedListQ Q)
VLBproc PROCEDURE(LONG row, SHORT column),STRING,PRIVATE
Q &StripedListQ,PRIVATE
ochanges LONG,PRIVATE
END
window WINDOW('Caption'),AT(,,153,103),SYSTEM,GRAY
LIST,AT(33,12,80,80),USE(?List1),FORMAT('20L*')
END
Q QUEUE(StripedListQ)
END
SL StripedList
i SIGNED
CODE
LOOP i = 1 TO 20
Q.s = 'Line ' & i
ADD(Q)
END
OPEN(window)
SL.Init(window, ?list1, Q)
ACCEPT
END
StripedList.Init PROCEDURE(WINDOW w, SIGNED feq, StripedListQ Q)
CODE
SELF.Q &= Q
SELF.ochanges = CHANGES(Q)
w $ feq{PROP:VLBval} = ADDRESS(SELF)
w $ feq{PROP:VLBproc} = ADDRESS(SELF.VLBproc)
StripedList.VLBproc PROCEDURE(LONG row, SHORT col)
nchanges LONG
CODE
CASE row
OF -1
RETURN RECORDS(SELF.Q)
OF -2
RETURN 5
OF -3
nchanges = CHANGES(SELF.Q)
IF nchanges <> SELF.ochanges THEN
SELF.ochanges = nchanges
RETURN 1
ELSE
RETURN 0
END
ELSE
GET(SELF.Q, row)
CASE col
OF 1
RETURN WHAT(SELF.Q,1)
OF 3
RETURN CHOOSE(BAND(row,1), COLOR:none, 0c00000H)
END
END
|
No prizes for sorting this one out (although I'll give bonus points to anyone describing how they used the debugger to find the bug), but feel free to post your discovery as a reader comment. In deference to those who may come to the article after you, please do not include the solution in the first sentence - it will show up in the comment summaries and be visible to anyone downloading the source.
Have fun!
David Harms is an independent software developer and the editor and publisher of Clarion Magazine. He is also co-author with Ross Santos of Developing Clarion for Windows Applications, published by SAMS (1995), and has written or co-written several Java books. David is a member of the American Society of Journalists and Authors (ASJA).
Copyright © 1999-2008 by CoveComm Inc. All Rights Reserved. Reproduction in any form without the express written consent of CoveComm Inc., except as described in the subscription agreement, is prohibited.
Clarion Magazine ISSN 1718-9942
One year: $184
(includes all back issues since '99)
Renewals from $134
Two years: $274
Renewals from $224