Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Stefan Wuebbe
  Where is Stefan Wuebbe?
 Hamburg
 Germany
 Stefan Wuebbe
 To: Gene Wirchenko
  Where is Gene Wirchenko?
 Kamloops
 Canada
 Gene Wirchenko
 Tags
Subject: RE: if endif,do while,scan endscan with C#
Thread ID: 394070 Message ID: 394143 # Views: 55 # Ratings: 6
Version: Visual FoxPro 9 SP2 Category: .NET
Date: Monday, December 30, 2013 10:52:46 PM         
   


> > With a comparison to VFP? C# counterparts are more versatile:
>
> Ha!
>
> For example, if works about the same in both.
>
> A lot of your "more versatile" is simply different formatting.
>
> > do case ... endcase
> >
> > simply done with if ... else ... endif style using the fact that syntactically you can write it like:
> >
> >
if c1
> > ...
> > else
> >   if c2
> >     ...
> >   else
> >     if c3
> >        ...
> >     else
> >        ...
> >     endif
> >   endif
> > endif

> >
> > And in C# it is much easier and readable:
>
> About the only difference is the braces and that VFP does not require brackets around conditions.

There are a lot more formatting options in C# than in VFP, for example
        if (test == 0) { }
        else if (test == 1) { }
        else if (test == 2) { }
        else if (test == 3) { }
        else if (test == 4) { }
        else if (test == 5) { }
        else { }



> > (There is a switch () in C# that at first looks like do case...endcase but is different).
>
> "different" meaning *far* less capable.

As we know, in .Net, everything is an object, and additionally almost everything is a type.
switch() plays together with the "strong typing" feature, namely with the ability to create user-defined types.
So as a syntax element it's capable by not intending to be flexible. The flexible part is the object, not the language element.
The switch (someType) {...} statement is somewhat made-to-measure in that context, objects come along with complexity being hidden, "encapsulated", so the public interface is easy, no need to write complicated code to handle them

                ITabModule tabModule = null;
                switch (module)
                {
                    case AppConstants.Modules.Customers:
                        tabModule = new CustomersUserControl();
                        break;
                    case AppConstants.Modules.Invoices:
                        tabModule = new InvoicesUserControl();
                        break;
                    case AppConstants.Modules.Articles:
                    case AppConstants.Modules.Orders:
                        throw new FeatureNotImplementedYetException();
                    default:
                        throw new RMUnexpectedException("Unexpected module parameter.");
                }



> > and another one that VFP doesn't have:
> >
> >
> > do
> > {
> >   // ... guaranteed to execute once
> >   // even if conditionalExpr is false
> > } while (conditionalExpr )
> > 

> >
> > In VFP you have to do that like:
> >
> >
* ... the code to execute
> > do while conditionalExpr
> >   * ... the code to execute
> > enddo
> > 

>
> > Note the unnecessary duplication in code (VFP coders need to be creative to prevent this duplication but that makes it harder).
>
> It is unnecessary duplication. Here is how to avoid it:
>
>
> first=.t.
> do while (conditionalExpr) or first
>    first=.f.
>    * ... the code to execute
>    enddo
> 

>
> Actually, it is very easy to avoid duplicating the code.

Yes, but what Cetin says is that in Vfp it's easy and in .Net it's easier, or in C languages in general in this case




Regards
-Stefan

ENTIRE THREAD

if endif,do while,scan endscan with C# Posted by anand kulkarni @ 12/30/2013 1:30:32 PM
RE: if endif,do while,scan endscan with C# Posted by Stefan Wuebbe @ 12/30/2013 2:15:20 PM
RE: if endif,do while,scan endscan with C# Posted by anand kulkarni @ 12/31/2013 4:20:30 AM
RE: if endif,do while,scan endscan with C# Posted by Cetin Basoz @ 12/30/2013 6:49:50 PM
RE: if endif,do while,scan endscan with C# Posted by Gene Wirchenko @ 12/30/2013 8:11:48 PM
RE: if endif,do while,scan endscan with C# Posted by Stefan Wuebbe @ 12/30/2013 10:52:46 PM
RE: if endif,do while,scan endscan with C# Posted by Gene Wirchenko @ 12/31/2013 7:34:32 PM
RE: if endif,do while,scan endscan with C# Posted by Tony Vignone @ 12/31/2013 9:26:15 PM
RE: if endif,do while,scan endscan with C# Posted by David Mustakim @ 12/31/2013 9:39:31 PM
RE: if endif,do while,scan endscan with C# Posted by Tony Vignone @ 12/31/2013 10:33:36 PM
RE: if endif,do while,scan endscan with C# Posted by David Mustakim @ 1/2/2014 10:05:03 PM
RE: if endif,do while,scan endscan with C# Posted by Tony Vignone @ 1/2/2014 11:37:33 PM
RE: if endif,do while,scan endscan with C# Posted by Gene Wirchenko @ 12/31/2013 11:06:05 PM
RE: if endif,do while,scan endscan with C# Posted by Cetin Basoz @ 1/2/2014 1:42:16 PM
RE: if endif,do while,scan endscan with C# Posted by Gene Wirchenko @ 1/2/2014 6:49:34 PM
RE: if endif,do while,scan endscan with C# Posted by Stefan Wuebbe @ 1/1/2014 11:49:33 AM
RE: if endif,do while,scan endscan with C# Posted by Gene Wirchenko @ 1/2/2014 3:31:21 AM
RE: if endif,do while,scan endscan with C# Posted by Cetin Basoz @ 1/2/2014 1:38:05 PM
RE: if endif,do while,scan endscan with C# Posted by Gene Wirchenko @ 1/2/2014 7:04:59 PM
RE: if endif,do while,scan endscan with C# Posted by Cetin Basoz @ 1/2/2014 7:31:59 PM
RE: if endif,do while,scan endscan with C# Posted by Gene Wirchenko @ 1/3/2014 7:45:08 PM
RE: if endif,do while,scan endscan with C# Posted by Cetin Basoz @ 1/3/2014 9:38:13 PM
RE: if endif,do while,scan endscan with C# Posted by Gene Wirchenko @ 1/6/2014 8:26:53 PM
RE: if endif,do while,scan endscan with C# Posted by Glen Villar @ 12/31/2013 4:19:58 AM
RE: if endif,do while,scan endscan with C# Posted by Cetin Basoz @ 12/31/2013 10:10:22 AM
RE: if endif,do while,scan endscan with C# Posted by Glen Villar @ 12/31/2013 12:02:34 PM
RE: if endif,do while,scan endscan with C# Posted by Binod Binani @ 1/3/2014 2:34:45 PM