* @param value value to set to variable
* @return value setted
* @throws PageException
*/
public static Object setVariable(PageContext pc,String var, Object value) throws PageException {
StringList list = parse(pc,new ParserString(var),false);
if(list==null) throw new InterpreterException("invalid variable name declaration ["+var+"]");
if(list.size()==1) {
return pc.undefinedScope().set(list.next(),value);
}
// min 2 elements
int scope=scopeString2Int(list.next());
Object coll;
if(scope==Scope.SCOPE_UNDEFINED){
coll=pc.touch(pc.undefinedScope(),list.current());
}
else {
coll=VariableInterpreter.scope(pc, scope, true);
//coll=pc.scope(scope);
}
while(list.hasNextNext()) {
coll=pc.touch(coll,list.next());
}
return pc.set(coll,list.next(),value);
}