ORA_FFI

From: Frank Scheldeman <fscheldeman_at_roularta.be>
Date: Tue, 13 Feb 2001 16:02:48 +0100
Message-ID: <96bi77$uf9$1_at_news1.skynet.be>


Hello,

I've tried to pass a VARCHAR2(IN OUT defined) from a forms application(Forms 6.0.8.10.3)
to a Dll written in C windows compiled with borland c 5.01.

The dll received the variable, but when i change the variabele in the dll, the changes are not reflected in the forms application.

Here's a fragment:



PACKAGE BODY JUSTIFAPACKAGE IS
  lh_windows ora_ffi.libHandleType;
  fh_justifa ora_ffi.funcHandleType;

  PROCEDURE icd_justifa(funcHandle IN OUT ora_ffi.funcHandleType,

                  pZoekersTekst IN OUT VARCHAR2,
                  pJustCnf IN OUT VARCHAR2,
                  pLengteInMM IN OUT VARCHAR2);
                  PRAGMA interface(c, icd_justifa, 11265);


    [Quoted]
  • Op te roepen fuunctie vanuit PL/SQl block(in dat de geval de when [Quoted] button pressed PROCEDURE PJustifA(ZoekersTekst IN OUT VARCHAR2, JustCnf IN OUT VARCHAR2, LengteInMM IN OUT VARCHAR2) IS

[Quoted]       pZoekersTekst VARCHAR2(1000) := RPAD(SUBSTR(NVL(ZoekersTekst,'
'),1,1000),1000,CHR(0));

      pJustCnf VARCHAR2(257) := RPAD(SUBSTR(NVL(JustCnf,'
'),1,257),257,CHR(0));

      pLengteInMM VARCHAR2(25):= RPAD(SUBSTR(NVL(LengteInMM,'
'),1,25),25,CHR(0));
    BEGIN
    icd_justifa(fh_justifa, pZoekersTekst, pJustCnf, pLengteInMM);     END PJustifA;

  PROCEDURE Unloaden IS
  BEGIN

     Message('voor unload library');
     Message('voor unload library');
     ora_ffi.unload_library(lh_windows);
     Message('na unload library');
     Message('na unload library');

  END Unloaden;

PROCEDURE loadenn IS

      DllPath VARCHAR(100):='';
      DllNaam VARCHAR(100):='';

  BEGIN     lh_windows := ora_ffi.load_library('c:\ad-sell-it\justifa\', 'justifa.dll');

    fh_justifa := ora_ffi.register_function(lh_windows,'JustifA', ora_ffi.C_STD);

    ora_ffi.register_parameter(fh_justifa,ORA_FFI.C_CHAR_PTR);
    ora_ffi.register_parameter(fh_justifa,ORA_FFI.C_CHAR_PTR);
    ora_ffi.register_parameter(fh_justifa,ORA_FFI.C_CHAR_PTR);


  END loadenn;
END;



PACKAGE JustifAPackage IS
  PROCEDURE loadenn;
  PROCEDURE PJustifA(ZoekersTekst IN OUT VARCHAR2, JustCnf IN OUT VARCHAR2, LengteInMM IN OUT VARCHAR2);
  PROCEDURE Unloaden;
END;



Trigger from the pushbutton:

DECLARE
    ZoekersTekst
VARCHAR(1000):='<CS250,375,500,1000><CF1><AH><CC3.8><CP10><CL10>De tekst isaanden kensdfgsdfgs sdfsdsdf<QL>';

    --ZoekersTekst
VARCHAR(1000):='<CS250,375,500,1000><CF1><AH><CC13.8><CP10><CL10>aandenken<Q L>';

     JustCnf VARCHAR(257):='l:\ccci\just.cnf';
     LengteInMM VARCHAR2(25):='0000000000000000000000000';

BEGIN
  JUSTIFAPACKAGE.loadenn;

  • Message('0'); --Message('0');

   JUSTIFAPACKAGE.PJustifA(ZoekersTekst, JustCnf, LengteInMM);

   --Message('1');
   --Message('1');

   Message(LengteInMM);
   Message(LengteInMM);
   Message('Button justifa na justif');
   Message('Button justifa na justif');

   JUSTIFAPACKAGE.Unloaden;
END;

Part of the dll:

void FAR PASCAL JustifA(char *String, char *JustCnf, char *AantalMm) {
  float mm;
  char T[30];
  char *String2;

  JustifAinit(JustCnf);
  String2=(char *)malloc(strlen(String)*2);   String2[0]=0;
  It2Just2Z(String,String2,strlen(String)*2,JustPathJ);

  JustificatieAdSellIt(String2, JustCNF, &mm);   sprintf(T, "%f", mm);

  strcpy(AantalMm, TeBreedWoord);
  AantalMm[0]='d';
  AantalMm[1]='\0';
  JustCnf[0]='X';
  free(String2);
/* CloseJustifWindow();*/
}

AantalMm is to be changed, but LengteInMM in not changed in forms

Thanks for the help....

Frank Scheldeman
Email: fscheldeman_at_roularta.be
Email thuis: frank.scheldeman_at_pandora.be

--
Frank Scheldeman
Email: fscheldeman_at_roularta.be
Email thuis: frank.scheldeman_at_pandora.be
Received on Tue Feb 13 2001 - 16:02:48 CET

Original text of this message