Jump to content

How to read file by 100bytes each time? plz help

- - - - -

  • Please log in to reply
7 replies to this topic

#1
thatsme

thatsme

    Programmer

  • Members
  • PipPipPipPip
  • 175 posts
I read 100 bytes of text in file.that's ok. Then i use it, clear buffer, and i have to read another 100 bytes from file, which i dont know how to do. Can anybody tell me how to do it or post a an example?
Thanks in advance

#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,822 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others
Are you having trouble with opening the file, reading from the file, reading only 100 bytes at a time, or something else?
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#3
thatsme

thatsme

    Programmer

  • Members
  • PipPipPipPip
  • 175 posts
Opening file - no problems
reading first 100bytes - no problems
reading another 100bytes - that's the problem

#4
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,822 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others
Is it the looping or the flushing the buffer that's an issue?
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#5
thatsme

thatsme

    Programmer

  • Members
  • PipPipPipPip
  • 175 posts
the issue is that i dont know how make code read not first 100 bytes but another 100 bytes

#6
dargueta

dargueta

    Writes binary right handed and hex left handed

  • Moderators
  • 4,705 posts
  • Programming Language:C, Java, C++, PHP, Python, Perl, Assembly, Bash, Others
  • Learning:JavaScript
Just move the file pointer to where you want to read from:

;same as lseek(file_handle, 100, SEEK_SET)
mov    ax, 4200h
mov    bx, filehandle
xor    cx,cx
mov    dx, 100
int    21h

;optional, just in case something goes wrong
jc    ERROR_FILE_SEEK

;no error, move on with life. NOW is when
;you can read the next 100 bytes.

Here's what you need to do:

Interrupt 21H, subfunction 42H (i.e. AH=42h)
AL - seek mode
* 0 - SEEK_SET
* 1 - SEEK_CUR
* 2 - SEEK_END
BX - file handle
CX:DX - signed offset to move the file pointer.

Returns:
* DX:AX - new offset of file pointer from start of file (i.e. SEEK_SET)
* CF set on error, AX has error code in that case.
* Error codes: AX=0 means "Invalid function", AX=6 means "Invalid file handle".
sudo rm -rf /

#7
thatsme

thatsme

    Programmer

  • Members
  • PipPipPipPip
  • 175 posts
thanks for info, i would like also to know how to overwrite text in file. I was serching for function which deletes text, but i didn't find any infornation. Maybe i can you writting function (3Fh) to overwrite text? can anybody help?

#8
dargueta

dargueta

    Writes binary right handed and hex left handed

  • Moderators
  • 4,705 posts
  • Programming Language:C, Java, C++, PHP, Python, Perl, Assembly, Bash, Others
  • Learning:JavaScript
Yes, just position the file pointer where you want to overwrite and just write out your buffer.
sudo rm -rf /




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users