Re: help

new topic     » goto parent     » topic index » view thread      » older message » newer message

----- Original Message ----- 
From: "George Walters" <gwalters at sc.rr.com>
To: "EUforum" <EUforum at topica.com>
Subject: help


> 
> 
> I'm moving my programs to the new win32 and having some success but I don't
> know where to look for this trap. My keypress's are working fine but when I
> click a button it blows up with this message... which is a long way away
> from my program. Here's the code:
> 
> ----------------------------------- Button
> Handler ----------------------------------
> procedure clickButton(integer self, integer eventId, sequence arg)
>  for i = 1 to len(btn) do
>   if self = btn[i] then
>    call_proc(buttonProcess[i],{})
>    exit
>   end if
>  end for
> end procedure
> -------------------------------- Setup process
> control ------------------------------
> 
>  setHandler(btn, w32HClick, routine_id("clickButton"))
> 

As you indicate in a subsequent email, buttonProcess contains a list of
procedure names. That is, each element in buttonProcess is a NAME of a routine in
your program. Thus the line ...

   call_proc(buttonProcess[i],{})

is running call_proc() giving the first parameter a routine name. However,
call_proc()'s first parameter must be a routine_id and not a routine name.

The easiest fix for you is to change this line to ...

   call_proc(routine_id(buttonProcess[i]),{})

but that is also the slowest executing fix. You might like to consider this
fix... Leave the call_proc() line as it is but change the initialization of
buttonProcess...

   rightButtonProcess = {routine_id("processChange"),
                         routine_id("processSave"),
                         routine_id("processAbort")}
etc ....

An even better fix (in terms of execution speed) is to do this...Change the
initialization as above and change the code in clickButton() to ...



 procedure clickButton(integer self, integer eventId, sequence arg)
  int pos
  pos = find(self, btn)
  if pos != 0 then
    call_proc(buttonProcess[pos],{})
  end if
 end procedure

Though I still prefer the original method I sent you.

-- 
Derek

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu