I need to convert all values in a structure (arguments passed into a function) to uppercase.
I wrote the following method, but rather than replace the argument with the formatted one, it is creating a new key to the arguments struct (e.g. for first loop, it creates a key of ‘1’ with the value of arguments[1], next loop creates a new key of ‘2’ with the value of arguments[2] and so on.
Can anyone suggest how I can change the value of each key in the struct?
The code kind of shows what I am trying to do, but let me know if you need more info.
public function formatValues(){
numArgs = structCount(arguments);
for (i=1; i<=numArgs ; i=i+1){
arguments[i] = Ucase(arguments[i]);
}
return arguments;
}
Try this:
This will work with named arguments and non-named arguments. It also will only modify simple values (strings, numbers, etc) and not complex variables (arrays, structures, objects)