I am sorry that it can't work.
the varible instance of Class ProcessInstance hava no such functions as getVarible(). So this is not a good approach.
I am sure that ret was updated after the execution of my script. I print out the result in my script and it is 2.
Thank you anyway.