One Star

instruction while in Talend

hi guys,
i'm a newby and i'm a problem with the instruction while in tMap in Talend (java)
i've setted the variables:
a ------>new Integer(row1.x)*1000
b ------>new Integer(row1.y)*1000
c ------>new Date(new Long(Var.a)).getDay()
d -----> 0
then i've setted the column:
while (Var.a<Var.b)
{
Var.a=Var.a+86400000;
if (new Boolean(Var.c<6 && Var.c>0)) Var.d=Var.d+28800000;
}
where is the problem(s)?
8 REPLIES
One Star

Re: instruction while in Talend

i don't manage the instrution while, if, for, etc. there is a documentation where i can find the explanation of their use?... in java not in perl, thanks in advance.
Community Manager

Re: instruction while in Talend

Hi
In tMap, you can use the column expression like this: Var.a<Var.b?myValue1:myValue2
Best regards
shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: instruction while in Talend

Hi
In tMap, you can use the column expression like this: Var.a<Var.b?myValue1:myValue2
Best regards
shong

ok, in fact is the only expression that is right but if i want use it in a "while" or "for" expression for example:
while (Var.a<Var.b)
{
Var.a=Var.a+86400000;
if (Var.c!=0) Var.d=Var.d+28800000;
}
i must use "if" because the expression with ? it give error (misplaced construct) and also with "if" it give the same error... where i'm wrong?
p.s.: all Var are int
One Star

Re: instruction while in Talend

so, none has ever used the "while" or "for" expression (java) in Talend? what is the correct syntax?
Employee

Re: instruction while in Talend

Use a routine and code your while into, then call this routine from tMap.
One Star

Re: instruction while in Talend

Use a routine and code your while into, then call this routine from tMap.

a routine?
please where can i find information about how to use a routine?
Employee

Re: instruction while in Talend

You can download the documentation, and find near page 12, in topic Repository > Codes > Routines a short description of this functionality.
You will be able to create new (static) methods in a class and call it from tMap. Take example on System routines if you wish to use in tRowGenerator or other components which need to read parameters from routines.
I created a feature issue 3114 to document more precisely this subject.
You can also see this post http://talendforge.org/forum/viewtopic.php?id=2159.
One Star

Re: instruction while in Talend

Use a routine and code your while into, then call this routine from tMap.

thanks, it works