Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Problem With Do-Enddo
Message
From
30/01/2013 12:21:56
 
 
To
30/01/2013 08:48:00
General information
Forum:
Visual FoxPro
Category:
Object Oriented Programming
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP
Network:
Windows XP
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01564633
Message ID:
01564687
Views:
50
Set a breakpoint in your program by doubleclicking in the left margin in the editor. You will see a red dot. Open the debugger, and start your program. Your program will stop at the breakpoint. Then you can step through your code, and see what happens and what does not.

>Thanks for your Valuable Suggestions. I will try to incorporate the suggestions you have advised.
>My problem is that want to scan all the records of banks.dbf and they are to be updated from trial.dbf as mentioned in my code.
>
>But using the code mentioned I am not able to replace data for Banks.accode=120616 and banks.bankcode=09. It seems that when append blank is executed the pointer moves to end of file, and the rest of records are left for updation.
>
>kindly provide appropriate method to overcome this.
>
>my code is
>
>
>Mmonth=1
>Select  7
>Use Banks
>Select  6
>Use Trial
>
>
>Select  7
>Goto Top
>SCAN 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
>	ENDSCAN
><pre>
>
>Both the above DBF can be downloaded from 
>
><a href=https://www.dropbox.com/s/7reelvvjuix9k9u/DBF.zip?m target="_blank">https://www.dropbox.com/s/7reelvvjuix9k9u/DBF.zip?m</A>
>
>Regards
>Harsh
>
>
>
>
>
>
>>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:<pre>
>>
>>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
Previous
Reply
Map
View

Click here to load this message in the networking platform