groff-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[groff] 10/12: doc/groff.texi: Show how to emulate switch/case.


From: G. Branden Robinson
Subject: [groff] 10/12: doc/groff.texi: Show how to emulate switch/case.
Date: Wed, 3 Aug 2022 20:40:43 -0400 (EDT)

gbranden pushed a commit to branch master
in repository groff.

commit 41477bb4b4ac307c6d4ba3261cd31af91bcf0b02
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Wed Aug 3 16:14:28 2022 -0500

    doc/groff.texi: Show how to emulate switch/case.
---
 doc/groff.texi | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/doc/groff.texi b/doc/groff.texi
index 2968699ab..2e6a1325a 100644
--- a/doc/groff.texi
+++ b/doc/groff.texi
@@ -12638,6 +12638,26 @@ condition was false) the remainder of the input line 
is interpreted
 @emph{as if it were on an input line by itself}.
 @endDefesc
 
+We can use @code{ie}, @code{el}, and conditional blocks to simulate the
+multi-way ``switch'' or ``case'' control structures of other languages.
+The following example is adapted from the @code{groff} @file{man}
+package.  Indentation is used to clarify the logic.
+
+@Example
+.\" Simulate switch/case in roff.
+.      ie '\\$2'1' .ds title General Commands\"
+.el \@{.ie '\\$2'2' .ds title System Calls\"
+.el \@{.ie '\\$2'3' .ds title Library Functions\"
+.el \@{.ie '\\$2'4' .ds title Kernel Interfaces\"
+.el \@{.ie '\\$2'5' .ds title File Formats\"
+.el \@{.ie '\\$2'6' .ds title Games\"
+.el \@{.ie '\\$2'7' .ds title Miscellaneous Information\"
+.el \@{.ie '\\$2'8' .ds title System Management\"
+.el \@{.ie '\\$2'9' .ds title Kernel Development\"
+.el                .ds title \" empty
+.\@}\@}\@}\@}\@}\@}\@}\@}
+@endExample
+
 @c ---------------------------------------------------------------------
 
 @node while,  , if-else, Conditionals and Loops



reply via email to

[Prev in Thread] Current Thread [Next in Thread]