Args Concept:
Args
class (Argument)
"The Args class is used to pass
arguments such as a name, a caller, and parameters between application
objects"
Args Types
Caller
|
Gets or
sets the instance of the object that created this instance of the Args
class.
|
name
|
Gets and
sets the name of the application object to call.
|
parm
|
Gets or
sets a string that specifies miscellaneous information for the called
object.
|
parmEnum
|
Gets or
sets the enumeration value of the enumeration type that is specified in the
parmEnumType method.
|
parmEnmType
|
Gets or
sets the ID value of any enumeration type.
|
ParmObject
|
Gets or
sets an instance of any object to pass to the called object.
|
record
|
Gets and
sets the record from the table on which the caller object is working.
|
Example to pass the args:
static void
Sa_Args(Args
_args)
{
_args = new Args();
_args.Parm(“ any string value”); // used to pass strings values.
_args.Record(Sa_productTable); // used to pass tables.
_args.ParmEnum ( NoYesEnumValue.selection()); // used to pass enumsType methods.
_args.ParmEnumType( EnumNum( NoYes ) ); // Used to pass enum values.
_args.Name(FormStr(Sa_ArgsForm)); // Used to pass application objects
}
Student student = new Student();
_args.ParmObject(student); // Used to pass the
instance of any objects.
Passing Args From one Form To Another Form:
1. First create two table.
Table1:
Table2:
2. Now create 2 forms
Form1:
Take form1 datasource as
table1
Form2:
Take form2 datasource as
table2
3. In form1 clicked method
write the following code.
void clicked()
{
Args args;
FormRun formRun;
super();
args = new
Args();
args.record(Sa_Products);
args.parm (Sa_Products.Product_Id);
args.name(formstr(sv_childForm));
formRun = ClassFactory.formRunClass(args);
formRun.init();
formRun.run();
formRun.wait();
}
4. In form2 override
init method and write the following code.
public void init()
{
Query query;
QueryBuildRange qbr;
Sa_Products sa_Products;
str parmid;
;
super();
sa_Products = element.args().record();
parmid = element.args().parm();
query = new
Query();
qbr = query.addDataSource(tablenum(Sa_ProductDetails)).addRange(fieldnum(Sa_ProductDetails,Product_Id));
qbr.value(parmid);
Sa_ProductDetails_ds.query(query);
}
5.Output
Send Args From
Form To Class:
1.
Create one table.
Table:
2. Create a form drag the datasource as Sa_product
table.
Form:
In Clicked method write below code
Void
clicked ()
{
Args args;
MenuFunction menuFunction;
super();
args = new
Args();
args.record(Sa_Products);
args.parm(Sa_Products.Product_Id);
menuFunction = new MenuFunction(identifierStr(Sa_ArgsClass), MenuItemType::Action);
menuFunction.run(args);
super();
}
3. Create a classes for getting the args
value.
In main method write following code to get the values from
form
4. Output:
Very good blog.... I am beginner and this information was much needed.
ReplyDeleteThanks a lot.
This comment has been removed by the author.
ReplyDeleteVery Useful content ...Thankyou.
ReplyDeleteThis comment has been removed by the author.
ReplyDelete