Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Breaking from the loop
Message
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Titre:
Breaking from the loop
Versions des environnements
Environment:
C# 4.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Divers
Thread ID:
01572547
Message ID:
01572547
Vues:
65
Hi everybody,

I am thinking of the best way to convert the following VFP code
'Other Level: '+misc_level+chr(13)+chr(10) + ;
   alltrim(prefs_bk.b_pop1)+':'+chr(13)+chr(10) + ;
    iif(empty(prefs_bk.b_pop1_1),'', ;
     '   '+alltrim(prefs_bk.b_pop1_1)+': '+iif(pop_up1_1,'YES','NO')+chr(13)+chr(10))+;
    iif(empty(prefs_bk.b_pop1_2),'',;
     '   '+alltrim(prefs_bk.b_pop1_2)+': '+iif(pop_up1_2,'YES','NO')+chr(13)+chr(10))+;
    iif(empty(prefs_bk.b_pop1_3),'',;
     '   '+alltrim(prefs_bk.b_pop1_3)+': '+iif(pop_up1_3,'YES','NO')+chr(13)+chr(10))+;
    iif(empty(prefs_bk.b_pop1_4),'',;
     '   '+alltrim(prefs_bk.b_pop1_4)+': '+iif(pop_up1_4,'YES','NO')+chr(13)+chr(10))+;
    iif(empty(prefs_bk.b_pop1_5),'',;
     '   '+alltrim(prefs_bk.b_pop1_5)+': '+iif(pop_up1_5,'YES','NO')+chr(13)+chr(10))+;
    iif(empty(prefs_bk.b_pop1_6),'',;
     '   '+alltrim(prefs_bk.b_pop1_6)+': '+iif(pop_up1_6,'YES','NO')+chr(13)+chr(10))+;
    iif(empty(prefs_bk.b_pop1_7),'',;
     '   '+alltrim(prefs_bk.b_pop1_7)+': '+iif(pop_up1_7,'YES','NO')+chr(13)+chr(10))+;
    iif(empty(prefs_bk.b_pop1_8),'',;
     '   '+alltrim(prefs_bk.b_pop1_8)+': '+iif(pop_up1_8,'YES','NO')+chr(13)+chr(10))+;
    iif(empty(prefs_bk.b_pop1_9),'',;
     '   '+alltrim(prefs_bk.b_pop1_9)+': '+iif(pop_up1_9,'YES','NO')+chr(13)+chr(10))+;
    iif(empty(prefs_bk.b_pop1_10),'',;
     '   '+alltrim(prefs_bk.b_pop1_10)+': '+iif(pop_up1_10,'YES','NO')+chr(13)+chr(10)) + ;
   iif(empty(prefs_bk.b_crit2),'', alltrim(prefs_bk.b_crit2) + ': ' + iif(criteria_2,'YES','NO')+chr(13)+chr(10)) + ;
   iif(empty(prefs_bk.b_crit3),'', alltrim(prefs_bk.b_crit3) + ': ' + iif(criteria_3,'YES','NO')+chr(13)+chr(10)) + ;
   iif(empty(prefs_bk.b_crit4),'', alltrim(prefs_bk.b_crit4) + ': ' + transform(criteria_4)+chr(13)+chr(10)) + ;
   iif(empty(prefs_bk.b_crit5),'', alltrim(prefs_bk.b_crit5) + ': ' + transform(criteria_5)+chr(13)+chr(10)) + ;
   alltrim(prefs_bk.b_pop2)+':'+chr(13)+chr(10) + ;
    iif(empty(prefs_bk.b_pop2_1),'', ;
     '   '+alltrim(prefs_bk.b_pop2_1)+': '+iif(pop_up2_1,'YES','NO')+chr(13)+chr(10)) + ;
    iif(empty(prefs_bk.b_pop2_2),'',;
     '   '+alltrim(prefs_bk.b_pop2_2)+': '+iif(pop_up2_2,'YES','NO')+chr(13)+chr(10)) + ;
    iif(empty(prefs_bk.b_pop2_3),'',;
     '   '+alltrim(prefs_bk.b_pop2_3)+': '+iif(pop_up2_3,'YES','NO')+chr(13)+chr(10))+ ;
    iif(empty(prefs_bk.b_pop2_4),'',;
     '   '+alltrim(prefs_bk.b_pop2_4)+': '+iif(pop_up2_4,'YES','NO')+chr(13)+chr(10))+ ;
    iif(empty(prefs_bk.b_pop2_5),'',;
     '   '+alltrim(prefs_bk.b_pop2_5)+': '+iif(pop_up2_5,'YES','NO')+chr(13)+chr(10))+ ;
    iif(empty(prefs_bk.b_pop2_6),'',;
     '   '+alltrim(prefs_bk.b_pop2_6)+': '+iif(pop_up2_6,'YES','NO')+chr(13)+chr(10))+ ;
    iif(empty(prefs_bk.b_pop2_7),'',;
     '   '+alltrim(prefs_bk.b_pop2_7)+': '+iif(pop_up2_7,'YES','NO')+chr(13)+chr(10))+ ;
    iif(empty(prefs_bk.b_pop2_8),'',;
     '   '+alltrim(prefs_bk.b_pop2_8)+': '+iif(pop_up2_8,'YES','NO')+chr(13)+chr(10))+ ;
    iif(empty(prefs_bk.b_pop2_9),'',;
     '   '+alltrim(prefs_bk.b_pop2_9)+': '+iif(pop_up2_9,'YES','NO')+chr(13)+chr(10))+ ;
    iif(empty(prefs_bk.b_pop2_10),'',;
     '   '+alltrim(prefs_bk.b_pop2_10)+': '+iif(pop_up2_10,'YES','NO')+chr(13)+chr(10)) + ;
    iif(empty(prefs_bk.b_pop2_11),'',;
     '   '+alltrim(prefs_bk.b_pop2_11)+': '+iif(pop_up2_11,'YES','NO')+chr(13)+chr(10)) + ;
    iif(empty(prefs_bk.b_pop2_12),'',;
     '   '+alltrim(prefs_bk.b_pop2_12)+': '+iif(pop_up2_12,'YES','NO')+chr(13)+chr(10)) + ;
    iif(empty(prefs_bk.b_pop2_13),'',;
     '   '+alltrim(prefs_bk.b_pop2_13)+': '+iif(pop_up2_13,'YES','NO')+chr(13)+chr(10)) + ;
    iif(empty(prefs_bk.b_pop2_14),'',;
     '   '+alltrim(prefs_bk.b_pop2_14)+': '+iif(pop_up2_14,'YES','NO')+chr(13)+chr(10)) + ;
    iif(empty(prefs_bk.b_pop2_15),'',;
     '   '+alltrim(prefs_bk.b_pop2_15)+': '+iif(pop_up2_15,'YES','NO')+chr(13)+chr(10))
(the VFP could have been written using loop and evaluate also, but it was written long time ago and never changed).

This is what I have so far, but I don't like checking i and j variables inside the loop - may be there is a better way to break out?
for (int i = 1; i <= 2; i++)
            {
               displayString.AppendFormat("{0}:{1}", database.GetPreferenceString("prefs_bk", "b_pop" + i.ToString()).Trim(), Environment.NewLine);
               for (int j = 1; j <= 15; j++)
               {
                  if ((1 == i && j <= 10) || (2 == i))
                  {
                     String prefs_pop = database.GetPreferenceString("prefs_bk", "b_pop" + i.ToString() + "_" + j.ToString()).Trim();
                     if (!String.IsNullOrWhiteSpace(prefs_pop))
                     {
                        Boolean skills = Convert.ToBoolean(row[String.Format("pop_up{0}_{1}", i, j)]);
                        displayString.AppendFormat("   {0}: {1}{2}", prefs_pop, (skills) ? "YES" : "NO", Environment.NewLine);
                     }

                     if ((j >= 2 && j <= 5) && 1 == i)
                     {
                        String criterion = database.GetPreferenceString("prefs_bk", "b_crit" + j.ToString());
                     }
                  }

               }  
            }
So, the problem here is that we have 10 b_pop1_ columns and 15 b_pop2 columns. So, I somehow need to run loop for 10 and for 15.

Thanks in advance for the suggestions.
If it's not broken, fix it until it is.


My Blog
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform