How can I code a 'CASE Structure' (Multiway Branch) in NCL.
search cancel

How can I code a 'CASE Structure' (Multiway Branch) in NCL.


Article ID: 11193


Updated On:


CMDB for z/OS NetSpy Network Performance NetMaster Network Automation SOLVE NetMaster Network Management for SNA NetMaster Network Management for TCP/IP NetMaster File Transfer Management SOLVE:Operations Automation SOLVE:Access Session Management SOLVE:FTS


In NCL, there is no designated verb for a 'Case Structure' (also called a Multi-way Branch) which is available for some other languages.

How can I code a 'CASE Structure' (Multiway Branch) in NCL?


Release: SLACCS00200-5-SOLVE:Access-Session Management


We can create a 'CASE Structure' sub-routine as shown in the following example:

Assume that a panel is displayed, presenting a list of five options, which can be selected by specifying '1' through to '5'. The User enters their required number choice and presses <ENTER>. The NCL code for processing the Users selection is shown here (assuming the 'User entered' selection is stored in the variable &SELECT)...

   processing for wrong selection 
   processing of selection 1 
   processing of selection 2 
   processing of selection 3 
   processing of selection 4 
   processing of selection 5 

...For every valid value of '&SELECT', there is a Label to which processing 'jumps', via line...


To follow the rules of 'Structured Programming', the processing jumps to the end of the 'CASE Structure' via Label '.ENDCASE'.

It is necessary to code...


...prior to the 'CASE Structure' sub-routine, to avoid the NCL abending, due to a wrong selection, causing a 'jump' to a

non-existent Label, i.e. ...

If the User enters a '7', for example, then a Branch to Label '.#7' is attempted, but the Label does not exist. With '&CONTROL NOLABEL' in effect, processing continues after the '&GOTO'. This allows the NCL to react to incorrect or missing entries, at that place in the NCL.

Additional Information

There is a YouTube video which describes how to do this. SeeĀ Case Structures in NCL