Programming (VFP8): Conundrum

Ask the few things google does not know

Moderator: Dictators in Training

Programming (VFP8): Conundrum

Postby horendus » Wed May 25, 2005 5:14 am

I have been pulling my hair out here.

Scenario:
VFP8
Win2k
Reports containing ActiveX Bound Control
Barcode ActiveX control: IDAutomation PDF417 (IDAuto.PDF417)
| %SYSTEM32%\IDAutomationPDF417e.dll
| (http://www.idautomation.com)

----

The report basically prints bills/notices/etc (various mail outs). The
OLE Bound Control displays an Image generated on the fly by a
procedure.

There can be as many as 5000 records (or more), therefore 5000+ General
fields. We have tried this several ways - the first of which was to
create a general field in the cursor used in the report. That made the
cursor enormous, so we decided to go with a function call that creates
a single field, single record cursor - here is the function used to
create the barcode cursor:

Code: Select all

FUNCTION PopulateBarCode
        LPARAMETER tcBarCodeVal
        LOCAL lcOldCursor

        * Save the old cursor to local var for later
        STORE ALIAS() TO lcOldCursor

        * Check for previously opened cursor, if open close
        IF USED("cur_barcode") = .T. THEN
                close_cursor("cur_barcode")
        ENDIF

        * Create cursor add the class
        CREATE CURSOR cur_barcode (barcode G)
        APPEND BLANK
        APPEND GENERAL barcode CLASS ("IDAuto.PDF417")

        * This is the best way we could come up with for this.
        frmTemp = CreateObject("Form")
        frmTemp.AddObject("BarCode", "OLEBoundControl")
        frmTemp.BarCode.ControlSource = "cur_barcode.barcode"

        * Refresh to assure we are on the right record, then assign the data.
        frmTemp.BarCode.Refresh()
        frmTemp.BarCode.Object.DataToEncode = tcBarCodeVal

        * Get rid of the objects
        frmTemp.RemoveObject("BarCode")
        frmTemp.Release()

        * Return to original cursor
        SELECT &lcOldCursor

ENDFUNC



In the report there is an ActiveX OLE Bound Control with the field set
to cur_barcode.barcode, before that there is a call to
PopulateBarCode(ALLTRIM(barcodedata)).

Everything works fine to generate the reports, the problem arises when
we try to print (Printer or Adobe PDF driver) where it prints up until
about 3100-3300 pages (front and back, 1600+- actual records, then it
bombs throwing the infamous C0000005 fatal error code. Normally the
error looks similar to the following:

<pre>
Fatal error: Exception code=C0000005 @ DATETIMESTAMP. Error log file:
C\Program Files\Common Files\Microsoft Shared\VFP\vfp8rerr.log
Called from - populatebarcode line 0 {mail_shared.fxp}
[rest of call stack]
</pre>

A co-worker reported the same error which specified the same thing,
except in the call stack entries:

<pre>
Fatal error: Exception code=C0000005 @ DATETIMESTAMP. Error log file:
C\Program Files\Common Files\Microsoft Shared\VFP\vfp8rerr.log
Called from - populatebarcode line 602 {mail_shared.fxp}
[rest of call stack]
</pre>

Line 602 coincides with the APPEND GENERAL statement. So my thoughts on
this is that somehow, even though we are closing the cursor if it
exists, and destroying any objects we create, something is lingering in
memory somehow.

I have also added to the beginning of the PopulateBarCode() function:
Code: Select all
        CLEAR RESOURCES

Which *should* clear out any cached images from memory and reload them
as they are used. All in all, this logically should create the barcode
image for each page of the report and not store any previous pages
barcodes in memory. The General field type, from my understanding, not
only stores the Object and Image data, but also quite a bit of
overhead.

An idea I had was to use the IDAuto.PDF417 objects
.SaveBarCode(cFilePath) method to write out a barcode to a temp file
with the constant name of curbarcode.wmf (it only saves to Windows
Metafile format), then assigning the OLEBoundControl on the report to
that filename. The result is no error, but also no barcode.

I guess the question of the moment is: Has anyone come across similar
situations; if so, are there any ways around this.

There must be a better way around this. Any help would be greatly
appreciated.
<img src="http://images.station.sony.com/qfa/000/000/000/490.jpg">
<a href="http://eq2players.station.sony.com/en/pplayer.vm?characterId=115183108">Deykann Scalerot</a>
<a href="http://www.magelo.com/eq_view_profile.html?num=1091726" target="_blank">Horendus Gutwrencher</a> - Dark Knight of Cuteness
horendus
NT Veteran
NT Veteran
 
Posts: 1139
Joined: Thu Aug 26, 2004 6:11 am
Location: FL

Postby Lyion » Wed May 25, 2005 5:22 am

Its been so long since I've touched Foxpro and I am a Unix/Oracle guy, and I'm unsure exactly what your problem is. Is it just printing?

Horendus wrote:Everything works fine to generate the reports, the problem arises when
we try to print (Printer or Adobe PDF driver) where it prints up until
about 3100-3300 pages (front and back, 1600+- actual records, then it
bombs throwing the infamous C0000005 fatal error code. Normally the
error looks similar to the following:


Why not cat it into 3 separate print jobs to try and bypass this problem? That's somewhat a crude fix, but whatever works.
What saves a man is to take a step. Then another step.
C. S. Lewis
User avatar
Lyion
Admin Abuse Squad
Admin Abuse Squad
 
Posts: 14376
Joined: Wed Mar 10, 2004 1:42 pm
Location: Ohio

Postby kaharthemad » Wed May 25, 2005 7:50 am

I would agree with Lyion o this one. I started in FoxPro before I shed most of the programming for straight networking and hardware. However the break down into 3 print jobs which will parse down. Alot of people have this problem in VFP looking at the MS website. According to Microsoft it is a fuckup with VFP 6.0. However I am still not able to find a fix. Ill keep looking for you.
Image
User avatar
kaharthemad
NT Traveller
NT Traveller
 
Posts: 3768
Joined: Sat Mar 27, 2004 8:47 am
Location: Somewhere South of Disorder

Postby horendus » Wed May 25, 2005 10:59 am

I've been looking all over for similar situations and what people have done to rectify it.

While the problem is in the printing portion of it, it also lies in the generation of the data as well. We are imlpementing this barcode on all of our prints which span over many many procedures (usually about one for each bill/notice type) the integration of this barcode needs to work with current reports with as little modification as possible, which is why I have the PopulateBarCode procedure.

THe problem lies in the GENERAL field type, at least from what I see on my end and have read from others.

I am still working on fixing this, but each test run I do takes about 30-45 minutes before it blows up, so it's a SLOW process of trial and error. =/

Another option I am investigating is outputting the image to a file and displaying that image in the ole control, this works, but there is a slight problem. VFP needs to load images by unique file name, otherwise it uses its cached copy to display. The CLEAR RESOURCES doesn't work. So I use a "barcode_" + GUID + ".wmf" as the file name, storing it to a temp cursor and deleting it at the beginning on the next procedure call. THe problem here is that the last one to run remains since the procedure doesnt get called again.

This will, over time, build up to quite a few image files on the users disk. One solution for that would be to possible just delete for any barcode_*.wmf that way every time it is run it gets rid of any residual barcode files.

I may try that when I get back to work.
<img src="http://images.station.sony.com/qfa/000/000/000/490.jpg">
<a href="http://eq2players.station.sony.com/en/pplayer.vm?characterId=115183108">Deykann Scalerot</a>
<a href="http://www.magelo.com/eq_view_profile.html?num=1091726" target="_blank">Horendus Gutwrencher</a> - Dark Knight of Cuteness
horendus
NT Veteran
NT Veteran
 
Posts: 1139
Joined: Thu Aug 26, 2004 6:11 am
Location: FL


Return to Tech Support

Who is online

Users browsing this forum: No registered users and 22 guests