syntax: Support chained If directives #6

Open Jookia opened this issue on 24 Aug 2021 - 3 comments

@Jookia Jookia commented on 24 Aug 2021

Currently if statements do one test, then an action depending on its result. In reality you often need to go through a list of mutually exclusive conditions and do some operation, such as doing an action based on a menu item.

Here's an example of some hacks to handle multiple checks:

If Command Equals BeginText Hi EndText
Then System Print BeginText Hey there! EndText
Else True BeginNote Does nothing EndNote
EndIf
If Command Equals BeginText Exit EndText
Then System Exit
Else True
EndIf

It would be a lot nicer to write something like:

If Command Equals BeginText Hi EndText
Then System Print BeginText Hey there! EndText
ElseIf Command Equals BeginText Exit EndText
Then System Exit
Else True
EndIf

This seems fairly simple.

Maybe while we're at it we could make the 'Else' optional?

@Jookia Jookia changed title from syntax: Support chained if statements to syntax: Support chained If directives on 24 Aug 2021

Yes, that does seem sane to me, and fairly easy to read.

Okay we'll probably go with that then unless it ends up being unreasonably complicated to implement.

@Jookia Jookia deleted the comment on 24 May 2022
Labels

Priority
high
Milestone
No milestone
Assignee
No one assigned
2 participants
@Jookia @xogium