Calling test cases based on result

How does one execute the following:

def result1 == WebUI.callTestCase() whatever

if(result1 == ‘Passing’){
WebUI.callTestCase()_Whatever2
}

The method, callTestCase, has a return type of Object, so you might do something like:

def result1 = WebUI.callTestCase(findTestCase('TC1'), [:], FailureHandling.OPTIONAL)

if (result1.toString() == 'Passed') {
    WebUI.callTestCase(findTestCase('TC2_Whatever2'), [:], FailureHandling.OPTIONAL)
}

and inside TC1 return a String Object, like

...
if (condition) {
    return 'Passed'
} else {
   return 'Failed'
}

Another method that I have used was to use GlobalVariables of a Map, or a List depending on need to pass between the called Test Case and the running one.

GlobalVariable.gTempHolder = [];

WebUI.callTestCase(findTestCase('TC1'), [ : ], FailureHandling.OPTIONAL)

for (int i = 0; i < (GlobalVariable.gTempHolder as List).size(); i++) {
	WebUI.comment('values are ' + GlobalVariable.gTempHolder[i].toString())
}

and inside the test case, ensure you have:

import internal.GlobalVariable as GlobalVariable

Thank you ! I thought that maybe thats what I was missing I just didnt know where I needed it to go!