VPE and Openedge

marymcmahon

New Member
Hi, We used VPE(Virtual Print Engine) from idealsoftware to print rtf docs in v9.0b. We now have to upgrade to Openedge 10.1b. Does anyone know if there will be any problems with VPE?

TIA
 

FrancoisL

Member
Between version 9.0b and 10.1B the .WRX generated by OCX has been changed to support Unicode.

What this means is that any WRX generated by 9.1E or higher will not be compatible with version 9.0B .

This is the only known problem that you can encounter with VPE while working in 10.1B ... So if you generate your WRX with 10.1B you will not be able to install it at a client still using 9.0B . This only apply if you have to deploy your 10.1B app to a 9.0B client.
 

TimBloom

New Member
Hello,

I've been tasked with getting VPE to generate reports on the Appserver instead of the client. Since VPE's stated OCX implementation needs a GUI window open to be attached to, using the DLL library is the logical direction. I had a heck of a time getting it to work until I googled to this post, but then checked other threads too. The first external procedure used must be defined as "persistent" and later closed so that the returned handles stay in the library's memory.

While it will take some macro-magic to convert the hundreds of reports, I'm sure it will be faster and more reliable, as well as able to run in batch mode.

Here's my demo code:

Code:
/* --------------------------------------------------------
*   File: vpe.p -- Demo VPE/dll access in Progress ABL 4GL.
*---------------------------------------------------------*/
/* ******  Definitions  ************************** */
/* Install VPE so the DLL is Registered */
&SCOP dll_file "vpep3240.dll"
/* {vpe.i} */
/* Only including what's used for demo */
&GLOB     VPE_FIXED_MESSAGES 131072
&GLOB     VUNIT_FACTOR_CM 100000
&GLOB     VUNIT_FACTOR_INCH 254000
&GLOB     VUNIT_FACTOR_MM10 1000
DEF VAR rReport      AS CHARACTER     NO-UNDO.
DEF VAR intError     AS INTEGER       INITIAL 0 NO-UNDO.
DEF VAR decLastPosXY AS DECIMAL       NO-UNDO.
DEF VAR decUnit1     AS DECIMAL       NO-UNDO.
DEF VAR decUnit2     AS DECIMAL       NO-UNDO.
DEF VAR decX         AS DECIMAL       NO-UNDO.
DEF VAR decY         AS DECIMAL       NO-UNDO.
DEF VAR decX2        AS DECIMAL       NO-UNDO.
DEF VAR decY2        AS DECIMAL       NO-UNDO.
DEF VAR hRptHdl      AS INTEGER       NO-UNDO.
DEF VAR hDocHdl      AS INT64         NO-UNDO INIT -1.
DEF VAR intFlag      AS INTEGER       NO-UNDO.
DEF VAR hWnd AS INTEGER NO-UNDO. /* OK to keep zero */
/* Constants sometimes need to be decimals, not literals */
DEFINE VAR VPE_FIXED_MESSAGES AS INTEGER  INITIAL {&VPE_FIXED_MESSAGES} NO-UNDO.
DEFINE VAR VUNIT_FACTOR_MM10  AS DECIMAL  INITIAL {&VUNIT_FACTOR_MM10} NO-UNDO.
DEFINE VAR VUNIT_FACTOR_INCH  AS DECIMAL  INITIAL {&VUNIT_FACTOR_INCH} NO-UNDO.
 
/* ***************************  Main Block  *************************** */
ASSIGN decX  = 1
       decY  = 1
       decx2 = 7
       decY2 = 5
       rReport = "c:\temp\vpeTestRpt.vpe".
MESSAGE "Prior to VpeOpenDocFile" SKIP
        "VPE_FIXED_MESSAGES" {&VPE_FIXED_MESSAGES} VIEW-AS ALERT-BOX.
RUN VpeOpenDocFile (OUTPUT hDocHdl, 0, rReport, "Title", {&VPE_FIXED_MESSAGES}).
/*
MESSAGE "Prior to VpeOpenDoc"
        SKIP "hWnd" hWnd
        SKIP "VPE_FIXED_MESSAGES" {&VPE_FIXED_MESSAGES} VIEW-AS ALERT-BOX.
RUN VpeOpenDoc
   (OUTPUT hDocHdl, hWnd, "Title", {&VPE_FIXED_MESSAGES}).
*/
IF hDocHdl = 0 THEN /* VpeOpenDoc returns a handle */
DO:
   MESSAGE "Document Handle Returned zero."
      SKIP "This is means the OpenDoc method"
      SKIP "encountered an error. Returning."
   VIEW-AS ALERT-BOX.
   RETURN.
END.
/*
MESSAGE "Prior to VpeLicense"
        SKIP "Output hDocHdl: " hDocHdl
        VIEW-AS ALERT-BOX.
RUN VpeLicense (INPUT hDocHdl,
                INPUT "VPE-P2400-xxxx",
                INPUT "xxxx-xxxx").
*/
MESSAGE "Prior to VpeGetLastError"
        SKIP "Output hDocHdl: " hDocHdl
        VIEW-AS ALERT-BOX.
RUN VpeGetLastError (OUTPUT intError, hDocHdl).
MESSAGE "Prior to VpeGetUnitTransformation (1)"
        SKIP "Returned from VpeGetLastError: " intError
        SKIP "hDocHdl: " hDocHdl
        SKIP "VUNIT_FACTOR_INCH" {&VUNIT_FACTOR_INCH}
        SKIP "decUnit1" decUnit1
        SKIP "decUnit2" decUnit2
        VIEW-AS ALERT-BOX.
RUN VpeGetUnitTransformation (OUTPUT decUnit1, INPUT hDocHdl).
MESSAGE "Prior to VpeSetUnitTransformation"
        SKIP "hDocHdl: " hDocHdl
        SKIP "VUNIT_FACTOR_INCH" {&VUNIT_FACTOR_INCH}
       SKIP "decUnit1" decUnit1
        SKIP "decUnit2" decUnit2
        VIEW-AS ALERT-BOX.
RUN VpeSetUnitTransformation (hDocHdl, VUNIT_FACTOR_INCH ).
MESSAGE "Prior to VpeGetUnitTransformation (2)"
        SKIP "hDocHdl: " hDocHdl
        SKIP "VUNIT_FACTOR_INCH" {&VUNIT_FACTOR_INCH}
        SKIP "decUnit1" decUnit1
        SKIP "decUnit2" decUnit2
        VIEW-AS ALERT-BOX.
RUN VpeGetUnitTransformation (OUTPUT decUnit2, INPUT hDocHdl).
 
MESSAGE "Prior to VpeWrite"
        SKIP "hDocHdl: " hDocHdl
        SKIP "VUNIT_FACTOR_INCH" {&VUNIT_FACTOR_INCH}
        SKIP "decUnit1" decUnit1
        SKIP "decUnit2" decUnit2
        VIEW-AS ALERT-BOX.
RUN VpeWrite (OUTPUT decLastPosXY, hDocHdl, decX, decY, decX2, decY2,
              "Hello World").
MESSAGE "Prior to VpeWriteDoc" VIEW-AS ALERT-BOX.
RUN VpeWriteDoc (OUTPUT intError, hDocHdl, rReport).
/* VpeCloseDoc returns with an intError = 1.
** But the file was generated. */
MESSAGE "Prior to VpeCloseDoc" VIEW-AS ALERT-BOX.
RUN VpeCloseDoc (OUTPUT intError, hDocHdl).
MESSAGE "Procedure Completed"
        SKIP "intError" intError
        SKIP rReport SEARCH(rReport) VIEW-AS ALERT-BOX.
/* Important or Server go boom on go-live :) */
RELEASE EXTERNAL {&dll_file}.
RETURN. /* External API procedure definitions follow */
 
/* Don't bother with CDECL */
/*Define the VpeOpenDocFile() method*/
PROCEDURE VpeOpenDocFile EXTERNAL {&dll_file} PERSISTENT:
  DEFINE RETURN PARAMETER hDocHdl    AS LONG      NO-UNDO.
  DEFINE INPUT  PARAMETER hWindow    AS LONG      NO-UNDO.
  DEFINE INPUT  PARAMETER pReport    AS CHARACTER NO-UNDO.
  DEFINE INPUT  PARAMETER chrTitle   AS CHARACTER NO-UNDO.
  DEFINE INPUT  PARAMETER LongFlags  AS LONG      NO-UNDO.
END PROCEDURE.
/*Define the VpeOpenDoc() method*/
PROCEDURE VpeOpenDoc EXTERNAL {&dll_file} PERSISTENT:
  DEFINE RETURN PARAMETER hDocHdl    AS LONG      NO-UNDO.
  DEFINE INPUT  PARAMETER hWindow    AS LONG      NO-UNDO.
  DEFINE INPUT  PARAMETER chrTitle   AS CHARACTER NO-UNDO.
  DEFINE INPUT  PARAMETER LongFlags  AS LONG      NO-UNDO.
END PROCEDURE.
/*Define the VpeSetUnitTransformation() method*/
PROCEDURE VpeSetUnitTransformation EXTERNAL {&dll_file}:
  DEFINE INPUT   PARAMETER hReport   AS LONG NO-UNDO.
  DEFINE INPUT   PARAMETER dblFactor AS DOUBLE    NO-UNDO.
END PROCEDURE.
/*Define the VpeGetUnitTransformation() method*/
PROCEDURE VpeGetUnitTransformation EXTERNAL {&dll_file}:
  DEFINE RETURN PARAMETER dblFactor AS DOUBLE    NO-UNDO.
  DEFINE INPUT  PARAMETER hDoc      AS LONG NO-UNDO.
END PROCEDURE.
/*Define the VpeWrite() method*/
PROCEDURE VpeWrite EXTERNAL {&dll_file}:
  DEFINE RETURN PARAMETER intLastPOS AS DOUBLE    NO-UNDO.  /*dec*/
  DEFINE INPUT  PARAMETER hReport    AS LONG NO-UNDO.
  DEFINE INPUT  PARAMETER intPOSX    AS DOUBLE    NO-UNDO.  /*dec*/
  DEFINE INPUT  PARAMETER intPOSY    AS DOUBLE    NO-UNDO.  /*dec*/
  DEFINE INPUT  PARAMETER intPOSX2   AS DOUBLE    NO-UNDO.  /*dec*/
  DEFINE INPUT  PARAMETER intPOSY2   AS DOUBLE    NO-UNDO.  /*dec*/
  DEFINE INPUT  PARAMETER chrTEXT    AS CHARACTER NO-UNDO.
END PROCEDURE.
/*Define the VpeWriteDoc() method*/
PROCEDURE VpeWriteDoc EXTERNAL {&dll_file}:
  DEFINE RETURN PARAMETER intError   AS SHORT NO-UNDO.
  DEFINE INPUT  PARAMETER hReport    AS  LONG NO-UNDO.
  DEFINE INPUT  PARAMETER chrFile    AS CHARACTER NO-UNDO.
END PROCEDURE.
/*Define the VpeCloseDoc() method*/
PROCEDURE VpeCloseDoc EXTERNAL {&dll_file}:
  DEFINE RETURN PARAMETER intError   AS SHORT NO-UNDO.
  DEFINE INPUT  PARAMETER hReport    AS LONG  NO-UNDO.
END PROCEDURE.
/*Define the VpeGetLastError() method*/
PROCEDURE VpeGetLastError EXTERNAL {&dll_file}:
  DEFINE RETURN PARAMETER intError   AS LONG NO-UNDO.
  DEFINE INPUT  PARAMETER hDoc       AS LONG NO-UNDO.
END PROCEDURE.
/*Define the VpeLicense() method*/
PROCEDURE VpeLicense EXTERNAL {&dll_file}:
  DEFINE INPUT  PARAMETER hDoc       AS LONG NO-UNDO.
  DEFINE INPUT  PARAMETER serial1    AS CHARACTER NO-UNDO.
  DEFINE INPUT  PARAMETER serial2    AS CHARACTER NO-UNDO.
END PROCEDURE.

Be well all! -- Tim
 
Top