Consultor Eletrônico



Kbase P38262: Crystal Report. CRPE32.DLL Call PESetNthTableLocation Corrup
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   21/08/2003
Status: Unverified

FACT(s) (Environment):

Progress 9.1D

FACT(s) (Environment):

Progress 8.3x

FACT(s) (Environment):

Crystal Reports 9

SYMPTOM(s):

Crystal Report. CRPE32.DLL Call PESetNthTableLocation Corrupts Memory Pointers (MEMPTR).

CAUSE:

When making a call in a 4GL program to PESetNthTableLocation in CRPE32.DLL while using Crystal Reports 9, When passing arguments to the Library you will find that the 2 first characters of the Mempry pointer you are using are corrupted after the call to the library.
Two first characters are replaced by some stranges characters.

To demonstrate this issue you can run the following code:

&scoped-define Dll-CrystalReport "CRPE32.DLL"
&scoped-define Dll-CrystalExport "crwrap32.dll"

define variable mPointerSource as MEMPTR no-undo .
define variable cDataSource as character no-undo.
define variable iTrouve as Integer no-undo .
define variable iCompteur as integer no-undo.
define variable cSource as Char no-undo.
define variable cValeurPointeur as char no-undo .
define variable iNumeroJob as integer no-undo.
define variable iCodeRetour as integer no-undo.

    cDataSource = 'f-ChemiseDMANAGER132.txt' .
    iTrouve = Num-Entries (cDataSource).
    iCompteur = 1.
    Do :    

       cSource = "C:\temp\test\f-ChemiseDMANAGER132.txt" .
       set-size (mPointerSource) = 75 .
      
       Put-String (mpointerSource,1) = "C:\temp\test\f-ChemiseDMANAGER132.txt".



   Assign
  cValeurPointeur = Get-String(mPointerSource,1) .
   message "before setNthTable and after the get-string cValeurPointeur =
" cValeurPointeur  view-as alert-box .

       Run PESetNthTableLocation (Input iNumeroJob,
                                  Input (iCompteur - 1),
                                  Input mPointerSource,
                                  OutPut iCodeRetour)
                                  .
   cValeurPointeur = Get-String(mPointerSource,1) .

   message "after setNthTable et apres le get-string cValeurPointeur =
" cValeurPointeur view-as alert-box .

   set-size (mPointerSource) = 0.
   end.

PROCEDURE PESetNthTableLocation EXTERNAL {&Dll-CrystalReport}:
     DEFINE INPUT PARAMETER PrintJob As Long .
     DEFINE INPUT PARAMETER TableN As Long .
     DEFINE INPUT PARAMETER PETableLocation As MEMPTR .  /* Struct */
     DEFINE RETURN PARAMETER CodeRetour As Long.
End Procedure.

FIX:

There is a workaround for the issue.

As MEMPTR can have several arguments, if you try with 2 arguments, with first argument the 2 first characters are corrupted, with second argument the first character is corrupted in the Memory Pointer.

So workaround consist in using 3 values in the Memory Pointer: i.e.


&scoped-define Dll-CrystalReport "CRPE32.DLL"
&scoped-define Dll-CrystalExport "crwrap32.dll"

define variable mPointerSource as MEMPTR no-undo .
define variable cDataSource as character no-undo.
define variable iTrouve as Integer no-undo .
define variable iCompteur as integer no-undo.
define variable cSource as Char no-undo.
define variable cValeurPointeur as char no-undo .
define variable iNumeroJob as integer no-undo.
define variable iCodeRetour as integer no-undo.


cDataSource = 'f-ChemiseDMANAGER132.txt' .
iTrouve = Num-Entries (cDataSource).
iCompteur = 1.
Do :

cSource = "C:\temp\test\f-ChemiseDMANAGER132.txt" .
set-size (mPointerSource) = 75 .

Put-String (mPointerSource,1) = "Pedro".
Put-String (mpointerSource,2) = "Mihai".
Put-String (mpointerSource,3) ="C:\temp\test\f-ChemiseDMANAGER132.txt".

Assign
cValeurPointeur = get-String(mPointerSource,3).
message "before setNthTable and after get-string cValeurPointeur =
" cValeurPointeur view-as alert-box .

Run PESetNthTableLocation (Input iNumeroJob,
Input (iCompteur - 1),
Input get-string(mPointerSource,3),
OutPut iCodeRetour).
cValeurPointeur = Get-String(mPointerSource,3).

message "after setNthTable and after the get-string cValeurPointeur =
" cValeurPointeur view-as alert-box .

set-size (mPointerSource) = 0.
end.

PROCEDURE PESetNthTableLocation EXTERNAL {&Dll-CrystalReport}:
DEFINE INPUT PARAMETER PrintJob As Long .
DEFINE INPUT PARAMETER TableN As Long .
DEFINE INPUT PARAMETER PETableLocation As char . /* Struct */
DEFINE RETURN PARAMETER CodeRetour As Long.
End Procedure.