0

Switch syntax wrong?

Where is my error here? Can't get my head around the syntax of Switch. The result is always 0 in NumberField and nothing in TextField. (script is in update-trigger for the choice-field "ComboSelect".)

switch ComboSelect do
case ComboSelect = "A": NumberField := 1 and (TextField := "A")
case ComboSelect = "B": NumberField := 2 and (TextField := "B")
case ComboSelect = "C": NumberField := 3 and (TextField := "C")
default: NumberField := 0 and (TextField := "X")
end

3 replies

null
    • Sean
    • 5 yrs ago
    • Reported - view

    You were close. I didn't know you could combine actions in the case sections until now. Here's what I got to work...

     

    switch text(Choice) do
    case "A":
    Number := 1 + (Text := "A")
    case "B":
    Number := 2 + (Text := "B")
    case "C":
    Number := 3 + (Text := "C")
    case "":
    Number := 0 + (Text := "X")
    end

     

    Just modify your field names to match what you have.

    • Viggo
    • 5 yrs ago
    • Reported - view

    Worked like a breeze. Someone hit the light switch; who would know that you could use the "+" as kind of logic operator? Obvious, your more openminded towards putting round balls into square holes ;) Thanks Sean!!!

    • Sean
    • 5 yrs ago
    • Reported - view

    😆 That's kind of the allure for me! I figured since the "and" operator didn't throw an error I might as well try "+". I agree that the documentation is lacking, however, the Webinars offer insight and solutions that the documentation doesn't. Most of my understanding, though, has come from experimenting as you say.