Calculations Macro

Discussion, questions and support.
Post Reply
Renaldostheold
Posts: 1
Joined: Sep 1st, ’25, 22:53

Post by Renaldostheold » Sep 1st, ’25, 23:45

Hi there,

I have had some success with writing a Text Expander that asks the user to select a response to 21 Questions.

Each question's answer is saved to a variable (Select_D_1, Select_D_2.......Select_D_21,).

Three Calculations Macros add the appropriate variable to determine a total score for Depression, Anxiety, and Stress.

The case-if macro is used to determine the severity of Depression, Anxiety, and Stress scores.

Consider the following:

Name: %INPUT_F_Name% %INPUT_L_Name%
%DATETIME_Test_Date%
%SELECT_D_1% %SELECT_D_2% %SELECT_D_3% %SELECT_D_4% %SELECT_D_5% %SELECT_D_6% %SELECT_D_7% %SELECT_D_8% %SELECT_D_9% %SELECT_D_10% %SELECT_D_11% %SELECT_D_12% %SELECT_D_13% %SELECT_D_14% %SELECT_D_15% %SELECT_D_16% %SELECT_D_17% %SELECT_D_18% %SELECT_D_19% %SELECT_D_20% %SELECT_D_21%
TestCalc: %CALC_TestCalc%
Depression: %CALC_Depression%
Anxiety: %CALC_Anx%
Stress: %CALC_Str%
Test Date: %DATETIME_Test_Date%
Results: DASS21(%DATETIME_Test_Date%):%CASE_Dep_Range% Depression(%CALC_Depression%), CASE_ANX_Range Anxiety(%CALC_Anx%), Stress(%CALC_Str%).

Selection Form example for selection with the Type=Radio:
Did not apply to me at all::0
Applied to me to some degree, or some of the time::1
Applied to me to a considerable degree, or a good part of time::2
Applied to me very much, or most of the time::3

The Calculation:

(SELECT_D_3+SELECT_D_5+SELECT_D_10+SELECT_D_13+SELECT_D_16+SELECT_D_17+SELECT_D_21) * 2

The Case-If:
CALC_Depression>=0 and CALC_Depression<=9 --->Normal
CALC_Depression>=10 and CALC_Depression<=13 ---> Mild
CALC_Depression>=14 and CALC_Depression<=20 ---> Moderate
CALC_Depression>=21 and CALC_Depression<=27 ---> Severe
Else ---> Extremely Severe

THE PROBLEM:

The calculations work as expected for three variables, but if more than three variables are used, the totals are incorrect.
If all 21 questions default to zero, then the Depression score returns as a number (16, from memory).
I have checked and rechecked each question, and it appears to be correct.
I have tried the calculation without the multiplier, without brackets.
I have tried giving the variable different names.

Could you please explain what I am doing wrong?
Is there a way to zero out a variable (if it remains in memory)?

I note that the final If case does not capture an out-of-range number, but I can work on that later.

Thanks
User avatar
Marko
Posts: 1906
Joined: Mar 2nd, ’13, 21:02

Post by Marko » Sep 2nd, ’25, 14:33

Hi and thanks for posting this. I believe you issue it that one or more selection macros do not contain any selections. Blank variables would break the calculation.

If this is not the case, please send your settings fdb file with this phrase only (File/Save Selected As...) to our support mail for further analysis.
Post Reply