Link to home
Start Free TrialLog in
Avatar of Dee
DeeFlag for United States of America

asked on

Replace command stopped working

The replace BREED commands on line 80 has been working for months and has suddenly stopped.

Replace Descrip-- fields starting on line 88 still work.


*!*	*-----------------------------------------
* -    cbBreedRemind_Update.prg
*!*	writes breed and label edits back to practices pull files
*!*	*-----------------------------------------

lparameter lcThisPath;
			lcProc; 
			lnWeekNum
			
LOCAL laDirs[1];
		 lnI;
		 lcPullFile;
		 lcPrgNm
		 
set date to YMD
		 
lcPrgNm = "ckBreedRemind_update.prg"
?
? lcPrgNm + " STARTED", datetime()

if empty(lcThisPath)
	lcThisPath = "c:\vetdata\_de\vetdata\"	
endif


local lcWeekPullFile, ;
	lcWeekPullFileNam ;
	lcPracDir;
	lnWeekNum;
	lcPath ;
	lcScrubFile	
		

set safety off 
set deleted on

if empty(lnWeekNum)
	lnWeekNum = 36
endif


lcWeekNum = "9" + alltrim(right(str(100 + lnWeekNum),2))


lcWeekPullFile = "wk" + lcWeekNum + "_pull.dbf"

use in select('ScrubFile')
lcScrubFile = (lcThisPath) + "ckBreedScrub.dbf"
use (lcScrubFile) alias ScrubFile in 0 excl

select ScrubFile

*-- Create a liast of practice dirs	
SELECT DISTINCT DefaultDir FROM scrubFile INTO ARRAY laDirs

SELECT scrubFile
INDEX ON PRRecno TAG PRRecno

*-- Close possibly open Pullfile
USE IN SELECT('PullFile')

*-- Process all dirs
FOR lnI = 1 TO ALEN(laDirs)

  lcPullFile = lcThisPath + ALLTRIM(laDirs[m.lnI]) + "\pull\" + (lcWeekPullFile)
  IF FILE(m.lcPullFile)
  
    SELECT 0
    *-- Open Pullfile
    USE (m.lcPullFile) ALIAS PullFile
    *-- Update rows one by one
    ? "Updating ",  m.lcPullFile
    SCAN ALL
    
               
      *-- if row in srubfile exists
      IF SEEK(PRRecno, 'scrubFile')
      ? laDirs(lnI) + " " + PRRecno + " " + lcPrgNm

		        REPLACE Breed WITH ;
		        	scrubFile.Breed, ;
		        	Breed1 with scrubfile.breed1, ;
		        	Breedd with scrubfile.breedd, ;
		        	Species with scrubfile.Species, ;
		        	Speciesd with scrubfile.speciesd, ;
		        	Breed with scrubfile.breed

		     		replace ;
		        	Descriptn WITH scrubfile.Descriptn, ;
		        	Descrip2 WITH scrubfile.Descrip2, ;
		        	Descrip3 WITH scrubfile.Descrip3,;
		     		   	Descrip4 WITH scrubfile.Descrip4, ;
		        	Descrip5 WITH scrubfile.Descrip5, ;
		        	Descrip6 WITH scrubfile.Descrip6, ;
		            Descrip7 WITH scrubfile.Descrip7, ;
		            Descrip8 WITH scrubfile.Descrip8
      ENDIF
    ENDSCAN
    USE
  ELSE
    wait window " no File " + (lcPullFile) &&? m.lcPullFile, "does not exist"w
    ? m.lcPullFile, " does not exist"
  ENDIF
NEXT

? lcPrgNm + "    has Completed", datetime()

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Pavel Celba
Pavel Celba
Flag of Czechia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I interpret this as updating pulldata from scrubdata.

The simplest reason would be you don't have any PRRecno in both Scribfile and pullfile, so there is no update. of existing records.

If this is about syncing, I'd expect an ELSE case, where a not found PRRecno would be added to pullfile. You don't do that. If you never do that, that could lead to that situation in the long run, as most database changes are new inserts or updates of most recent data. When you never add new data, the pulldata becomes less current and updates of already existing PRRecno become scarcer and scarcer until none are done.

I second Pavel, the more you tell instead of just posting all your code without any data samples or explanation and expecting us to understand your situation, the better help you can get.

The shortest advice: Look into the data and see whether you can actually expect any SEEKS to find records to update.

Bye, Olaf.
Hi Olaf,

failed SEEK would not explain the second REPLACE command working correctly. So something behind the scene we still don't know...

But I believe this will be explained soon.

P.C.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Dee

ASKER

I think the rest of my question  dropped off in the copy and paste from my draft in notepad.  Crazy me.  :)  

But you guys never cease to amaze me in reading between the lines even when there are no lines to read between!  I left them all out!

"Suddenly stopped working" was to mean that the fields were not being replaced by anything.  They were blank.

The seek was returning blank fields due to a very minor change I had made to the program that builds the scrubfile.  I had forgotten about even making the change.

Thank you both for being so patient with me.  xoxo :)