Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help missing keyword in the FOR...ENDFOR or DO CASE...ENDCASE command structure

Status
Not open for further replies.

Luiz Eduh

Technical User
Jan 10, 2012
51
US
You need to put your problem into the posting itself as well as the specific lines of associated code (not a whole program of code) so that we can look directly at it and not put it into some link where unscrupulous people (of course, not you) might have "gotcha's" waiting for us.

Good Luck,
JRB-Bldr


 
Okay so sorry,
Im getting a popup error saying "There is a missing keyword in the FOR...ENDFOR or DO CASE....ENDCASE command structure. Here is the code that im running; the program is crashing in the second line in this code "case shiploca=' '

do case
case shiploca=' '
skip
case retailponu # ' '
select cus
seek 'PETCO '
locate for '#'+m->storenum+' '$cusname while cusname='PETCO '
if !found()
exit
endif
* we have a store
trandate = date()
if val(cus->cusdelday) > 0
do while str(dow(m->trandate),1) <> cus->cusdelday ;
trandate = m->trandate + 1
endif
select tran
loopit = .f.
seek 'O'+cus->cuscode
do while trantype = 'O'.and.;
cuscode = cus->cuscode.and.!loopit.and.!eof()
if po == m->po
loopit = .t.
endif
skip
seek 'i'+cus->cuscode
do while trantype = 'i'.and. cuscode = cus->cuscode.and.!loopit.and.!eof()
if po = m->po
loopit = .t.
endif
skip
enddo
select temptran
locate for po = m->po
if !eof()
loopit = .t.
endif
select tran

if loopit
select dbfdata
continue
loop
endif
mtrannum = NextTran()
select temptran
if add_rec( 3 )
replace ;
Cuscode with cus->Cuscode, ;
Cusname with cus->Cusname, ;
Salesman with cus->CusSalesmn, ;
Trancol with cus->CusCol, ;
Trandue with cus->Cusdaysdue, ;
Trandisc with cus->Cusdisc, ;
Billto with cus->Billto, ;
Trantype with 'O', ;
trannum with m->mtrannum, ;
Trandate with m->trandate, ;
PO with m->PO, ;
trandisc with 2
endif
select dbfdata
skip
case poline # ' '
total = 0
mline = 0
line = '0'
do while m->storenum = trim(shiploca) .and. !eof()
mitem=alltrim(vendorstyl)
do case
case len(mitem)=1
mitem='000'+mitem
case len(mitem)=2
mitem='00'+mitem
case len(mitem)=3
mitem='0'+mitem
endcase
select inv
seek trim(m->mitem) &&seek trim(petcopo->c)
if !found()
do errormess with 'Item '+trim(m->mitem)+' is unknown' &&do errormess with 'Item '+trim(petcopo->c)+' is unknown'
select dbfdata
skip
loop
* record this unknown
endif
line = str(mline+1,3,0)
mline = val(line)
* 08/12/05 11:00am made discount a memvar previously was inv->discount
* okc gives 2% on livestock 0% on frozen
discount = 'N'
if sku01disc>0
discount = 'Y'
endif
select tempstat
if upper(dbfdata->unitmeasur) # 'CASE'
append blank
replace ;
trannum with m->mtrannum, ;
tranline with m->line, ;
prodnum with inv->prodnum, ;
ordqty with val(dbfdata->qtyordered), ;
shipqty with val(dbfdata->qtyordered), ;
descript with inv->sku01desc, ;
price with inv->sku01prc, ;
searchcode with inv->searchcode, ;
taxable with inv->taxable, ;
printlabel with 'N', ;
updated with .f., ;
discount with m->discount, ;
com_rate with inv->com_rate, ;
category with inv->category
dbcommit()
total = m->total + shipqty * inv->sku01prc
select inv
rec_lock()
if reserved + tempstat->shipqty < 900000 && n,6
replace reserved with reserved + tempstat->shipqty
else
replace reserved with 900000
endif
dbcommit()
unlock
select tempstat
else
* do the case thing
select tempstat
for i = 1 to val(dbfdata->qtyordered)
append blank
replace ;
trannum with m->mtrannum, ;
tranline with m->line, ;
prodnum with inv->prodnum, ;
ordqty with inv->sku01qty, ;
shipqty with inv->sku01qty, ;
descript with inv->sku01desc, ;
price with inv->sku01prc, ;
searchcode with inv->searchcode, ;
taxable with inv->taxable, ;
printlabel with 'N', ;
updated with .f., ;
discount with m->discount, ;
com_rate with inv->com_rate, ;
category with inv->category
dbcommit()
total = m->total + shipqty * inv->sku01prc
select inv
rec_lock()
if reserved + tempstat->shipqty < 900000 && n,6
replace reserved with reserved + tempstat->shipqty
else
replace reserved with 900000
endif
dbcommit()
unlock
if i < val(dbfdata->qtyordered)
line = str(mline+1,3,0)
mline = val(line)
endif
select tempstat
next
endif case thing
select dbfdata
if !eof()
skip
endif
enddo
select dbfdata
for num = 1 to 2
line = str(val(m->line)+1,3,0)
if num = 1
if lcharge1 = ' '
line = str(val(m->line)-1,3,0)
loop
endif
code = lcharge1
ord = 0
ship = 1
endif
if num = 2
if lcharge2 = ' '
loop
endif
code = lcharge2
ord = 1
ship = 1
endif
select inv
seek code
if !found()
* record this unknown
endif
select tempstat
append blank
replace ;
trannum with m->mtrannum, ;
tranline with m->line
replace ;
prodnum with inv->prodnum, ;
ordqty with m->ord, ;
shipqty with m->ship
replace ;
descript with inv->sku01desc, ;
price with inv->sku01prc, ;
searchcode with inv->searchcode, ;
taxable with inv->taxable
replace ;
printlabel with 'N', ;
updated with .f., ;
discount with m->discount, ;
com_rate with inv->com_rate, ;
category with inv->category
select inv
rec_lock()
replace reserved with reserved + tempstat->shipqty
dbcommit()
unlock
total = m->total + m->ship * inv->sku01prc
select dbfdata
next
* endfor
select temptran
replace trantotal with m->total
select dbfdata
enddo
endcase
**********************************************************************
enddo


Thanks for your help
 
Have you used the VFP top menu - Tools - Beautify... on your code to visually show the layout of your DO CASE/ENDCASE code?

If you had you would see that the final ENDCASE is not visually in-line with the initial DO CASE. That indicates that you have an in-balance of the statements.

Go into the code and work out each individual part separately so that each and every 'Start' (DO CASE or IF) has a matching 'Close' (ENDDO or ENDIF).

Good Luck,
JRB-Bldr
 
Sorry, for asking too much.
Im new on programing, and even using the beautify tool, I can't figure it out whats wrong.

Thanks
 
Write out your DO CASE/ENDCASE as 2 single lines of code.

Code:
DO CASE
 * --- Nothing here YET ---
ENDCASE

Then write or Copy/Paste the code for your first CASE only

Code:
DO CASE
   CASE <condition #1>
     <put code in here>
   * --- Nothing MORE here YET ---
ENDCASE
Run Tools - Beautify...

If things look good, then go on to your next CASE in the same manner.
Code:
DO CASE
   CASE <condition #1>
     <put code in here>

   CASE <condition #2>
     <put code in here>
   * --- Nothing MORE here YET ---
ENDCASE
Run Tools - Beautify...

If things look in-balance after the first code entry, then the most recent piece of code you put in has a problem.

Good Luck,
JRB-Bldr


 
I can see two things right off the bat so to speak.

Code:
		* we have a store
		TRANDATE = DATE()
		IF VAL(CUS->CUSDELDAY) > 0
			DO WHILE STR(DOW(M->TRANDATE),1) <> CUS->CUSDELDAY ;
					TRANDATE = M->TRANDATE + 1
			ENDIF

This looks to me as if you are trying to put a condition (the IF VAL(...) around the head of a do while loop.


Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.
 
The other one is probably related to the first - there is a 'dangling' or widow enddo at the end of the code.

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top