Recent

Author Topic: Compatibility problem  (Read 459 times)

Janfi

  • New member
  • *
  • Posts: 9
Compatibility problem
« on: May 29, 2020, 10:31:55 pm »
Hello everybody,

I did write a software with Lazarus 2.02 that worked perfectly.
This software is in 2 parts who communicate throught a file

On first side I wrote a DLL on windows 32 bits (virtual machine on Linux)
On second side I write an application in Linux 64 bits

The DLL is called in a language called MQL4
My application is a sort of debugger for MQL4

I updated Windows and Linux Lazarus to 2.08 and my application does not work properly, it looks like the file in the middle of the 2 parts is not seen same by each side.

Maybe word alignment change or byte alignment or ???

If someone has an idea, it is welcome.
Thanks

Jean-Philippe

the structure :

Type T_Exchange = RECORD
                    Case integer OF
                        0 : ( Nbr_rec         : Int64;
                              Symbol          : String[20];
                              TimeFrame       : String[20]  );
                        1 : ( semaphore       : Boolean;
                              CheckBoxA       : Boolean;
                              CheckBoxB       : Boolean;
                              CheckBoxC       : Boolean;
                              CheckBoxD       : Boolean;
                              CheckBoxE       : Boolean    );
                        2 : ( ligne           : Array[0..255] of widechar );

                  END; 

DLL side
//------------------------------------------------------------------------------
PROCEDURE dbgopenfile (mode : integer);   cdecl;
begin                           // mode = 0 : read only   1 = write  2 = create
  if mode = 0 then
     filemode :=  fmOpenRead + fmShareDenyNone
  else
    filemode :=  fmOpenReadWrite + fmShareDenyNone;

  if mode = 2 then
    Rewrite (FileExchange);
  //else
  Reset (FileExchange);
end;                         


Linux Side
//------------------------------------------------------------------------------
PROCEDURE dbgopenfile (mode : integer);
VAR cnt, result : integer;
begin                           // mode = 0 : read only   1 = write
  if mode = 0 then
     filemode :=  fmOpenRead + fmShareDenyNone
  else
    filemode :=  fmOpenReadWrite + fmShareDenyNone;

  cnt := 0;
  REPEAT
    {$I-}
    Reset (FileExchange);
    {$I+}
    inc(cnt);
    result := IOResult;
    if result > 0
      then sleep(500);
  UNTIL (result = 0) OR (cnt = 5);

  IF Result <> 0 THEN
     BEGIN
        Beep;
        Sleep (2000);
        Halt;
     END;
{      en cours de mise au point
  Read_BreakPoints;
  BreakPoints.semaphore := false;
  BreakPoints.CheckBoxA := true;
  BreakPoints.CheckBoxB := true;
  BreakPoints.CheckBoxC := true;
  BreakPoints.CheckBoxD := true;
  BreakPoints.CheckBoxE := true;
  Write_BreakPoints; }
end;                           

jamie

  • Hero Member
  • *****
  • Posts: 3528
Re: Compatibility problem
« Reply #1 on: May 30, 2020, 04:02:25 am »
I was going to say the version of the compiler but I just checked my old W2k PC with has 2.0.0 on it and it is used 3.0.4 compiler

  The problem you are describing seems like it could be compiler version related.

 maybe you need to PACK  your record and Use the FLUSH on the IO functions ?

 Looks like you are not closing your file after each write,, that may cause data to not be sent on time.



The only true wisdom is knowing you know nothing

ASerge

  • Hero Member
  • *****
  • Posts: 1671
Re: Compatibility problem
« Reply #2 on: May 30, 2020, 10:00:15 am »
What is FileExchange? Where read and write operation?

Janfi

  • New member
  • *
  • Posts: 9
Re: Compatibility problem
« Reply #3 on: June 15, 2020, 02:39:18 pm »
Hello, I come back with my problem.

Is TStringGrid has been modified ? the problem is maybe not reading file but on the display side. When I use the lazarus debugger, I can see my record and i looks to be correct.

The problem looks to be here :

(GridVariables is a TStringGrid where I place variables of MQL4 language) Name, Type, Value, Comment and the key for updating is Name, Type and Comment

Procedure TForm1.LookUpVar(Sender: TObject; KW : UnicodeString);
 BEGIN
   i := 0;  b := false;
   Repeat
     inc(i);
     if (i > GridVariables.RowCount-1) then
       begin
         GridVariables.InsertRowWithValues(i,['','','','']);
       end;
     if (GridVariables.Cells[0,i] = KW)  AND
        (GridVariables.Cells[1,i] = Champs(ligne.ligne,2))   AND
        (GridVariables.Cells[3,i] = Champs(ligne.ligne,4)) THEN b := true
     else
        if GridVariables.Cells[0,i] = '' then b := true;
     Until (b);

     GridVariables.Cells[0,i] := KW;
     GridVariables.Cells[1,i] := Champs(ligne.ligne,2);
     GridVariables.Cells[2,i] := Champs(ligne.ligne,3);
     GridVariables.Cells[3,i] := Champs(ligne.ligne,4);
 END;                                           

 

TinyPortal © 2005-2018