locked
Passing Parameters with addobject RRS feed

  • Question

  • Hi

    I looked everywhere I could think of but cannot find what I'm doing wrong. Please help!

    To simplify, I have a form with a command button on it.

    form1.init:
    set classlib to form_edit


    command1.click
    thisform.addobject('oeditor','object_editor','',this.name)

    form_edit.vcx contains the class 'object_editor'
     

    object_editor.init
    lparameters oname


    When I click the button I get the error:
    Must specify additional parameters

    Looking with debug:
    oname=(blank)

    I've tried passing this.name as an array and as a location by reference (@)
    I've tried using the load event of the class.

    What am I doing wrong?

    Thanks in advance
    Wednesday, December 17, 2008 11:04 PM

Answers


  • try with following
    thisform.addobject('oeditor','object_editor',this.name)
    Thursday, December 18, 2008 5:52 AM
  • Hi,

    You are passing two parameters and you are accepting just one parameters in the class. Thats why you are getting error for additional parameters.

     

    Remove the first parameter from your addobject command i.e. ""

     

    thisform.addobject('oeditor','object_editor',this.name)

     

    here oeditor is the object name, object_edito is the class and then your parameters are followed which are two in you case.

     

     

    Thursday, December 18, 2008 7:19 AM
  •  

    >> thisform.addobject('oeditor','object_editor','',this.name)

    The syntax for this command includes an optional item that can be passed in position #2 instead of the class name - that is what is confusing you. You are passing BOTH the class and the OLEClass parameters, and the object is interpreting the extra ( '',)  item as a parameter. The result is that you are passing TWO parameters to the object, instead of one - and hence the message.

     

    You only pass EITHER the class name, OR the OLE classname, thus:

     

    Code Snippet

    ThisForm.AddObject( "oEditor", "Object_Editor", This.Name )

     

     

     

    Thursday, December 18, 2008 11:12 AM

All replies


  • try with following
    thisform.addobject('oeditor','object_editor',this.name)
    Thursday, December 18, 2008 5:52 AM
  • Hi,

    You are passing two parameters and you are accepting just one parameters in the class. Thats why you are getting error for additional parameters.

     

    Remove the first parameter from your addobject command i.e. ""

     

    thisform.addobject('oeditor','object_editor',this.name)

     

    here oeditor is the object name, object_edito is the class and then your parameters are followed which are two in you case.

     

     

    Thursday, December 18, 2008 7:19 AM
  •  

    >> thisform.addobject('oeditor','object_editor','',this.name)

    The syntax for this command includes an optional item that can be passed in position #2 instead of the class name - that is what is confusing you. You are passing BOTH the class and the OLEClass parameters, and the object is interpreting the extra ( '',)  item as a parameter. The result is that you are passing TWO parameters to the object, instead of one - and hence the message.

     

    You only pass EITHER the class name, OR the OLE classname, thus:

     

    Code Snippet

    ThisForm.AddObject( "oEditor", "Object_Editor", This.Name )

     

     

     

    Thursday, December 18, 2008 11:12 AM
  • Thanks

    I knew I was overlooking something obvious.
    Thursday, December 18, 2008 11:28 AM