Advanced scripting

I been looking for a way to speed up my subroutines.

Right now I use set commands for each variable and I was told that you can write java code into the editior.

 

Anyone ever done this?

s_date = 20091231

{
String year="";
String month="";
String day="";
String date="";
year = s_date.substring(2,4);
month = s_date.substring(4,6 );
day = s_date.substring(6);

date = month+"/"+day+"/"+year;

}
 

it should return 12/31/2009 in varible date.

 

Thanks,

Mike

Advanced scripting

Yes, you can use the 'DO' object in the general folder. In your example you are better of using a 'set'.

Use your date object in the set and type this in the expression editor:

{
 String s_date = "20091231";

 int year = int.valueOf((s_date.substring(2,4)));
 int month = int.valueOf((s_date.substring(4,6 )));
 int day = int.valueOf((s_date.substring(6)));
 
 return new Date(year,month,day);
}

If you want to put it in a coulple of lines of code you could do this:

{

 String s_date = "20091231";

 return new Date(int.valueOf((s_date.substring(2,4))),int.valueOf((s_date.substring(4,6 ))),int.valueOf((s_date.substring(6))));

}

 

Note: You have to have all you code surrounded by { }

Cheers

Jason

Advanced scripting

Hi,

I have created a similar code in my script  , but it is giving error when using it in the application.

 

I am running UCCX 5.0(2) premium.

 

Regards,

Veer Pratap 

 

 

Recommended Reading: