1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
|
**test program for Word Perfect Extraction**
USE C:\BSG\DATA\inspctn.dbf
*RECNO(188)
GO 188
SCAN WHILE RECNO() > 187 AND RECNO() < 200
generalFileName = "c:\TestFolder\" + inspctn.ciulkey
newFileName = generalFileName
IF (ISBLANK(inspctn.ciulkey))
inspectionDate = SUBSTR(STRTRAN(TTOC(inspctn.dinspdate), "/", "-"),1,8)
generalFileName = "c:\TestFolder\_" + STRTRAN(inspctn.cinspkey, " ", "") + "_" + STRTRAN(inspctn.cpermit, " ", "") + "_" + inspectionDate
newFileName = generalFileName
ENDIF
IF (ISBLANK(inspctn.Gnarrative) = .F.)
* USE C:\BSG\DATA\inspctn.dbf
*-- Locate some record containing non empty General field
&&LOCATE FOR !EMPTY(gnarrative)
COPY NEXT 1 FIELD gnarrative TO c:\TestFolder\testgen.dbf
lnH = FOPEN('testgen.dbf', 2)
= FSEEK(lnH,43)
IF FREAD(lnH,1) = "G"
= FSEEK(lnH,43)
= FWRITE(lnH,"M")
*? "Success"
ENDIF
= FCLOSE(lnH)
SELECT 0
USE c:\TestFolder\testgen.dbf
lcWPF = CHR(0xFF)+CHR(0x57)+CHR(0x50)+CHR(0x43)
lcWord = CHR(0xD0)+CHR(0xCF)+CHR(0x11)
DO CASE
CASE lcWPF $ gnarrative
lcDoc = SUBSTR(gnarrative, AT(lcWPF, gnarrative)-4, 4)
lnDocLen = ASC(lcDoc) + 256*ASC(SUBSTR(lcDoc, 2)) + 256*256*ASC(SUBSTR(lcDoc, 3)) + 256*256*256*ASC(SUBSTR(lcDoc, 4))
lcDoc = SUBSTR(gnarrative, AT(lcWPF, gnarrative), lnDocLen)
newFileName = FORCEEXT(newFileName, 'WPD')
= STRTOFILE(lcDoc, newFileName)
? RECNO('inspctn'), "WPF", newFileName
CASE lcWord $ gnarrative
lcDoc = SUBSTR(gnarrative, AT(lcWord, gnarrative)-4, 4)
lnDocLen = ASC(lcDoc) + 256*ASC(SUBSTR(lcDoc, 2)) + 256*256*ASC(SUBSTR(lcDoc, 3)) + 256*256*256*ASC(SUBSTR(lcDoc, 4))
lcDoc = SUBSTR(gnarrative, AT(lcWord, gnarrative), lnDocLen)
newFileName = FORCEEXT(newFileName, 'DOC')
= STRTOFILE(lcDoc, newFileName)
? RECNO('inspctn'), "Word", newFileName
OTHERWISE
*-- Unknown format
? RECNO('inspctn'), "Unknown format"
ENDCASE
USE
ENDIF
ENDSCAN
|