October 3, 200223 yr Can I use a CASE statement in a script using the SET FIELD command instead of a series of IF statements Cheers Nick
October 3, 200223 yr CASE does not exist as a SCRIPT step. The only conditional scripting control is the IF/ELSE steps.
October 3, 200223 yr Indeed you can, Nick! The Case ( ) function, used within a Set Field command will in some instances provide for a much more compact script sytax - where, for example, the following sequence: If ["IsEmpty(EventDate)"] Set Field ["WhenHappens.txt", " "Unknown" "] Else If ["EventDate" < Status(CurrentDate)"] Set Field ["WhenHappens.txt", " "Already Over" "] Else If ["EventDate" = Status(CurrentDate)"] Set Field ["WhenHappens.txt", " "Today!" "] Else If ["EventDate" > Status(CurrentDate)"] Set Field ["WhenHappens.txt", " "Not Yet..." "] EndIf EnfIf EndIf EndIf Can be achieved rather more neatly with a single step, using the following: Set Field ["WhenHappens.txt", "Case(IsEmpty(EventDate), "Unknown", EventDate" < Status(CurrentDate), "Already Over", EventDate" = Status(CurrentDate), "Today!", "Not Yet..." "] There are many uses for this technique.
Create an account or sign in to comment