Author Topic: This property or method is not allowed on this object  (Read 5046 times)

JPN

  • Community Member
  • Posts: 9
  • Hero Points: 0
This property or method is not allowed on this object
« on: June 06, 2008, 03:35:43 pm »
I never got this error until the newest 12 version of slickedit

The error is this: "This property or method is not allowed on this object."

and I'm getting it for this particular function...

_str get_function_name()
{
    _str sFunctionName = current_proc(0);
   
    return sFunctionName;
}

How can I change this so it works again?

Thanks




Graeme

  • Senior Community Member
  • Posts: 2300
  • Hero Points: 302
Re: This property or method is not allowed on this object
« Reply #1 on: June 06, 2008, 08:16:56 pm »
Probably you are calling this function from some macro code that created or opened a window or from an event handler, resulting in the current buffer not being the active object.  Try using this

    int wid = p_window_id;
    _str x = _mdi.p_child.current_proc(0);
    p_window_id = wid;


Also try this, and run it from the command line.

_command void xyz() name_info(',')
{
   message(current_proc(0));
}

Graeme

JPN

  • Community Member
  • Posts: 9
  • Hero Points: 0
Re: This property or method is not allowed on this object
« Reply #2 on: June 09, 2008, 01:26:39 pm »
I tried doing the message(current_proc(0)); and it gave me the original error. I also tried this:

_str get_function_name()
{
_str sFunctionName = ""
_message_box(_mdi.p_child.current_proc(0));
    return sFunctionName;
}

and received this error:


---------------------------
Slick-C Error
---------------------------
Control -mdi referenced but does not exist

file=GetFunctionName.ex offset=41
---------------------------
OK   
---------------------------


Also I found a stack trace of when this error crashes the IDE:

Stack trace written to file: C:\DOCUME~1\JPN\LOCALS~1\Temp\vsstack
 This property or method is not allowed on this object
slickc.ex 13222 select_proc(0,4,,0)   p_window_id: 25   p_object: OI_TREE_VIEW   p_name: _proj_tooltab_tree
GetFunctionName.ex 36 get_function_name()   p_window_id: 25   p_object: OI_TREE_VIEW   p_name: _proj_tooltab_tree
compile.ex 11828 _parse_project_command(


It looks like it might be trying to do the current_proc command on the treeview, how would i tell it to give me current_proc from the code. This worked fine before the new version of slickedit.

---UPDATE----

I am using this function and it works with in the code window, but I need it to work even if I right click on a file in the treeview, right now it crashes IDE.

_str get_function_name()
{
    return current_proc(false);
}


« Last Edit: June 09, 2008, 02:26:25 pm by JPN »

JPN

  • Community Member
  • Posts: 9
  • Hero Points: 0
Re: This property or method is not allowed on this object
« Reply #3 on: June 09, 2008, 03:35:00 pm »
Hi..


I got it working now. I just had to make sure I was referencing the edit window when they right clicked to activate this macro through the treeview file window on left.   This line was really what fixed it: form_wid=_edit_window; then referencing the edit window as an object: myproc = form_wid.current_proc(false);
 


_str get_function_name()
{
  _str myproc = ""
 
  mdisetfocus();
  form_wid=_edit_window;
  if (p_mdi_child > 0 ){
  myproc = current_proc(false);
  }
else
  {
  myproc = form_wid.current_proc(false);
  }
  return myproc
}