Solved

VFP Report writer preview.

Posted on 2011-02-17
10
689 Views
Last Modified: 2012-05-11
I am trying to print data from a memo field. I use MEMLINES() and MLINE() to put the data into an array.

The report has 60 fields and the EXPRession refers to the corresponding array element.

After 60 lines  are processed, the page is printed and  the array is cleared.

I recently had to work with a file created by another user. If I print from the preview screen it works fine. If I print directly to the printer, all I get is a blank page. No fileds, no labels: just a blank page.

I don't know for a fact that the memo was created within vfp with an EDITbox. It may have been done in a word processor and imported.  There may be some odd characters that are causing this. I can view the file for strange characters, but I don't know what to look for.

I packed the file by COPYing to TempFile, ZAPing and APPENDing FROM TempFile. No help, but the size reduced from 211,136 to 13,696 bytes.

I'm sorry I don't have more info, but any insight will be helpful.

Thanks,
Michael
0
Comment
Question by:MichaelKatz
  • 3
  • 3
  • 3
  • +1
10 Comments
 
LVL 42

Accepted Solution

by:
pcelba earned 167 total points
ID: 34915895
"If I print from the preview screen it works fine. If I print directly to the printer, all I get is a blank page."

Interesting behavior... typical for error in report definition but the preview should also be blank... It is almost impossible to help without your files.

The size reduction is obvious after file packing.

To remove "suspicious" characters from the memo you may use following code (but create a backup copy first!):


LOCAL cStr, i

FOR i = 1 TO 31
  cStr = cStr + IIF(i <> 13 AND i <> 10, CHR(i), '')
NEXT

REPLACE ALL YourMemo WITH CHRTRAN(YourMemo, cStr, '')

Open in new window

0
 
LVL 42

Expert Comment

by:pcelba
ID: 34915906
The FOR loop should also contain zero value:

FOR i = 0 TO 31
0
 
LVL 29

Expert Comment

by:Olaf Doschke
ID: 34916158
What's in the report data environment and are you sure you select the alias you want to print from?

Bye, Olaf.
0
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 

Author Comment

by:MichaelKatz
ID: 34916394
Hi Olaf,

There is nothing in the data environment. It uses a private data session.
If I add a memo to the table it works fine.

Another interesting thing I just discovered.
The memo had 60 lines . If I reduce to 59 it works.

I don't think this makes a difference, but I first copy the designed report to a TempFile in case it needs hacking for formatting purposes. The troublesome memoes do not require any changes to the file.

I also used a "Wait Window" immediately before the "REPORT FORM. . ." command to display the value of various array elements and they were correct. So, the values were there, but something apparently simply ejects the page.

I realize this is bit of a puzzle, but I have no idea why it happens.
I tried pcelba's reccommendation and it did not help. Strange though, each time i run it, the file gets bigger.

Michael


0
 
LVL 29

Assisted Solution

by:Olaf Doschke
Olaf Doschke earned 167 total points
ID: 34916560
Is there code in the detail band not only reading from the memo and creating the array but also writing back to the memo? Otherwise I wouldn't know why the data table should grow in size when you report from it.

If you actually at the command line do have the table selected and at runtime not, the case is clear, you only get a blank page because a record source is missing.

Even if all report fields are set to print an array element, a report always is controlled by the current active alias and the rpoert engine loops through all it's records printing a detail band for each record.

If no table is open and you have the array setup before printing, the report therefore still rpints nothing. What you need is a table with one record selected before issuing the REPORT FORM.

Bye, Olaf.

0
 

Author Comment

by:MichaelKatz
ID: 34916879
The table doesn't grow when reporting. I was referring to pcelba's code to clean it up. See above.  Each time I ran it, the file increased by about 12,000 bytes.

The detail band has 60 fields with the following expression:  Letterlines(1,2,3 etc.).

I get identical results from the runtime and development.

The report form command includes "NEXT 1" because the memo is a form letter that acts on 1 record at a time.

A table is open, and pointing to an appropriate record.  I get a blank page; no labels, no lines or anything.

As I mentioned above, I used a "Wait Window" immediately before the "REPORT FORM. . ." command to display the value of various array elements and they were correct. So, the values were there, but something apparently simply ejected the page.

Michael




0
 
LVL 42

Expert Comment

by:pcelba
ID: 34918897
It should be much easier to make a copy of the report and sample data, add the TXT extension and post it here.
0
 
LVL 12

Assisted Solution

by:jrbbldr
jrbbldr earned 166 total points
ID: 34919846
"There may be some odd characters that are causing this. I can view the file for strange characters, but I don't know what to look for."

Since each individual line should only have alphanumeric characters + space & punctuation characters (I am assuming here), then you could pre-process each individual line to remove any possible un-wanted characters.

One way would be to do a character-by-character check to see if its ASCII value fell between your allowed parameters.
lcOrigLine = <the input line>
nLen = LEN(lcOrigLine)
FOR CharCntr = 1 TO nLen
   cTestChar = SUBSTR(lcOrigLine,CharCntr,1)
   * --- Now Test ASCII Value of This Char ---
   IF !BETWEEN(ASC(cTestChar),32,126)
      * --- Remove Char If BAD ---
       lcOrigLine = STUFF(lcOrigLine,CharCntr,1,'')
      * --- Reset CharCntr so as to Test Next Char In Same Position ---
      CharCntr = CharCntr - 1
   ENDIF
ENDFOR

Another way might be something like:
lcOrigLine = <the input line>
* --- Get Char String Of BAD Characters In Line ---
lcX = CHRTRAN(lcOrigLine, "0123456789abcdefghijklmnopqrstuvwxyzABDDEFGHIJKLMNOPQRSTUVWXYZ .,'", "")
* --- Remove ALL Bad Characters from Line ---
lcNewLine = CHRTRAN(lcOrigLine, lcX, "")   && remove unwanted chars

CAVEAT - I have offered possible approaches to the code above, and have not actually run any of that code, so there may be typos, etc.

"No fileds, no labels: just a blank page."
Generally when you get a blank page, it is due to some reference in the Report Form not being found.

In the VFP Development Preview or Print mode, the missing reference is usually 'popped up' so that you can change/modify/correct the parameter.

In the Runtime Preview or Print mode it usually shows up as blank.

"If I print from the preview screen it works fine"
But I can't tell from that if you are in the Development environment when you run that test or not.

If not, then I'd try running the code in the Development mode and putting a SET STEP ON just prior to the REPORT FORM command.   Then I would go into the Command Window and either do a MODIFY REPORT followed by a PREVIEW or just manually run the REPORT FORM command from the Command Window.

Good Luck
0
 
LVL 29

Expert Comment

by:Olaf Doschke
ID: 34923954
It's normal that changing the memo increases it's size. The purpose of the code is to remove unwanted characters in the area of chr(0) to chr(31). But writing to memo always appends to the fpt file and invalidates the earlier pointer to a fpt file section. Only if you pack you see the shrinking of it, if there are such characters at all.

A blank report with no popup searching for a source, like jrbbldr describes simply misses records in the current workarea, then nothing is printed, not even labels, headers etc.

Bye, Olaf.
0
 

Author Comment

by:MichaelKatz
ID: 34924714
Thank you all.
This is what happened.

The memo had some function triggers that were surrounded by double angle brackets,
chr(171) and chr(187). These were picked from a list box.

Someone replaced them with 2 << and 2 >> , (the less than and greater than signs). The function calls were bypassed resulting in the wrong work area.

THANJ YOU ALL!

Michael
0

Featured Post

The New “Normal” in Modern Enterprise Operations

DevOps for the modern enterprise offers many benefits — increased agility, productivity, and more, but digital transformation isn’t easy, especially if you’re not addressing the right issues. Register for the webinar to dive into the “new normal” for enterprise modern ops.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Scrolling a grid 3 1,539
export vfp file to csv WITHOUT field names 2 628
Life afer Fox Pro 3 105
Is my syntax for locking records causing 'File is in use by another' errors? 11 144
Microsoft Visual FoxPro (short VFP) is a programming language with it’s own IDE and database, ranking somewhat between Access and VB.NET + SQL Server (Express). Product Description: http://msdn.microsoft.com/en-us/vfoxpro/default.aspx (http://msd…
This article describes my battle tested process for setting up delegation. I use this process anywhere that I need to setup delegation. In the article I will show how it applies to Active Directory
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question