Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Otros entornos y lenguajes > C++ Builder
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 07-05-2014
mordaz mordaz is offline
Miembro
 
Registrado: mar 2008
Posts: 32
Poder: 0
mordaz Va por buen camino
Ayuda para traducir código delphi a c++ builder

Que tal,

Alguien me puede ayudar a entender este codigo para traducirlo, principalmente hace 2 funciones convertir una variable Variant a un archivo y de un archivo a la variable de nuevo.

Este es el codigo de guardado:

Código:
procedure TForm1.SaveTemplate();
 var
outFile : File of byte;
vrnt: Variant;
vtByteBuf : PByteArray;
aryLow: integer;
aryHigh : integer;
loopIndex : integer;
iTemplate : DPFPShrXLib_TLB.IDPFPTemplateDisp;
begin

try
if SaveDialog.Execute then
      begin
iTemplate := DPFPEnrollment.Template as DPFPShrXLib_TLB.IDPFPTemplateDisp;
vrnt:=iTemplate.Serialize;  //raw data is now stored in this variant

        //Now that you have the variant, try to get raw byte array
        //We are assuming here that you cannot save a variant directly to database field
        //That you need a byte array before saving the data to the database.
        aryLow:=VarArrayLowBound(vrnt,1);
        aryHigh:=varArrayHighBound(vrnt,1);
        aryHigh:=aryHigh-aryLow;

        vtByteBuf:=VarArrayLock(vrnt);  //lock down the array
        AssignFile(outFile,saveDialog.FileName);
        Rewrite(outFile);
        for loopIndex := 0 to aryHigh  do
        begin
               //fpData[loopIndex]:=vtByteBuf[loopIndex];
               //bt:=fpData[loopIndex];
               Write(outFile,vtByteBuf[loopIndex]);  //Save directly to file here
        end;
        VarArrayUnlock(vrnt);
      end;
except
on E: Exception do showmessage('Trouble saving data');
end;
        CloseFile(outFile);


end;
Y este el codigo de recuperacion:
Código:
procedure TForm1.LoadTemplate;
var inFile : File of Byte;
    vrnt: Variant;
    vtByteBuf : PByteArray ;
    loopIndex : integer;
    length : integer;
    bt : byte;
begin
  if OpenDialog.Execute() then
  begin
    if OpenDialog.FileName <>'' then
    begin

         AssignFile(inFile,OpenDialog.FileName);
         Reset(infile);

         length:=FileSize(inFile);
         vrnt := VarArrayCreate([0,length],varByte); //Allocate the array required to store the fpdata in your variant
         vtByteBuf:=VarArrayLock(vrnt);
         loopIndex:=0;
         while not Eof(inFile) do
         begin
             Read(inFile,bt);
              vtByteBuf[loopIndex]:=bt;
              loopIndex:=loopIndex+1;
         end;

         VarArrayUnlock(vrnt);
         CloseFile(inFile);

         TemplateFromFile.Deserialize(vrnt);

    end;
  end;
end;
Espero que me puedan ayudar a entender el codigo para traducirlo. Gracias.
Responder Con Cita
Respuesta



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
Ayuda para traducir código PHP a Delphi FideRosado Varios 2 19-10-2013 15:28:51
Traducir código delphi a vb monaguillo Varios 2 08-12-2007 11:32:42
Ayuda para completar código:Traducción de Delphi a Builder Pernorak C++ Builder 3 30-05-2007 12:45:16
Traducir un codigo de VB a Delphi ¡¡¡¡ Por favor !!!! Betsa23 Internet 2 30-11-2004 16:29:35
Ayuda en traducir de C a Delphi carlosmoralesm C++ Builder 2 01-07-2004 09:28:59


La franja horaria es GMT +2. Ahora son las 00:50:26.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi