Iterative Component Select Box/Select Input ---selectedElement

Still having some challenges with Selects and looking for clarification.

The options for the select input are Grey, Dark, Yellow, with values same as labels.

the selectedElement is a qodly string source selectedColor

I pass the selected Element to function:

function returnWeather(string:selectedColor)→weather:string

switch
 :(selectedColor == "Grey")
   weather = "Rainy"
 :(selectedColor == "Yellow"
   weather = "Sunny"
 :(selectedColor == "Dark"
   weather = "Nighttime"
 else
   weather = "I can't tell"
end

If the user does not make a selection and an “Empty”? selectedElement is passed to the function, I get Parameter type Mismatch error. Can someone confirm if the following is correct:

  1. We MUST always set the qodlysource type for selected elements in Selects as a variant. Otherwise, if the qodlysource value is not selected and passed to a function that is looking for a string/object/entity, the function will return error because a null or undefined was passed.
  2. Once the selected Element is passed into the function as a variant, it is ok to do tests like: selectedElement == “Rainy” without issue.
  3. if we want to confirm that the user did not make a selection we could also test in the function if selectedElement == null

Thanks for confirming or redirecting/refining. Instinctively I setup the qodlysource as object/string/entity/number etc. but this seems like this can be problematic for selected Elements in iterative qodlysources.

correct.

correct

correct

1 Like

Thx for the confirm. Nulls, Undefined, empty have given me some headaches.

i know it. the descriptions in the manuals are ungreat. there should be an explanation on the null and undefined page of when to use which and why, and examples.

btw you can also use empty if the variable is a variant.

1 Like