Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to Save File Using FLUSH/Force or something Else
Message
From
15/12/2017 04:43:00
 
 
To
14/12/2017 12:40:50
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows 7
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01656416
Message ID:
01656453
Views:
74
*Foxypreviewer can translate any  txt file (even big one) to pdf (save this code as ytxt2pdf.prg)
*the txt file is divided into pages and passed to  a memo ytext of a cursor playing the role of dataenvironment of the report
*point to foxypreviewer location if its not already  loaded in memory.
*the output is a pdf file.
*the number of lines/page is important .if not good text can be troncated (to adjust).

Set Safe Off
Local m.yrep
m.yrep=Addbs(Justpath(Sys(16,1)))
Set Defa To (yrep)
*downlaod as demo a big book as txt file
*download one time abs save as txt file

#Define OLECMDID_SAVEAS 4
#Define OLECMDEXECOPT_DONTPROMPTUSER  2
Local apie
apie = Createobject('internetexplorer.application')
With apie
  .Navigate('http://www.fullbooks.com/Droll-Stories-Complete1.html')
  Do While.readystate#4  &&pass the transitionning (can put 5 sec in inke(5)).
  Enddo
  Inke(1)
  apie.ExecWB(OLECMDID_SAVEAS ,OLECMDEXECOPT_DONTPROMPTUSER,m.yrep+"Balzac.txt","")  &&there is a bug in IE11 the dialog shows always !
  .Quit
Endwith

Local m.maxl,i,j,N,m.xtext,m.cr,m.x
m.xtext=Filetostr("D:\Balzac.txt")
N=Alines(yArray,m.xtext,4)
m.cr=Chr(13)+Chr(10)

Create Cursor ycurs (ytext m)
Create Report ytemp   From  ycurs Width 1
*Modi Repo ytemp   &&if want to modify  /customize

m.j=1
m.x=""
m.maxl=33   &&35  &&lines per page

For m. i=1 To m.n
  m.x=m.x+Chr(9)+yArray[i]+Chr(13)
  If  m.j>=m.maxl
    Insert Into ycurs Values (m.cr+m.cr+m.x)
    m.j=1
    m.x=""
  Else
    m.j=m.j+1
  Endi
Endfor
If !Empty(m.x)
  Insert Into ycurs Values (m.cr+m.cr+m.x)   && last shuttle
Endi

Do Locfile("FoxyPreviewer.App")  &&dialog to pint to the app
Sele ycurs
*brow

* Make PDF
Report Form  asup.frx  Object Type 10 To File "asup.Pdf"   Preview

Return
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform