Page 1 of 1

Switch in a Variable

Posted: Wed Dec 02, 2009 5:01 am
by whythetorment
Hi,

How can I create a switch in a variable. I have set as a function and as readonly. Type is string

I have the following, but get an error : "Invalid expression term 'switch'.

Code: Select all

switch (DataSource1.ClaimType)
		{
			case 5:
				ToUpperCase("MyText1");
				break;
				
			case 6:
				ToUpperCase("MyText2");
				break;
				
			case 7:
				ToUpperCase("MyText3");
				break;
				
			case 8:
				ToUpperCase("MyText4");
				break;

			case 9:
				ToUpperCase("MyText5");
				break;

			case  10:         
				ToUpperCase("MyText6");
				break;

			case  11:         
				ToUpperCase("MyText7");
				break;

			default:
				DataSource1.ClaimTypeDescription;
        		break;

		}

Switch in a Variable

Posted: Wed Dec 02, 2009 5:53 am
by Edward
Hi

In that case you need to use a ternary operation instead:

DataSource1.ClaimType == 5?"MyText1":
DataSource1.ClaimType == 6?"MyText2":"value for default"

Also that expression must be set when ReadOnly and Function checkboxes are checked in the variable editor form.

And another approach is to use custom function from the CodeTab. Please see attached report which illustrates this.

Thank you.

Switch in a Variable

Posted: Wed Dec 02, 2009 6:11 am
by whythetorment
Ahhhh thank you... works like a charm..

Switch in a Variable

Posted: Wed Dec 02, 2009 11:44 am
by Edward
Hi

Please let us know if you need any help.

Thank you.