Function with Multiple Returns
I have this little script for getting objects on a given page:
function getFieldOn(name, p){//finds (the first) field on page p with 'name' in its name
var fields;
for(var i = 0; i < this.numFields; i++){
var f = this.getField(this.getNthFieldName(i));
if ((f.name.indexOf(name) > -1) && (f.page == p)) return f;
}
}I'd like to modify this so it can return a single object if that's all it finds, and return an array of objects if there are multiple objects sharing the same name or partial name. Can I have two types of return values like that? How can I modify this code?
