* * * *

Privacy Policy

Blog italiano

Clicca qui se vuoi andare al blog italiano su Lazarus e il pascal.

Forum ufficiale

Se non siete riusciti a reperire l'informazione che cercavate nei nostri articoli o sul nostro forum vi consiglio di visitare il
Forum ufficiale di Lazarus in lingua inglese.

Lazarus 1.0

Trascinare un file nel programma
DB concetti fondamentali e ZeosLib
Recuperare codice HTML da pagina web
Mandare mail con Lazarus
Stabilire il sistema operativo
Esempio lista in pascal
File INI
Codice di attivazione
Realizzare programmi multilingua
Lavorare con le directory
Utilizzare Unità esterne
TTreeView
TTreeview e Menu
Generare controlli RUN-TIME
LazReport, PDF ed immagini
Intercettare tasti premuti
Ampliare Lazarus
Lazarus e la crittografia
System Tray con Lazarus
UIB: Unified Interbase
Il file: questo sconosciuto
Conferma di chiusura di un applicazione
Liste e puntatori
Overload di funzioni
Funzioni a parametri variabili
Proprietà
Conversione numerica
TImage su Form e Panel
Indy gestiore server FTP lato Client
PopUpMenu sotto Pulsante (TSpeedButton)
Direttiva $macro
Toolbar
Evidenziare voci TreeView
Visualizzare un file Html esterno
StatusBar - aggirare l'errore variabile duplicata
Da DataSource a Excel
Le permutazioni
Brute force
Indy 10 - Invio email con allegati
La gestione degli errori in Lazarus
Pascal Script
Linux + Zeos + Firebird
Dataset virtuale
Overload di operatori
Lavorare con file in formato JSON con Lazarus
Zeos ... dietro le quinte (prima parte)
Disporre le finestre in un blocco unico (come Delphi)
Aspetto retrò (Cmd Line)
Lazarus 1.0
Come interfacciare periferica twain
Ubuntu - aggiornare free pascal e lazarus
fpcup: installazioni parallele di lazarus e fpc
Free Pascal e Lazarus sul Raspberry Pi
Cifratura: breve guida all'uso dell'algoritmo BlowFish con lazarus e free pascal.
Creare un server multithread
guida all'installazione di fpc trunk da subversion in linux gentoo
Indice
DB concetti fondamentali e connessioni standard
Advanced Record Syntax
DB concetti fondamentali e DBGrid
DB concetti fondamentali e TDBEdit, TDBMemo e TDBText
Advanced Record Syntax: un esempio pratico
Superclasse form base per programmi gestionali (e non)
Superclasse form base per programmi gestionali (e non) #2 - log, exception call stack, application toolbox
Superclasse form base per programmi gestionali (e non) #3 - traduzione delle form
Superclasse form base per programmi gestionali (e non) #4 - wait animation
Un dialog per la connessione al database:TfmSimpleDbConnectionDialog
Installare lazarus su mac osx sierra
immagine docker per lavorare con lazarus e free pascal
TDD o Test-Driven Development
Benvenuto! Effettua l'accesso oppure registrati.
Maggio 17, 2024, 05:32:30 pm

Inserisci il nome utente, la password e la durata della sessione.

633 Visitatori, 1 Utente
 

Autore Topic: DLL Profilabexpert  (Letto 21810 volte)

Simon75

  • Full Member
  • ***
  • Post: 139
  • Karma: +0/-0
Re:DLL Profilabexpert
« Risposta #30 il: Maggio 17, 2013, 01:57:44 pm »
così non carica niente

Nome del file selezionato : C:\Documents and Settings\Simone\Desktop\dll\Prova.txt
POutput ok
0: valore = <>
  0 non caricato
A volte bisogna commettere errori per capire qual è la cosa giusta da fare...

Const
Errori=Esperienza

Simon75

  • Full Member
  • ***
  • Post: 139
  • Karma: +0/-0
Re:DLL Profilabexpert
« Risposta #31 il: Maggio 17, 2013, 02:45:44 pm »
No...scusatemi ho copiato per intero quanto scritto da nomore e non avevo modificato 

questa riga

Codice: [Seleziona]

s := sl.Values[IntToStr(i)];



in questa

Codice: [Seleziona]



 s := sl[i];




Ora l'errore non esce più e nella log vedo che carica ma nel display non vedo il risultato.

Codice: [Seleziona]


procedure CaricaArrayDaFile(FileName: string; PAParams: PDLLParams);
  var
    i: integer;
    sl: TStringList;
    e: extended;
    s: string;
  begin
    sl := TStringList.Create;
    try
      try
        sl.LoadFromFile(FileName);
        for i := low(PAParams^) to high(PAParams^) do
        begin
          if not (i in [0..sl.Count - 1]) then
            break;
          s := sl[i];

          // s := sl.Values[IntToStr(i)];
          log(IntToStr(i) + ': valore = <' + s + '>');
          if s <> '' then
          begin
            e := StrToFloat(s);
            PAParams^[i] := e;
            log('   ' + IntToStr(i) + ' caricato');
          end
          else
          begin
            log('  ' + IntToStr(i) + ' non caricato');
          end;
        end;
      except
        on e: Exception do
        begin
          log('porca miseria! "' + e.message + '"');
          raise e;
        end;
      end;
    finally
      sl.Free;
    end;
  end;


Nome del file selezionato : C:\Documents and Settings\Simone\Desktop\dll\Prova.txt
POutput ok
0: valore = <23>
   0 caricato
A volte bisogna commettere errori per capire qual è la cosa giusta da fare...

Const
Errori=Esperienza

Simon75

  • Full Member
  • ***
  • Post: 139
  • Karma: +0/-0
Re:DLL Profilabexpert
« Risposta #32 il: Maggio 26, 2013, 12:24:56 am »
Ciao  Stilgar e Nomore vi ringrazio molto funziona!!!
sbagliavo a inserire i dati di input li salvavo come numerici e poi pretendevo di visualizzarli come stringhe nel display stringa (sempre in Profilab)

Adesso ho due domade da farvi ancora:

1) Dovrei salvarli come stringhe e ho pensato di usare questo:

Codice: [Seleziona]

  TStringParams = array[0..100] of PChar;   //Type of ProfiLab DLL parameters
  PStringParams = ^TStringParams;        // Pointer to ProfiLab DLL parameters



2) Vorrei inserire un semplice ShowMessage nel momento che premo salva, giusto per capire se ha salvato. Ho provato ma genera un errore, forse nelle dll va usata sotto procedura?

Attualmente mi genera 2 errori di tipo ma non so come rimediare:



project1.lpr(130,22) Hint: Parameter "PInput" not used
project1.lpr(130,30) Hint: Parameter "POutput" not used
project1.lpr(130,39) Hint: Parameter "PUser" not used
project1.lpr(246,39) Error: Incompatible type for arg no. 2: Got "PStringParams", expected "PDLLParams"
project1.lpr(181,13) Hint: Found declaration: CaricaArrayDaFile(AnsiString,PDLLParams);
project1.lpr(257,38) Error: Incompatible type for arg no. 2: Got "PStringParams", expected "PDLLParams"
project1.lpr(138,13) Hint: Found declaration: SalvaArrayInFile(AnsiString,PDLLParams);
project1.lpr(286) Fatal: There were 2 errors compiling module, stopping



Codice: [Seleziona]


library project1;

{$mode objfpc}{$H+}

uses
  Interfaces,
  Classes,
  SysUtils,
  Windows,
  FileUtil,
  Forms,
  Controls,
  Graphics,
  Dialogs,
  ShellApi;

const
  Inputs = 3;  // quantita entrata
  Outputs = 1; // quantita uscita

  {INPUTS}// nome per numero di entrata
  I0 = 0;  // valore I0 = PInput[I0] ossia PInput[0]
  I1 = 1;  // valore I1 = PInput[I1] ossia PInput[1]
  Leggi = 2;
  // I3 = 3;
  // ... I99 = 99;

  {OUTPUTS}// nome per numero di uscita
  Stampa = 0;  // valore Q0 = POutput[Q0] ossia POutput[0]
  //Q1 = 1;  // valore Q1 = POutput[Q1] ossia POutput[1]

  // Q3 = 3;
  // ... Q99 = 99;

  {USER}// nome per numero di variabile, I valori vengono memorizzati

  U0 = 0; // valore U0 = PUser[U0] ossia PUser[0]
  // U1 = 1;
  // U2 = 2;
  // U3 = 3;
  // ... U99 = 99;

  // I0,I1,I2,I3,Q0,Q1,Q2,Q3,U0,U1,U2,U3
  // I nomi possono essere qualsiasi, sono case-insensitive
var
  globalDialog: TFileDialog;

type

  TDLLParams = array[0..100] of extended; //Type of ProfiLab DLL parameters
  PDLLParams = ^TDLLParams;               // Pointer to ProfiLab DLL parameters

  TStringParams = array[0..100] of PChar;   //Type of ProfiLab DLL parameters
  PStringParams = ^TStringParams;        // Pointer to ProfiLab DLL parameters


  function ApriSaveDialog: ShortString;

  begin
    Result := '';
    if not assigned(globalDialog) then
    begin
      globalDialog := TSaveDialog.Create(nil);
      try
        globalDialog.DefaultExt := 'txt';

        globalDialog.Filter := '*.txt';
        if globalDialog.Execute then
          Result := globalDialog.FileName
        else
          Result := '';
      finally
        FreeAndNil(globalDialog);
      end;
    end;
  end;




  function ApriOpenDialog: ShortString;
  begin
    Result := '';
    if not assigned(globalDialog) then
    begin
      globalDialog := TOpenDialog.Create(nil);
      try
        globalDialog.DefaultExt := 'txt';
        globalDialog.Filter := '*.txt';
        if globalDialog.Execute then
          Result := globalDialog.FileName
        else
          Result := '';
      finally
        FreeAndNil(globalDialog);
      end;
    end;
  end;

  function NumInputs: byte;
  begin
    Result := Inputs; // trasferire quantita entrata
  end;

  function NumOutputs: byte;
  begin
    Result := Outputs; // trasferire quantita uscita
  end;

  function InputName(Channel: byte): ShortString; // trasferire nome di entrata
  begin
    case Channel of
      I0: Result := 'I0'; // nome di pin I0
      I1: Result := 'I1'; // nome di pin I1
      Leggi: Result := '$Leggi';
    end;
  end;

  function OutputName(Channel: byte): ShortString; // trasferire nome di uscita
  begin
    case Channel of
      Stampa: Result := '$Stampa'; // nome di pin Q0
      //Q1: Result := 'Q1'; // nome di pin Q1
    end;
  end;




  procedure SimStart(PInput, POutput, PUser: PDLLParams);
  // Routine viene eseguita solo al primo avvio
  begin

  end;



  procedure SalvaArrayInFile(FileName: string;
    PAParams: PDLLParams);
  var
    i: integer;
    sl: TStringList;
  begin

    sl := TStringList.Create;
    try
      for i := 2 to 3 do
        // for i := low(PAParams^) to high(PAParams^) do

        if PAParams^[i] = 0 then


          sl.Add(FloatToStr(PAParams^[i]));


      sl.SaveToFile(FileName);
    finally
      sl.Free;
    end;

  end;

  procedure log(msg: string);
  begin
    AssignFile(Output, 'Debug.txt');
    if (FileExists('Debug.txt')) then
    begin
      Append(Output);
    end
    else
    begin
      Rewrite(Output);
    end;
    WriteLn(Output, msg);
    Flush(Output);
    CloseFile(Output);
  end;



  procedure CaricaArrayDaFile(FileName: string;
    PAParams: PDLLParams);
  var
    i: integer;
    sl: TStringList;
    e: extended;
    s: string;
  begin
    sl := TStringList.Create;
    try
      try
        sl.LoadFromFile(FileName);

        for i := low(PAParams^) to high(PAParams^) do
        begin
          if not (i in [0..sl.Count - 1]) then
            break;
          s := sl[i];

          // s := sl.Values[IntToStr(i)];
          log(IntToStr(i) + ': valore = <' + s + '>');
          if s <> '' then
          begin
            e := StrToFloat(s);
            PAParams^[i] := e;
            log('   ' + IntToStr(i) + ' caricato');
          end
          else
          begin
            log('  ' + IntToStr(i) + ' non caricato');
          end;
        end;
      except
        on e: Exception do
        begin
          log('porca miseria! "' + e.message + '"');
          raise e;
        end;
      end;
    finally
      sl.Free;
    end;
  end;


  procedure CalculateEx(PInput,POutput, PUser: PDLLParams; PStrings : PStringParams);
  // Routine è permanente
  var
    sl: TStringList;
    s: string;
  begin

    if PInput^[I0] > 2.5 then
    begin
      if (PInput^[I0] > 2.5) and not (PUser^[U0] > 2.5) then
      begin
        s := ApriOpenDialog;
        log('Nome del file selezionato : ' + s);
        if s <> '' then
        begin
          if assigned(POutput) then
            log('POutput ok')
          else
            raise Exception.Create('Non ci siamo');

          CaricaArrayDaFile(s,PStrings);
        end;
      end;
    end;
    PUser^[U0] := PInput^[I0];
    if PInput^[I1] > 2.5 then
    begin
      if (PInput^[I1] > 2.5) and not (PUser^[I1] > 2.5) then
      begin
        s := ApriSaveDialog;
        if s <> '' then
          SalvaArrayInFile(s,PStrings);
      end;
    end;
    PUser^[I1] := PInput^[I1];
  end;




  procedure SimStop(PInput, POutput, PUser: PDLLParams);
  // Routine viene eseguita solo in fase di chiusura
  begin

  end;


  //export methods for ProfiLab
exports
  SimStart,
  SimStop,
  NumInputs,
  NumOutputs,
  CalculateEx,
  InputName,
  OutputName,
  ApriOpenDialog,
  ApriSaveDialog;
begin
end.                     


A volte bisogna commettere errori per capire qual è la cosa giusta da fare...

Const
Errori=Esperienza

nomorelogic

  • Global Moderator
  • Hero Member
  • *****
  • Post: 2877
  • Karma: +20/-4
Re:DLL Profilabexpert
« Risposta #33 il: Maggio 26, 2013, 10:38:14 am »
la dichiarazione CaricaArrayDaFile è la seguente:
procedure CaricaArrayDaFile(FileName: string; PAParams: PDLLParams);
e si aspetta nr. 2 parametri: 1 di tipo string e 1 di tipo PDLLParams

quando la richiami con
CaricaArrayDaFile(s,PStrings);
stai passando 1 parametri di tipo string ed 1 di tipo PStringParams
il compilatore giustamente si incacchia

ora:
a prescindere da come li salvi sul file, in memoria , sono sempre rappresentati nello stesso modo (PAParams: PDLLParams).
Inoltre, una volta che sono un in file, è come se già fossero una stringa: è nel momento in cui li rileggi che devi preoccuparti di convertirli per poterli memorizzare.

Qual è il problema che vorresti risolvere quando dici che vorresti salvarli come stringhe?
Imagination is more important than knowledge (A.Einstein)

Simon75

  • Full Member
  • ***
  • Post: 139
  • Karma: +0/-0
Re:DLL Profilabexpert
« Risposta #34 il: Maggio 27, 2013, 12:15:46 am »
Non riesco a salvare numeri con il separatore ; e non riesco a salvare numeri con / esempio 3300/400 mi salva solo 3300 stessa cosa per il ; 4500;500 mi salva solo il 4500.

Stessa cosa per caricare, ho provato ad aprire il file txt e scriverci dentro i numeri 3434;456
e la log mi tira fuori questo

0: valore = <3434;456>
porca miseria! ""3434;456" is an invalid float"

A volte bisogna commettere errori per capire qual è la cosa giusta da fare...

Const
Errori=Esperienza

nomorelogic

  • Global Moderator
  • Hero Member
  • *****
  • Post: 2877
  • Karma: +20/-4
Re:DLL Profilabexpert
« Risposta #35 il: Maggio 27, 2013, 09:36:07 am »
intanto risolviamo il salvataggio, per il load lo vedremo quando il salvataggio funziona

nella procedura SalvaArrayInFile devi intervenire sull'istruzione seguente
Codice: [Seleziona]
sl.Add(FloatToStr(PAParams^[i]));


sl è una TStringList ed ovviamente il metodo Add come parametro richiede una stringa
è per questo che usi FloatToStr, per convertire PAParams^ in una stringa e per passarla poi come parametro ad Add
se devi salvare in quel formato che dici tu puoi fare qualcosa del genere:
Codice: [Seleziona]
sl.Add( '<' + FloatToStr(PAParams^[i]) + ';' +  FloatToStr("un altro numero") + '>' );
che altro non è che una concatenazione di stringhe

fatto questa modifica salva il file ma non ricaricarlo in memoria (viene letto un numero ed ora non ci sono numeri) ma vai a vedere nel file se tutto è ok
per il load, poi si vedrà
« Ultima modifica: Maggio 27, 2013, 09:38:47 am da nomorelogic »
Imagination is more important than knowledge (A.Einstein)

Simon75

  • Full Member
  • ***
  • Post: 139
  • Karma: +0/-0
Re:DLL Profilabexpert
« Risposta #36 il: Maggio 27, 2013, 11:26:19 am »
Si nel file txt mi salva giusto, ho messo un numero a caso nelle parentesi:


Codice: [Seleziona]
 sl.Add( '<' + FloatToStr(PAParams^[i]) + ';' +  FloatToStr(3434) + '>' );



Il risultato:

<78;3434>


A volte bisogna commettere errori per capire qual è la cosa giusta da fare...

Const
Errori=Esperienza

nomorelogic

  • Global Moderator
  • Hero Member
  • *****
  • Post: 2877
  • Karma: +20/-4
Re:DLL Profilabexpert
« Risposta #37 il: Maggio 27, 2013, 12:46:07 pm »
altra domanda:
nel file il formato di salvataggio è sempre lo stesso?
tipo: <78;3434>

o c'è possibilità che a volte devi memorizzare altre combinazioni tipo
78
<434>
#78;3434/343#
Imagination is more important than knowledge (A.Einstein)

Simon75

  • Full Member
  • ***
  • Post: 139
  • Karma: +0/-0
Re:DLL Profilabexpert
« Risposta #38 il: Maggio 27, 2013, 01:41:17 pm »
Quello che andrò a salvare sarà es:

 2200;400;677 oppure 3300/400
A volte bisogna commettere errori per capire qual è la cosa giusta da fare...

Const
Errori=Esperienza

nomorelogic

  • Global Moderator
  • Hero Member
  • *****
  • Post: 2877
  • Karma: +20/-4
Re:DLL Profilabexpert
« Risposta #39 il: Maggio 27, 2013, 02:48:50 pm »
prova ad usare questa procedura
una cosa non mi è chiara: nella versione precedente leggevi un valore per riga e lo mettevi nella variabile 'e'.
ora i valori sono 2 o 3: è per questo che ho definito un array (nr) da 1 a tre
però non so cosa ci devi fare con i valori successivi al primo, quindi dovrai terminare tu la procedura.

NB: l'ho scritta su un text editor e non l'ho nè provata nè compilata...


Codice: [Seleziona]
procedure CaricaArrayDaFile(FileName: string;
    PAParams: PDLLParams);
  var
    i: integer;
    sl: TStringList;
    // e: extended;
    s: string;

sep: string;
p,idx: integer;
nr: array[1..3] of extended;
  begin
    sl := TStringList.Create;
    try
      try
        sl.LoadFromFile(FileName);

        for i := low(PAParams^) to high(PAParams^) do
        begin
          if not (i in [0..sl.Count - 1]) then
            break;
          s := sl[i];

          // s := sl.Values[IntToStr(i)];
          log(IntToStr(i) + ': valore = <' + s + '>');
          if s <> '' then
          begin
    sep := '';
p := pos('/', s);
    if p > 0 then
   sep := '/';
if p = 0 then begin
   p := pos(';', s);
   if p > 0 then
      sep := ';';
end;     
    if sep = '' then
   raise exception.create('impossibile determinare il tipo di tracciato record');
 
    for idx := 1 to 3 do
  nr[idx] := 0;
 
            idx := 0;
    repeat
   inc(idx);
   nr[idx] := StrToFloat(copy(s, 1, p-1));
   s := copy(s, p+1, length(s));    
   p := pos(sep, s);
until (s = '') or (p = 0);

            // e := StrToFloat(s); -> il primo numero è in nr[1]
            // PAParams^[i] := e;
            PAParams^[i] := nr[1];

            log('   ' + IntToStr(i) + ' caricato');
          end
          else
          begin
            log('  ' + IntToStr(i) + ' non caricato');
          end;
        end;
      except
        on e: Exception do
        begin
          log('porca miseria! "' + e.message + '"');
          raise e;
        end;
      end;
    finally
      sl.Free;
    end;
  end;
Imagination is more important than knowledge (A.Einstein)

Simon75

  • Full Member
  • ***
  • Post: 139
  • Karma: +0/-0
Re:DLL Profilabexpert
« Risposta #40 il: Maggio 28, 2013, 09:04:35 pm »
OK ho risolto  in SalvaArrayInFile e mi salva correttamente: 3300;400....

ora questo 3300;400 non gli va bene quando lo carico e dalla log  mi esce:

0: valore = <3300;400>
porca miseria! ""3300;400" is an invalid float"

Codice: [Seleziona]

procedure CaricaArrayDaFile(FileName: string; PAParams: PDLLParams; PStringParams:PStringParams);
  var
    i: integer;
    sl: TStringList;
    e: extended;
    s: string;
  begin
        sl := TStringList.Create;
    try
      try
        sl.LoadFromFile(FileName);
         //for i := 0 to 1 do
        for i := low(PAParams^) to high(PAParams^) do
        begin
          if not (i in [0..sl.Count - 1]) then
            break;
          s := sl[i];

          // s := sl.Values[IntToStr(i)];
          log(IntToStr(i) + ': valore = <' + s + '>');
          if s <> '' then
          begin
            e := strtofloat(s);
            PAParams^[i] := e;
            log('   ' + IntToStr(i) + ' caricato');
          end
          else
          begin
            log('  ' + IntToStr(i) + ' non caricato');
          end;
        end;
      except
        on e: Exception do
        begin
          log('porca miseria! "' + e.message + '"');
          raise e;
        end;
      end;
    finally
      sl.Free;
    end;
  end;

A volte bisogna commettere errori per capire qual è la cosa giusta da fare...

Const
Errori=Esperienza

nomorelogic

  • Global Moderator
  • Hero Member
  • *****
  • Post: 2877
  • Karma: +20/-4
Re:DLL Profilabexpert
« Risposta #41 il: Maggio 29, 2013, 10:19:42 am »
devi provare CaricaArrayDaFile che trovi nel mio post precedente
Imagination is more important than knowledge (A.Einstein)

Simon75

  • Full Member
  • ***
  • Post: 139
  • Karma: +0/-0
Re:DLL Profilabexpert
« Risposta #42 il: Maggio 30, 2013, 08:44:05 am »
Si non mi da più errore, e vedo che carica dalla log ma non leggo niente nel display...

Per riuscire a leggere nel display dovrei usare questo:

Codice: [Seleziona]
     TStringParams = array[0..100] of PChar;   //Type of ProfiLab DLL parameters
  PStringParams = ^TStringParams;        // Pointer to ProfiLab DLL parameters

In CaricaArrayDaFile  attualmente gli sto passando  PStringParams  ma non viene usato, come posso usarlo?


Codice: [Seleziona]
procedure CaricaArrayDaFile(FileName: string;
    PAParams: PDLLParams; PStringParams: PStringParams);
  var
    i: integer;
    sl: TStringList;
    // e: extended;
    s: string;

    sep: string;
    p,idx: integer;
    nr: array[1..3] of extended;
  begin
    sl := TStringList.Create;
    try
      try
        sl.LoadFromFile(FileName);

        for i := low(PAParams^) to high(PAParams^) do
        begin
          if not (i in [0..sl.Count - 1]) then
            break;
            s := sl[i];

          //s := sl.Values[IntToStr(i)];
          log(IntToStr(i) + ': valore = <' + s + '>');
          if s <> '' then
          begin
            sep := '';
            p := pos('/', s);
            if p > 0 then
               sep := '/';
            if p = 0 then begin
               p := pos(';', s);
               if p > 0 then
                  sep := ';';
            end;
            if sep = '' then
               raise exception.create('impossibile determinare il tipo di tracciato record');

            for idx := 1 to 3 do
              nr[idx] := 0;

            idx := 0;
            repeat
               inc(idx);
               nr[idx] := StrToFloat(copy(s, 1, p-1));
               s := copy(s, p+1, length(s));
               p := pos(sep, s);
            until (s = '') or (p = 0);

            // e := StrToFloat(s); -> il primo numero è in nr[1]
            // PAParams^[i] := e;
            PStringParams^[i] := nr[1];

            log('   ' + IntToStr(i) + ' caricato');
          end
          else
          begin
            log('  ' + IntToStr(i) + ' non caricato');
          end;
        end;
      except
        on e: Exception do
        begin
          log('porca miseria! "' + e.message + '"');
          raise e;
        end;
      end;
    finally
      sl.Free;
    end;
  end;


Grazie
« Ultima modifica: Maggio 30, 2013, 09:04:11 am da Simon75 »
A volte bisogna commettere errori per capire qual è la cosa giusta da fare...

Const
Errori=Esperienza

Simon75

  • Full Member
  • ***
  • Post: 139
  • Karma: +0/-0
Re:DLL Profilabexpert
« Risposta #43 il: Maggio 31, 2013, 02:52:02 pm »
Avete idea di come mai lo vedo caricare nella log ma non nei display?

Ho fatto questa modifica:

Codice: [Seleziona]

    procedure CaricaArrayDaFile(FileName: string; PAParams: PDLLParams; PStringParams:PStringParams);
  var
    i: integer;
    sl: TStringList;
  //  e: extended;
    s: string;
  begin
        sl := TStringList.Create;  // istanzio l'oggetto
    try
      try
        sl.LoadFromFile(FileName);  // carico il file
         for i := 0 to 0 do         // cerco il file da caricare
        //for i := low(PAParams^) to high(PAParams^) do
        begin
          if not (i in [0..sl.Count - 1]) then
            break;
         s := sl[i];

          //s := sl.Values[IntToStr(i)];
          log(IntToStr(i) + ': valore = <' + s + '>');
          if s <> '' then       // se cè qualcosa allora
          begin
         // e := strtofloat(s);  // converto s da stinga float e l'assegno a extended
          sl.Add(PStringParams^[i]);

            //PAParams^[i] := e;
            log('   ' + IntToStr(i) + ' caricato');
          end
          else
          begin
            log('  ' + IntToStr(i) + ' non caricato');
          end;
        end;
      except
        on e: Exception do
        begin
          log('porca miseria! "' + e.message + '"');
          raise e;
        end;
      end;
    finally
      sl.Free;
    end;
  end;   
A volte bisogna commettere errori per capire qual è la cosa giusta da fare...

Const
Errori=Esperienza

Simon75

  • Full Member
  • ***
  • Post: 139
  • Karma: +0/-0
Re:DLL Profilabexpert
« Risposta #44 il: Giugno 04, 2013, 10:07:33 am »
Ciao,

Ho provato in questo modo non da errori  ma non vedo niente nel display.

Ho provato a inserire un vettore stringa nella varibile globale poichè penso che s occupa sempre la stessa area di RAM e al massimo alla fine della procedura lì il programma troverebbe solo l'ultimo valore; in realtà neppure quello perchè terminata la procedura s in quanto variabile locale SPARISCE



Codice: [Seleziona]

var
  globalDialog: TFileDialog;
  i: integer;
  stringhe: array [0..100] of string;

Poi ho modificato CaricaArryDaFile così:
Codice: [Seleziona]
procedure CaricaArrayDaFile(FileName: string; PAParams: PDLLParams; PStringParams:PStringParams);
  var
    //i: integer;
    sl: TStringList;
    //e: extended;
    s: string;
  begin
        sl := TStringList.Create;
    try
      try
        sl.LoadFromFile(FileName);
        for i := 0 to 1 do
        //for i := low(PStringParams^) to high(PStringParams^) do
        begin
          if not (i in [0..sl.Count - 1]) then
            break;

         s := sl[i];
         //s[LastDelimiter(';',s)]:=',';

          log(IntToStr(i) + ': valore = <' + s + '>');
          if s <> '' then
          begin
          stringhe[i]:=s;
          PStringParams^[i] := PChar(stringhe[i]);

         
           log('   ' + IntToStr(i) + ' caricato');
          end
          else
          begin
            log('  ' + IntToStr(i) + ' non caricato');
          end;
        end;
      except
        on e: Exception do
        begin
          log('porca miseria! "' + e.message + '"');
          raise e;
        end;
      end;
    finally
      sl.Free;
    end;
  end;


Ora la mia domanda è per voi ci sono altre modifiche da fare? 
 
Come si esegue un debug per una DLL?

Vi ringrazio.
A volte bisogna commettere errori per capire qual è la cosa giusta da fare...

Const
Errori=Esperienza

 

Recenti

How To

Utenti
  • Utenti in totale: 788
  • Latest: mastro
Stats
  • Post in totale: 18826
  • Topic in totale: 2242
  • Online Today: 708
  • Online Ever: 900
  • (Gennaio 21, 2020, 08:17:49 pm)
Utenti Online
Users: 1
Guests: 633
Total: 634

Disclaimer:

Questo blog non rappresenta una testata giornalistica poiché viene aggiornato senza alcuna periodicità. Non può pertanto considerarsi un prodotto editoriale ai sensi della legge n. 62/2001.