Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Varios
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Grupo de Teaming del ClubDelphi

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 07-09-2007
scriptors scriptors is offline
Registrado
 
Registrado: sep 2007
Posts: 5
Poder: 0
scriptors Va por buen camino
read string from offset - upgrade needed

Código Delphi [-]
 
Function TMainForm.ReadFromOffset(const RAWFile: String; OffsetI: integer;BlockLength:Integer): string;
var
  RAW: file;
  BytesRead: integer;
  RAWData: array[1..5000] of char;
  I: integer;
  c: pointer;
  return: string;
  begin
  BytesRead := -1;
  return := '';
  AssignFile(RAW, RAWFile);
  Reset(RAW,1);
  for I := 0 to OffSetI - 1 do
    Blockread(RAW,c,1);
  BlockRead(RAW,RAWData,BlockLength,BytesRead);
  for I := 1 to BlockLength do
    return := return + RAWData[i];
  ReadFromOffset := return;
  CloseFile(RAW);
  end;

I use this for read byte from datafile at offset and have result one string
this work but are really time expensive if i need to meke more search

I think because it search all file for go to 'offset'

someone can upgrade this routine ?
Responder Con Cita
  #2  
Antiguo 07-09-2007
[basti] basti is offline
Miembro Premium
 
Registrado: ago 2004
Posts: 388
Poder: 20
basti Va por buen camino
He leído en otro mensaje que entiendes el castellano escrito, así que te respondo en castellano:

En la función hay un error, debería retornar el valor de 'return'.

Por otro lado, puedes usar la función seek para ir a una posición del archivo directamente:


Código Delphi [-]
Function TMainForm.ReadFromOffset(const RAWFile: String; OffsetI: integer;BlockLength:Integer): string;
var
  RAW: file;
  BytesRead: integer;
  RAWData: array[1..5000] of char;
  I: integer;
  c: pointer;
  return: string;
begin
  BytesRead := -1;
  return := '';
  AssignFile(RAW, RAWFile);
  Reset(RAW,1);
  Seek(RAW, OffsetI - 1);

  BlockRead(RAW,RAWData,BlockLength,BytesRead);

  for I := 1 to BlockLength do
    return := return + RAWData[i];

  ReadFromOffset := return;
  CloseFile(RAW);
  result := return;
end;
__________________
Saludos.
Responder Con Cita
  #3  
Antiguo 07-09-2007
scriptors scriptors is offline
Registrado
 
Registrado: sep 2007
Posts: 5
Poder: 0
scriptors Va por buen camino
encantado

from 25 sec -> to 1 sec
correct little 'bug'

Código Delphi [-]
 
Function TMainForm.ReadFromOffset(const RAWFile: String; OffsetI: integer;BlockLength:Integer): string;
var
  RAW: file;
  BytesRead: integer;
  RAWData: array[1..5000] of char;
  I: integer;
  c: pointer;
  return: string;
begin
  BytesRead := -1;
  return := '';
  AssignFile(RAW, RAWFile);
  Reset(RAW,1);
  Seek(RAW, OffsetI); // - 1 NOT necessary 
 
  BlockRead(RAW,RAWData,BlockLength,BytesRead);
 
  for I := 1 to BlockLength do
    return := return + RAWData[i];
 
  ReadFromOffset := return;
  CloseFile(RAW);
  result := return;
end;
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
INTERBASE Invalid request BLR at offset 69 mismail Firebird e Interbase 1 11-02-2007 12:11:59
upgrade W2K a Window 2003 santi33a Windows 0 12-06-2006 14:26:05
Upgrade ActiveX Component Pook OOP 1 04-05-2006 12:10:41
Error de tipo BLR at offset 18 gaby_stars Firebird e Interbase 1 08-04-2006 02:44:42
Problema con Procedimiento Almacenado Offset 88 AGAG4 Firebird e Interbase 8 19-11-2004 23:02:55


La franja horaria es GMT +2. Ahora son las 03:50:28.


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