*--Required variable settings ddir = SYS(2003)+"\" && set it to the data .dbf files directory tdir = "C:\TEMP\" && set it to any temporary directory *--Verify the user really wants to do an export to floppy and didn't pick this menu item by mistake PRIVATE llgoon llgoon=1 llgoon=MESSAGEBOX('This program exports agency files to floppy disk.'+CHR(13); +'Click OK to continue or Cancel to abort this operation.',1+32+256,'Export to floppy disk?') IF llgoon=2 RETURN ENDIF *--Prompt the user for a blank floppy disk llgoon=1 llgoon=MESSAGEBOX('Insert a blank floppy disk and click on OK to continue or Cancel to abort.',1+48+256,'Ready to export to floppy disk.') IF llgoon=2 RETURN ENDIF SET SAFETY OFF *--Modify this array to add more files to be exported =ADIR(lafiles,ddir+"*.dbf") *!* PRIVATE ARRAY lafiles[7] *!* DIMENSION lafiles[7] *!* lafiles[1]="carrier.dbf" *!* lafiles[2]="ca_types.dbf" *!* lafiles[3]="prpfcino.dbf" *!* lafiles[4]="users.dbf" *!* lafiles[5]="status.dbf" *!* lafiles[6]="transact.dbf" *!* lafiles[7]="type.dbf" IF ALEN(lafiles,1) = 0 =MESSAGEBOX('No files were selected to copy') return ENDIF WAIT WINDOW " Verifying System is ready for Exporting Data..." NOWAIT *--Determine the floppy drive lcFloppy=GetFloppyDrive() IF UPPER(TYPE('lcFloppy'))="L" .OR. ISNULL(lcFloppy) .OR. LEN(ALLTRIM(lcFloppy))=0 && no floppy drive detected MESSAGEBOX('ERROR! No floppy drive was detected on this computer.'+CHR(13); +'Contact ATI Support for assistance.',16,'An Error Occured.') RETURN ENDIF PRIVATE checkb checkb=.F. lcFloppy=UPPER(ALLTRIM(lcFloppy)) lnpos=AT(';',lcfloppy) IF lnpos>0 .AND. "B:" $ lcFloppy * 2 floppy drives STORE .T. TO checkb ENDIF lcFloppy="A:" *--See if there is a disk in the drive PRIVATE llok, llans, ncheckb ncheckb=0 llans=1 llok=.F. DO WHILE !llok llok=IsFloppyReady() IF llok && disk detected in floppy drive *--Is the disk in the floppy drive blank? =ADIR(afiles,lcFloppy+"\*.*") IF UPPER(TYPE('afiles'))!="U" llans=1 llans=MESSAGEBOX('The floppy in drive '+lcFloppy+' is not blank! '+CHR(13); +'Do you want to erase all files on drive ' +lcFloppy+' ? '+CHR(13)+CHR(13); +'Click OK to erase all files on the floppy or Cancel to abort this operation.',1+16+256,'Floppy disk in drive '+lcFloppy+' is Not Blank') IF llans=2 llok=.F. EXIT ENDIF *--Delete all files on the floppy to start with an empty disk =ADIR(gaexpfiles,lcFloppy+"\*.*") FOR i = 1 TO ALEN(gaexpfiles,1) IF UPPER(TYPE('gaexpfiles(i,1)'))="C" tcfile=lcFloppy+"\"+gaexpfiles(i,1) IF FILE(tcfile) DELE FILE &tcfile ENDIF ENDIF ENDFOR LOOP ENDIF EXIT ENDIF *--No disk detected in the floppy drive IF !checkb && bombed on a: drive, but no floppy disk inserted llans=1 llans=MESSAGEBOX('ERROR - A Floppy Disk was not detected in drive '+lcFloppy +CHR(13); +'Please Insert a Blank Floppy Disk into Drive '+lcFloppy+' and '; +'Click OK to try again or Cancel to abort.',1+16+256,'Floppy disk in drive '+lcFloppy+' Required to Continue') IF llans=2 && user cancelled EXIT ENDIF ELSE && check 2nd drive ncheckb=ncheckb+1 IF ncheckb=1 lcFloppy="B:" ELSE && 1st error on b: drive llans=1 llans=MESSAGEBOX('ERROR - A Floppy Disk was not detected in drive A: or B:'+CHR(13); +'Please Insert a Blank Floppy Disk into the floppy drive and '+CHR(13); +'Click OK to try again or Cancel to abort.',1+16+256,'Floppy disk in drive '+lcFloppy+' Required to Continue') IF llans=2 && user cancelled EXIT ENDIF lcFloppy="A:" ncheckb=0 ENDIF ENDIF ENDDO IF !llok && user cancelled WAIT WINDOW "Export Canceled." NOWAIT RETURN ENDIF PRIVATE lcfiles lcfiles="" PRIVATE lncount lncount=0 *--Verify files exist first to export FOR i = 1 TO ALEN(lafiles,1) IF UPPER(TYPE('lafiles(i,1)'))="C" .AND. !FILE(ddir+lafiles(i,1)) lcfiles=lcfiles+lafiles(i,1)+CHR(13) lncount=lncount+1 ENDIF ENDFOR IF LEN(ALLTRIM(lcfiles))>1 && Missing files to copy lans=2 && Cancel IF lncount=1 lans=MESSAGEBOX(lcfiles+CHR(13)+ "Is Missing and cannot be exported! Continue anyway?",1+16+256) ELSE lans=MESSAGEBOX(lcfiles+CHR(13)+ "Are Missing and cannot be exported! Continue anyway?",1+16+256) ENDIF IF lans=2 && cancel RETURN ENDIF ENDIF *--Ok to continue, export files to floppy procedure DO exp_files RETURN *------------------------------------------------------------------------------------------------------------------------------------------- PROCEDURE exp_files WAIT WINDOW " Exporting files..." NOWAIT WAIT WINDOW "STEP 1 CREATING TEMPORARY FILES - PROCESSING:" NOWAIT PRIVATE xrow xrow=2 PRIVATE llopen && was the file already open? don't close it when done if so FOR i = 1 TO ALEN(lafiles,1) llopen=.F. xrow=xrow+1 IF xrow=11 xrow=2 ENDIF IF UPPER(TYPE('lafiles(i,1)'))="C" .AND. FILE(ddir+lafiles(i,1)) lnpos=(RAT(".",lafiles(i,1))+1) && one position to the right of IF lnpos>0 lcshort = UPPER(LEFT(lafiles(i,1),lnpos-2)) && grab from lnpos to end ELSE lcshort=UPPER(lcfile) ENDIF IF !USED(lcshort) llopen=.F. SELE 0 USE ddir+lafiles(i,1) ELSE llopen=.T. SELECT(lcshort) ENDIF IF RECCOUNT()>0 lcname=tdir+lcshort+".csv" WAIT WINDOW "Copying "+lafiles(i,1) +" to "+tdir NOWAIT COPY TO &lcname TYPE DELIMITED ENDIF IF !llopen && table was not already open so close it again USE IN (lcshort) ENDIF ENDIF ENDFOR =ADIR(gaexpfiles,tdir+"*.csv") =ASORT(gaexpfiles) PRIVATE lntot, lctot lctot="" lntot=0 FOR i = 1 TO ALEN(gaexpfiles,1) IF UPPER(TYPE('gaexpfiles(i,2)'))="N" lctot=lctot; +PADR(ALLTRIM(gaexpfiles(i,1)),25,'.'); +PADL(ALLTRIM(STR(gaexpfiles(i,2))),25,'.'); +CHR(13) lntot=lntot+gaexpfiles(i,2) ENDIF ENDFOR lctot=lctot+'Total Free Space Required : '+ALLTRIM(STR(lntot))+CHR(13) lctot=lctot+'Space on your Floppy Drive: '+'1384576'+CHR(13)+CHR(13) PRIVATE tcfile IF lntot>1384576 && not enough space on floppy drive to copy files CLEAR WAIT CLEAR MESSAGEBOX(lctot; +'Not enough space on floppy disk to copy files.'+CHR(13); +'Click OK to Abort this Operation and Return',16, 'ERROR - Insufficient space on floppy drive.') FOR i = 1 TO ALEN(gaexpfiles,1) IF UPPER(TYPE('gaexpfiles(i,1)'))="C" tcfile=tdir+gaexpfiles(i,1) IF FILE(tcfile) DELE FILE &tcfile ENDIF ENDIF ENDFOR CLEAR WAIT CLEAR RETURN ELSE && ok to copy to floppy drive WAIT WINDOW "STEP 2 COPYING TO FLOPPY - PROCESSING:" NOWAIT xrow=2 FOR i = 1 TO ALEN(gaexpfiles,1) xrow=xrow+1 IF xrow=11 xrow=2 ENDIF IF UPPER(TYPE('gaexpfiles(i,1)'))="C" WAIT WINDOW "Copying "+gaexpfiles(i,1) +" to "+lcFloppy NOWAIT tcfile=tdir+gaexpfiles(i,1) lcname=lcFloppy+"\"+gaexpfiles(i,1) COPY FILE &tcfile TO &lcname ENDIF ENDFOR ENDIF *--Finished copying to floppy, delete temp copies WAIT WINDOW "STEP 3 CLEANING UP TEMPORARY FILES:" NOWAIT xrow=2 FOR i = 1 TO ALEN(gaexpfiles,1) xrow=xrow+1 IF xrow=11 xrow=2 ENDIF IF UPPER(TYPE('gaexpfiles(i,1)'))="C" tcfile=tdir+gaexpfiles(i,1) IF FILE(tcfile) WAIT WINDOW "Deleting temporary file: "+tcfile NOWAIT DELE FILE &tcfile ENDIF ENDIF ENDFOR WAIT WINDOW "Finished Exporting Files!" NOWAIT RETURN *------------------------------------------------------------------------------------------------ FUNCTION IsFloppyReady #DEFINE SEM_FAILCRITICALERRORS 1 #DEFINE SEM_NOALIGNMENTFAULTEXCEPT 4 #DEFINE SEM_NOGPFAULTERRORBOX 2 #DEFINE SEM_NOOPENFILEERRORBOX 32768 && 0x8000 DECLARE INTEGER SetErrorMode IN kernel32 INTEGER uMode LOCAL lvOldOnError, lnVfpError, lnOldErrorMode * saving the old ErroMode value, and at the same moment * suppressing a possible system message of no disk in drive lnOldMode = SetErrorMode (SEM_FAILCRITICALERRORS) * saving the old ON ERROR state lvOldOnError = ON("ERROR") lnVfpError = .F. ON ERROR lnVfpError = .T. SET CONS OFF IF lcFloppy="A:\" .OR. lcFloppy="A:" DIR a: ELSE DIR b: ENDIF SET CONS ON * restoring saved properties ON ERROR &lvOldOnError = SetErrorMode (lnOldMode) RETURN NOT lnVfpError *------------------------------------------------------------------------------------------------------------------------------- FUNCTION GetFloppyDrive * This program enumerates all drives on a Win32 system and * displays a message box containing the drive letters and * types of all logical drives on the system. * * Constants for drive types. #DEFINE DRIVE_UNKNOWN 0 #DEFINE DRIVE_NO_ROOT_DIR 1 #DEFINE DRIVE_REMOVABLE 2 #DEFINE DRIVE_FIXED 3 #DEFINE DRIVE_REM 4 * #DEFINE DRIVE_REMOTE 4 #DEFINE DRIVE_CDROM 5 #DEFINE DRIVE_RAMDISK 6 #DEFINE CR CHR(13) DECLARE INTEGER GetLogicalDrives IN Win32API DECLARE INTEGER GetDriveType IN Win32API STRING RootPath PRIVATE lcDrivestring, lcDriveRoot, liDrivelist, lcDrives, i lcDrives = "" * GetLogicalDrives returns a 32-bit value containing a list of * available drives. If the specific bit is ON, the drive letter * corresponding to that position exists. liDrivelist = GetLogicalDrives() * return liDrivelist * Check each of the bits PRIVATE ARRAY lexpdrives(1,2) IF UPPER(TYPE('lexpdrives(1,1)'))<>"L" DIMENSION lexpdrives(1,2) lexpdrives(1,1)=.F. lexpdrives(1,2)=.F. ENDIF PRIVATE lcFloppy, lnFloppy lnFloppy=1 lcFloppy="A:\" FOR i = 0 TO 31 IF BITTEST(liDrivelist, i) * If the 0th bit is ON, that means drive 'A:', * the 2nd bit is 'C:", etc. lcDriveRoot = CHR(65 + i) + ":\" * Perform a GetDriveType to determine if it is a floppy, CD, etc. lcDrivetype = GetDriveType(lcDriveRoot) DO CASE CASE lcDrivetype = DRIVE_UNKNOWN lcDrivestring = "Cannot be determined" CASE lcDrivetype = DRIVE_NO_ROOT_DIR lcDrivestring = "Root directory does not exist" CASE lcDrivetype = DRIVE_REMOVABLE lcDrivestring = "Floppy/removable drive" CASE lcDrivetype = DRIVE_FIXED lcDrivestring = "Hard drive/nonremovable drive" CASE lcDrivetype = DRIVE_REM lcDrivestring = "Remote/Network drive" CASE lcDrivetype = DRIVE_CDROM lcDrivestring = "CD-ROM drive" CASE lcDrivetype = DRIVE_RAMDISK lcDrivestring = "RAM disk" ENDCASE lcDrives = lcDrives + lcDriveRoot + " " + lcDrivestring + CR IF UPPER(TYPE('lexpdrives(ALEN(lexpdrives,1),1)'))="L" lexpdrives(ALEN(lexpdrives,1),1)=lcDriveRoot lexpdrives(ALEN(lexpdrives,1),2)=lcDrivestring ELSE DIMENSION lexpdrives(ALEN(lexpdrives,1)+1,2) lexpdrives(ALEN(lexpdrives,1),1)=lcDriveRoot lexpdrives(ALEN(lexpdrives,1),2)=lcDrivestring ENDIF ENDIF NEXT =ASORT(lexpdrives) DIMENSION myarray(1,1) FOR i = 1 TO ALEN(lexpdrives,1) IF UPPER(TYPE('lexpdrives(i,2)'))="C" IF "FLOPPY" $ UPPER(lexpdrives(i,2)) IF INLIST(LEFT(UPPER(lexpdrives(i,1)),1),"A","B") IF UPPER(TYPE('myarray(ALEN(myarray,1))'))!="L" DIMENSION myarray(ALEN(myarray,1)+1,1) ENDIF myarray(ALEN(myarray,1))=lexpdrives(i,1) ENDIF ENDIF ENDIF ENDFOR IF ALEN(myarray,1)>1 *2 floppy drives FOR i = 1 TO ALEN(myarray,1) IF UPPER(ALLTRIM(lcFloppy))!=ALLTRIM(UPPER(myarray(i))) lcFloppy=lcFloppy+";"+myarray(i) ENDIF ENDFOR ELSE lcFloppy=UPPER(ALLTRIM(myarray(1))) ENDIF * lnFloppy=ASCAN(lexpdrives,'Floppy')-1 * lcFloppy=lexpdrives(lnFloppy) * =MESSAGEBOX(lcDrives, 0 + 64 + 0) RETURN lcFloppy