caller in args

来源:互联网 发布:电气行业设计软件 编辑:程序博客网 时间:2024/06/15 18:25
 
First let learn what is a args:
The Args class is used to pass arguments to a class-constructor. Args can pass information such as name, caller, and parameters to a new class.
Forms, reports and queries all use this class as their first argument in the constructor. The preferred way to use this class is to construct an Args object, supplying a name-string, and then pass this Args object to the forms constructor or a ClassFactory Class method.
If you need to refer to the Args object passed to one of these classes, it can be reached using that class' args() method.
There are four methods that can be used to pass extra information to the new class:
·   Args.parm Method - for passing strings
·   Args.parmEnum Method and Args.parmEnumType Method - for passing enums
·   Args.parmObject Method - for passing an object of any type.
For example:
{
    Args a = new Args("CustTable");
    formRun fr = ClassFactory.FormRunClass(a);
    fr.init();
    fr.run();
}
Caller:
public Object caller([Object value])
while your call a form or report via a menu item the system will pass it automatically,in the called form you can use method like this to access it:
     Object _object;
    _object = element.args().caller();
You can also use the caller manually.For example:
In a class,there is a methos:
Public void demo()
{
Args args;
FormRun formRun;
;
Args = new Args(FormStr(“myformname”));
Args.caller(this);
Formrun = classFactory.formClassRun(args);
Formrun.init();
Formrun.run();
Formrun.wait();
}
When this method is called ,the form:myformname ran.And in this running form:myformname we can access the class whick called this form like this:
void init()
{
         Object _object;
         ;
         Super();
         _object = element.args().caller();
         //then we can use methods in the class:
         _object.methodname();//when you press the’.’the method name will not automatically appear.
}
this is very usefull when you have a variable or any other things in a Form A,and you need the Form B modify this variable ,but after the Form B modified the variable you need use this variable in Form A.
for example in form A you have a class classa which hold those usefull variables,you use the classa call the form b,and pass classa as a caller,after the form b modified the classa the form b closed,then you can access those variables in the classa in form a.
原创粉丝点击