Question : export wordperfect 8 file to file from FoxPro General Field

this question follows a previous question that I posted last week. I am having issues getting a Word Perfect 8 file to export from foxpro to a file (of any type). I used the saveas of a word object to successfully save a word document from the same general field. but when I open the word perfect from the general field as an OLE object on a form and try to use the saveas, it doesnt do anything at all. I will include sample code below. the sample code works with MS Word documents, but not Word Perfect.

Thanks!
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
&& create the OLE object
loForm = CREATEOBJECT("Form")
			 
loForm.addobject("oleboundcontrol1", "oleboundcontrol") 

loForm.oleboundcontrol1.autosize = .T. 

* bind general field to oleboundcontrol 
loForm.oleboundcontrol1.controlsource = "inspctn.gnarrative" 

* save data from general field to a generic file type 
loForm.oleboundcontrol1.saveas("c:\TestFolder\" + inspctn.ciulkey + ".x")

Answer : export wordperfect 8 file to file from FoxPro General Field

I've updated the code posted previously and it should reflect the file size stored just before document heading in General field. It also adds extension to the output filename.
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
Random Solutions  
 
programming4us programming4us