Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Problem With Do-Enddo
Message
De
30/01/2013 03:34:52
 
 
À
30/01/2013 02:37:39
Information générale
Forum:
Visual FoxPro
Catégorie:
Programmation Orientée Object
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP
Network:
Windows XP
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01564633
Message ID:
01564637
Vues:
53
Sorry for not providing any help to your specific reason, instead I will give you some well meant advices. If you follow these advices, it will also be much easier to help you without twisting our minds too much. I realize that you are relatively new to VFP, I give you these advices with no other things in mind than giving you help. Follow these advices, and you will find VFP programming much easier:

1. When you post code here, use < pre > before your code and < /pre > after the code. (remove the extra space between < and >, I must use a space here or UT will hide what I really write.)
2. NEVER hardcode a work area, meaning NEVER use "select 5" or some other number. Always use a work area name, whenever necessary. Instead of "Use 7" to select an empty work area, use "Select 0" which will select the next availbale work area. When you need to reselect another work area which already have a table open, you can "Select yourtable" instead. This solution is both safer and much easier to use. Your code should never rely on a table being opened in a specific work area.
3. Learn SQL syntax. Select, Update and Insert are the most used SQL commands, they will with one line of code do the same as many lines of procedural code, and usually much faster. In this case you can use the appropriate "Update ... from ... where ..." commands instead of a lot of "do while .. Replace .. enddo" commands. And use "Insert into .." instead of "Append blank" followed by "replace .."
4. If you need to scan a table, and there are many cases where this makes sense, I recommend Scan .. Endscan instead of Do while !eof().
5. When you have a problem with your code, only show the offending code, unless you think it's clear that we need to see it all.
6. Please enable "auto quote", unless you already have done so, it makes later messages easier to respond to. You find this option in the upper right corner of this message area. Just hover your mouse over the label "Message view setup", and you will see it.

And last, always indent your code, something like this, which makes your code much easier to follow:
Do while something
   If something
      do something
      some more code
      do case
          case 1
               some code
          case 2
               some more code
          otherwise
               do something else
      endcase
      even more code
   Else
      Do nothing
   Endif
   Some more code
Enddo
I recommend that you just right click in the editor and run Beuatify, which will do the formatting for you if it's set up properly. Or use the much improved BeautifyX which is a part of the free Thor/PEMEditor bundle. http://vfpx.codeplex.com/

NB! I hope you find this message helpful, my only goal is to help you. In this specific case please format your code, and show which part of the code you have problems with.

>I am using the following code to replace Data from Trial.DBF to Banks.dbf.
>
>But it seems that DO-ENDDO is not working for all all the records from Top to bottom.
>
>I am not able to replace data for Banks.accode=120616 and banks.bankcode=09. Whenever I execute the below procedure, the above heads are not updated.
>
>Where I am Going wrong, Kindly Guide.
>
>
>*****CODE STARTS HERE************
>
>
>Mmonth=1
>Select 7
>Use Banks
>Select 6
>Use Trial
>
>
>select 7
> goto top
> DO while (!EOF())
> bank_code= banks.bankcode
> bank_head= banks.accode
>
> select 6
> locate for bank_code = trial.bankcode .AND. bank_head = ;
> trial.accode
>
> If (!Found())
> select 7
> Append Blank
> Replace Banks.bankcode with bank_code
> Replace Banks.accode with bank_head
> ENDIF
>
> Select 6
> do case
> case mmonth == 4
> newob= trial.debit_4
> case mmonth == 5
> newob= trial.debit_5
> case mmonth == 6
> newob= trial.debit_6
> case mmonth == 7
> newob= trial.debit_7
> case mmonth == 8
> newob= trial.debit_8
> case mmonth == 9
> newob= trial.debit_9
> case mmonth == 10
> newob= trial.debit_10
> case mmonth == 11
> newob= trial.debit_11
> case mmonth == 12
> newob= trial.debit_12
> case mmonth == 1
> newob= trial.debit_1
> case mmonth == 2
> newob= trial.debit_2
> case mmonth == 3
> newob= trial.debit_3
> case mmonth == 13
> newob= trial.debit_31
> case mmonth == 14
> newob= trial.debit_32
> ENDCASE
> WAIT WINDOW bank_code
> WAIT WINDOW Bank_head
> WAIT WINDOW Newob
> select 7
> replace banks.ob with newob
> select 7
> skip
> enddo
>
>***CODE ENDS HERE********
>
>Both the above DBF can be downloaded from
>
>https://www.dropbox.com/s/7reelvvjuix9k9u/DBF.zip?m
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform