I've seen in the past a way to create a function with an unlimited number of variables. Usage would be something like a form that calculates a score but in some forms, there are 10 questions while on others, there are 30. Does anyone know how to do that? the only other way I can think of would be like :
{fnCounter(document.doc1)}
{fnCounter(document.doc2)}
{fnCounter(document.doc3)}
etc
which I would rather not do. I would rather be able to do
{fnCounter(document.doc1,document.doc2,document.doc3)}
I'm thinking a looping function that searches for a delimited list of what is contained in the function?
Not sure I understand what you are trying to do but I will take a stab at it. Have you thought about storing the parameters in an array and then just passing the array into the function? You could then loop through the variables/parameters contained in the array.
Check the data symbols section of EMR Help and review 'getarg' and 'getnargs'. This will accomplish what you want. Note: Unlike using defined parameters (arguments), you can leave the parens blank.
I.E.
Defined: fnMyFunction(arg1,arg2)
Undefined: fnMyFunction()
getnargs() - returns the number of arguments
getnarg(index) - returns the value found in the argument index of the parameter string
Keep in mind that ordinal position still applies to a large degree since the getarg symbol references the index position in the parameter string.
Hope this helps.
Great thank you!
{OBSNOW("MMSE SCORE", str(val(DOCUMENT.VALUE_1) + val(DOCUMENT.VALUE_2) + val(DOCUMENT.VALUE_3) + val(DOCUMENT.VALUE_4) + val(DOCUMENT.VALUE_5) + val(DOCUMENT.VALUE_6) + val (DOCUMENT.VALUE_7) + val(DOCUMENT.VALUE_8) + val(DOCUMENT.VALUE_9) + val(DOCUMENT.VALUE_10) + val(DOCUMENT.VALUE_11) + val(DOCUMENT.VALUE_12) + val(DOCUMENT.VALUE_13) + val(DOCUMENT.VALUE_14) + val(DOCUMENT.VALUE_15) + val(DOCUMENT.VALUE_16) + val(DOCUMENT.VALUE_17) + val(DOCUMENT.VALUE_18) + val(DOCUMENT.VALUE_19) + val(DOCUMENT.VALUE_20) + val(DOCUMENT.VALUE_21) + val(DOCUMENT.VALUE_22) + val(DOCUMENT.VALUE_23) + val(DOCUMENT.VALUE_24) + val(DOCUMENT.VALUE_25) + val(DOCUMENT.VALUE_26) + val(DOCUMENT.VALUE_27) + val(DOCUMENT.VALUE_28) + val(DOCUMENT.VALUE_29) + val(DOCUMENT.VALUE_30) + val(DOCUMENT.VALUE_31) + val(DOCUMENT.VALUE_32) + val(DOCUMENT.VALUE_33) + val(DOCUMENT.VALUE_34)+ val(DOCUMENT.VALUE_35)))}
Heres one I use for numerical value calculation. Works well enough.