1. Funny mistake

Initially the code was:

----------------------------------------------------------------------------
---
constant
  iDestroyWindow = define_c_func(g_user32,"DestroyWindow",{C_POINTER},C_INT)

global function DestroyWindow(atom hwnd)
  return c_func(iDestroyWindow,{hwnd})
end function

...
atom r
r = DestroyWindow(hFrameWnd)
...
----------------------------------------------------------------------------
---

Then I realised that I never check the value returned by DestroyWindow, so
I changed the function to a procedure to spare me the trouble with trashing
the retrun value:

----------------------------------------------------------------------------
---
constant
  iDestroyWindow = define_c_proc(g_user32,"DestroyWindow",{C_POINTER})

global procedure DestroyWindow(atom hwnd)
  return c_proc(iDestroyWindow,{hwnd})
end procedure

...
DestroyWindow(hFrameWnd)
...
----------------------------------------------------------------------------
---

The code still run but evidently worked not. It was not destroying the window.
Silly mistake.

Ian

new topic     » topic index » view message » categorize

2. Re: Funny mistake

Ian Burleigh writes:
> global procedure DestroyWindow(atom hwnd)
>      return c_proc(iDestroyWindow,{hwnd})
> end procedure

> The code still run but evidently worked not.
> It was not destroying the window.

Your bug is very hard to see because of the way you indented
your code. Had you indented differently it would have been
clear what's going on:

global procedure DestroyWindow(atom hwnd)
     return
     c_proc(iDestroyWindow,{hwnd})
end procedure

 In a function there must be an expression after "return",
but in a procedure there is no expression, just "return".

Regards,
     Rob Craig
     Rapid Deployment Software
     http://members.aol.com/FilesEu/

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu