Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Visual Documents 2.0 categories in report crashs program
Message
From
02/01/2003 19:23:09
Michael Gass
Instructional Software, Inc.
Kirkland, Washington, United States
 
 
To
31/12/2002 04:46:07
General information
Forum:
Visual FoxPro
Category:
CodeMine
Miscellaneous
Thread ID:
00736473
Message ID:
00737565
Views:
19
I moved a template out of a memo field to create an RTF file like you had suggested. When I tried the code it gave the following error:
Error found in paragraph 1 at tab "<<TR>>"
Not a valid RTF file - no header found
So I used an RTF file for the report that I’m having the most problems with and I’m loading it directly into the data stream using your suggested code. It didn’t change the behavior but your suggestions have drastically increased the pace of my debugging sequence. I’m getting nowhere much faster now. Seriously, I do appreciate not having to take so much time for each re-try. It has also eliminated the possibility of the problem dealing with copying the RTF file into the memo field or getting the template out of the memo field and into the data stream. It must be in my code or in the template.

I have noticed that the temporary file is increasing the paragraph numbers between category loops by double the previous difference in numbers or more. So for small reports it works fine. On longer reports it slows down more and more each time through the category loop.

The current report that I’m trying to run uses a table. The entire table is copied for category groups with a category title at the top of the report. The detail that’s copied consists of a row with about six columns. The first column is a persons name with an ‘X’ that’s inserted where appropriate for each column. So, obviously, there’s also heading for each row that is being copied in the 'Category copy' as well.

When I run it without any modifications it goes through the enter process quickly without any slow down but the report is totally messed with all of the category titles lumped together and all of the details lumped together in single cells under each column header.

When I include a blank TAG in front of the name category the report looks fine but it takes forever to print. Strange???

Here is the code that I’m using for this report: Please let me know if you notice anything wrong. Once again, thanks for your time and help.
LOCAL cLastCategory, cLastItem, category, iz, oProgress, THERMCT
m.cLastCategory = ''
m.cLastItem = ''
m.category = ''
SELECT Offallco3
COUNT ALL TO THERMCT
m.oProgress = THISFORM.oMessage.ProgressBar('Processing ' + ALLTRIM(Offallco3.Fullname))
m.oProgress.SetProgressRange(1,THERMCT)
m.iz = 1

GO TOP
DO WHILE ! EOF()
category = ALLTRIM(Offallco3.Fullname)
* Make a new copy of the entire detail group when the category
* changes, except for the very first time.
IF ! EMPTY(m.cLastCategory) AND (! m.cLastCategory == category)
    m.ortf.CopyGroup(m.nStream, 'Category', 'Item')
    * Copying the entire group will also create a new item row, since
    * the item row is in the range of tags specified in CopyGroup().
ENDIF
* Insert text for the new category when the category changes
IF ! m.cLastCategory == category
    m.cLastCategory = category
    m.ortf.InsertText(m.nStream, 'Category',  CHR(13) + TRIM(category))
ENDIF
                
SCAN WHILE ALLTRIM(m.cLastCategory) = ALLTRIM(Offallco3.Fullname)
IF ortf.IsDirty(m.nStream, 'Item')
    ortf.Copyrow(m.nStream, 'Item')
ENDIF
                    
m.oProgress.UpdateProgress(m.iz)
m.oProgress.SetProgressMessage('Processing ' + ALLTRIM(category))
m.iz = m.iz + 1
temp = ALLTRIM(Offallco3.Orgname)
**m.ortf.InsertText(m.nstream, 'xx', '- ')  &&  MOVES data in base table TO STREAM
m.ortf.InsertText(m.nstream, 'Item', temp)  &&  MOVES data in base table TO STREAM

IF Offallco3.Chair = .T.
    m.ortf.InsertText(m.nstream, 'CH', 'X')  &&  MOVES data in base table TO STREAM
ENDIF
IF Offallco3.Dir = .T.
    m.ortf.InsertText(m.nstream, 'DI', 'X')  &&  
ENDIF
IF Offallco3.Pres = .T.
    m.ortf.InsertText(m.nstream, 'PR', 'X')  &&  
ENDIF
IF Offallco3.Vicepres = .T.
    m.ortf.InsertText(m.nstream, 'VP', 'X')  &&  
ENDIF
IF Offallco3.Sec = .T.
    m.ortf.InsertText(m.nstream, 'SC', 'X')  &&  
ENDIF
IF Offallco3.Tres = .T.
    m.ortf.InsertText(m.nstream, 'TR', 'X')  &&  
ENDIF

ENDSCAN
                
SELECT Offallco3
ENDDO
m.oProgress.CloseProgress()
>>I save the template using MS Word in an RTF file then open the file using Windows Notepad. I copy the content from the Notepad and paste it into a memo field.
>
>OK. As you are doing it this way, you could try using :-
>
>
>Replace REPTTMPL.Template With FileToStr(cFileName)
>
>
>This would be much cleaner. However, the point is that you are putting the whole RTF content into the memo file and then using the VisDocs LoadTemplate method, right?
>
>>I'm loading the template into the datastream from the memo field using the following command:
>>
>>m.nstream = m.ortf.loadtemplate(REPTTMPL.Template)
>
>Can I suggest that you try the following approach :-
>
>
>*1. Create a temporary file name and write the RTF data in REPTTMPL.Template out to a disk file.
>m.cTempFile = forceExt(Substr(Sys(2015),3), 'RTF')
>=StrToFile(REPTTMPL.Template, m.cTempFile)
>*2. Open the tempfile as follows using the loadTemplateFile method (not the loadTemplate method)
>m.nStream = m.oRtf.loadTemplateFile(m.cTempFile)
>
>
>Obviously, you need to delete the temporary file you have created after it has been loaded into your application.
>
>Before we go any further, try the above approach and see what (if anything) happens when you run a troublesome report.
>
>Best
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform