
Am Freitag 17 April 2009 00:43:18 schrieb Tsunkiet Man:
Thank you for your response, however if I can't do that, why can the example of wxHaskell do that?
I refer to the following code inside http://darcs.haskell.org/wxhaskell/samples/wx/ (ImageViewer.hs)
Line 99 untill 110
openImage sw vbitmap mclose status fname = do -- load the new bitmap bm <- bitmapCreateFromFile fname -- can fail with exception closeImage vbitmap set vbitmap [value := Just bm] set mclose [enabled := True] set status [text := fname] -- reset the scrollbars bmsize <- get bm size set sw [virtualSize := bmsize] repaint sw `catch` \err -> repaint sw
if I'm correct the openImage is also defined in the where clause. Therefor by what I think it should not be possible, but it is.
Thanks for everything.
In your code, the variable dt was bound in the do-block, and you tried to reference it in the definition of onOpen in the where clause, where it is not in scope. The definition of openImage in ImageViewer.hs does not reference any variables bound in the do-block of imageViewer, only its parameters and the bitmap bm bound in its own body. As an alternative to defining onOpen in your main do-block, you could also pass the debug- text dt as a parameter.