DO CASE..ENDCASE

Control Structures – Decision making; DO CASE..ENDCASE

Do Case

/*

Control Structures - Decision making; DO CASE..ENDCASE

For more information refer here 

*/

PROCEDURE Main()
   CLS

   nKey := 0

   cDash := ''

   ? "Press a digit key ( Esc for exit ) : " 

   DO WHILE nKey # 27

      nKey := INKEY( 0 )

      IF nKey > 47 .AND. nKey < 58 

         ?? cDash

         DO CASE
            CASE nKey = 48
               ?? "zero"
            CASE nKey = 49
               ?? "one"
            CASE nKey = 50
               ?? "two"
            CASE nKey = 51
               ?? "three"
            CASE nKey = 52
               ?? "four"
            CASE nKey = 53
               ?? "five"
            CASE nKey = 54
               ?? "six"
            CASE nKey = 55
               ?? "seven"
            CASE nKey = 56
               ?? "eight"
            CASE nKey = 57
               ?? "nine"
         ENDCASE

         cDash := '-'

      ENDIF nKey > 47 .AND. nKey > 58 

   ENDDO

RETURN // Main()

One response to “DO CASE..ENDCASE

  1. Pingback: Harbour Statements | Viva Clipper !

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.