eboughey1008
Programmer
I really just want my program to stop, send me a message, create a file of the duplicate records for my client and then close out of the program if the word Dupes is in my status field. Otherwise I want it to finish the process. It's been years since I programmed so I am pretty rusty. Couldn't find anything in the threads though.
I know this must be easy but I am missing something here. Any help would be much appreciated. Below is the code. I know it's messy because I take snippets from all sorts of code I have to work with my current program.
*SET DEFAULT TO e:\working
*** Create job number directory
CLOSE ALL
CLEAR
SET TALK OFF
SET SAFETY OFF
listno = SPACE (15)
lcfilename= SPACE(60)
listcount = SPACE (15)
@ 5,5 say 'Enter Job Number: ' get listno
READ
jobno = listno
lcJOBNO = "e:\working\jobs\"+ALLTRIM(jobno)+"-T3\"
CHDIR ALLTRIM(lcJOBNO)
lcLastDir = FULLPATH(CURDIR())
*** Populate the status field with word 'DUPE' if one is found ***
thefile = getfile('DBF')
Use Alltrim(Lower(thefile))
INDEX ON UPPER(LEFT(ADDRESS,40)+LEFT(address2,10)+LEFT(ZIP,5)) UNIQ TO T1
DELETE ALL
SET INDEX TO
REPLACE ALL status WITH "DUPE" FOR !DELE() AND EMPTY(status)
RECALL ALL
**** create if statement to stop program, send a message and create file if dupes are found ***
IF status = 'DUPE'
GO TOP
COUNT TO Qty For STATUS = "DUPE"
lcNewFile = ALLTRIM(filename)+"-"+ALLTRIM(TRANSFORM(qty))+" Duplicate Records.csv"
COPY FIELDS NAME, ADDRESS, CITY, STATE, ZIP, LISTSOURCE To (lcNewFile) CSV
@ 15,5 say 'DUPLICATES FOUND. CONTACT CLIENT'
WAIT
CLOSE TABLES
RETURN
ELSE
*** Run program
SET FILTER TO EMPTY(STATUS)
alter table alltrim(lower(thefile)) add column 'recid' n(10)
alter table alltrim(lower(thefile)) add column county c(20)
alter table alltrim(lower(thefile)) add column class c(20)
alter table alltrim(lower(thefile)) add column style c(20)
alter table alltrim(lower(thefile)) add column mileage c(20)
alter table alltrim(lower(thefile)) add column z4 c(20)
alter table alltrim(lower(thefile)) add column crrt c(20)
alter table alltrim(lower(thefile)) add column dpc c(20)
REPLACE ALL recid WITH tag
INDEX on UPPER(LEFT(vin,8))+ALLTRIM(year) UNIQUE TO t
COPY fields recid,first,mid,last,suffix, address, city, state, zip, z4,crrt, dpc, make, model,year,vin,county,class,style,mileage TO bb-uniq
**** copy file for append to file for upload
USE bb-uniq
COPY TO "bb-"+LEFT(jobno,5)+".csv" csv
@ 15,5 say 'File for append copied to csv file: '
ENDIF
WAIT
CLOSE ALL
CLEAR
SET TALK OFF
SET SAFETY OFF