× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



I don't understand why "select/when" in RPG is all of a sudden being
compared with the "switch/case" in C.  They are not the same thing, and
do not work the same way.

select/when works the same as if/else if in C.  (Or for that matter,
the same as IF/ELSEIF in RPG...  not really sure why they needed to add
if/elseif since they do EXACTLY the same thing that select/when has always
done...)

Example:

     c                   select
     c                   when      conda='1' and condb='2'
     c                .... do this ....
     c                   when      conda='1' and condb='3'
     c                .... do that ....
     c                   endsl


Is the same as:

      if (conda=='1' && condb=='2') {
            .... do this ....
      }
      else if (conda=='1' && condb=='3') {
            .... do this ....
      }


So, why are people trying to make a comparison between select/when and
switch/case?!  Is it just because they have (slightly) similar names?




On Wed, 31 Jul 2002, Jim Langston wrote:

> Personally, I found the C style switch statement kinda limiting, with
> the Pascal/RPG giving me a lot more leeway.
>
> A lot easier to say:
> Select
> When CondA = '1' And CondB = 2
>   ... do this...
> etc..
>
> Then have to code:
> Switch CondA
> Case '1':
>    If CondB = 2
>       ... do something...
> etc...
>
> The first, IMO, is easer to understand.
>
> You are right, though, I think that compiler design decisions are not as
> much influenced by speed of execution but by becoming as high level as
> possible.  Everyone knows (or should) that Objects are no wear near
> optimized for speed.
>
> Regards,
>
> Jim Langston



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.