Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7963585
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T05:38:28+00:00 2026-06-04T05:38:28+00:00

I’m facing difficulty when creating some kind of a report in vfp. I created

  • 0

I’m facing difficulty when creating some kind of a report in vfp. I created a text file, used the ?/?? command to write to the file, then opened it using web browser (OLE Object in vfp form).

Set Printer To 'C:\temp\test.txt'
set printer on
set console off

?? 'test'

and then i called my prg :

PARAMETERS pUrl

lcURL = pUrl
PUBLIC oForm
oForm = CREATEOBJECT('IEForm')
oForm.SHOW()
oForm.oIE.Navigate2(m.lcURL)
READ events

DEFINE CLASS IEForm AS FORM

   CAPTION = 'Report Preview'   
   HEIGHT = 512
   WIDTH = 792
   AUTOCENTER = .t.
   ADD OBJECT oIE AS OLECONTROL WITH ;
      HEIGHT=512,WIDTH=792,OLECLASS="Shell.Explorer",ANCHOR=195

   PROCEDURE oIE.REFRESH
   NODEFAULT
   ENDPROC

ENDDEFINE 

and used the C:\temp\test.txt as the url.

This works fine. But the problem occurs when I use fcreate to create the text file( not using the already existing text file)

 lcfile ='C:\temp\'+SYS(2015)+'.txt'
 lchandle=FCREATE(lcfile)
 Set Printer To lcfile

sometimes the problem occurs when using ? ( resulting in blank doc), and sometimes the browser can’t navigate to the file.

The second problem is : the browser can’t navigate to the text file if i set the windowtype property to modal in the IEform. I need to set it modal because I have to delay the rest of the execution until the preview form is closed.

I hope I described the situation clear enough.
Thank You for helping Me 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T05:38:29+00:00Added an answer on June 4, 2026 at 5:38 am

    I would avoid using SET PRINTER TO, and just use the fcreate(), fwrite() and fclose(), especially if writing a large amount of text. If only writing a small amount of data, I would just build one long string by just appending each component to the prior and add cr/lf instead of “?” for new lines, then write the entire result to a file ONCE via StrToFile(). This way, you don’t have to worry if things are actually closed (if you dont clear the set printer off, set printer to, or fclose(). Being an incomplete file, the browser won’t navigate since the file handle may be “locked” to read anything.

    Option 1 — building a string

    lcCRLF = chr(13)+chr(10)
    lcMyOutput = "Some Text to Start with" + lcCRLF ;
               + "Today is: " + dtoc( date() ) + lcCRLF
    
    use SomeTable
    scan
        lcMyOutput = lcMyOutput + "Some Field: " + SomeCharField;
           + "A numeric field: " + transform( SomeNumberField, "999,999.99" ) + lcCRLF
    endscan
    
    lcMyOutput = lcMyOutput + "All Done"
    
    lcOutputFile = "C:\Temp\" + sys(2015) + ".txt"
    StrToFile( lcMyOutput, lcOutputFile )
    

    Option 2 — using fcreate(), fwrite(), fclose()

    lnHandle = 0
    do while .t.
       lcOutputFile = "C:\Temp\" + sys(2015) + ".txt"
       lnHandle = fcreate( lcOutputFile )
       */ Only get out if we have a proper handle and thus
       */ we are exclusive to it for duration of our process
       if( lnHandle > 0 )
          exit
       endif
    enddo
    
    lcCRLF = chr(13)+chr(10)
    fwrite( lnHandle, "Some Text to Start with" + lcCRLF ;
                   + "Today is: " + dtoc( date() ) + lcCRLF )
    
    use SomeTable
    scan
        fwrite( lnHandle, "Some Field: " + SomeCharField;
               + "A numeric field: " + transform( SomeNumberField, "999,999.99" ) + lcCRLF )
    endscan
    
    fwrite( lnHandle, "All Done" )
    
    fclose( lnHandle ) 
    

    For running your “batch” file attempt with the RUN command, build the WHAT you want into a string, then run that… ex:

    lcCommandToRun = '"' + sys(5) + sys(2003) + '\Compress.tzs"'
    run ( lcCommandToRun )
    

    I don’t know if it was failing due to a space being in the path of your sys(2003) result turning the RUN into a multi-parameter interpretation, it would fail. By wrapping the entire text within double-quotes, it will prevent such “path” issue.

    ADDITIONAL FEEDBACK

    Trying to simulate a preview of a DOT-matrix printer using “?” to a text file is not something I would try. I would just do a standard report and draw it with all the data you are doing manually with the “?”. If the user want’s to preview the report, or send to a laser printer, let the normal report version handled through Windows for generation, font, and such do it for you. Leave the ancient code going to dot-matrix with whatever specific font rendering code as you have. I would just keep the actual report version CLOSE TO your “?” version.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a reasonable size flat file database of text documents mostly saved in
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I want use html5's new tag to play a wav file (currently only supported
In my XML file chapters tag has more chapter tag.i need to display chapters
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.