News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Read and Writing files

Started by krikara, November 02, 2010, 02:53:24 AM

Previous topic - Next topic

FORTRANS

Quote from: krikara on November 02, 2010, 05:30:23 PM
I don't know what AF and PF means and if it affects the output,

Hi,

   AF is the Auxiliary carry Flag.  Used with BCD arithmetic.
PF is the Parity Flag.  It shows whether the accumulator has
an even or odd number of bits set by an operation.  Neither
has an effect here.

HTH,

Steve N.

krikara

Quote from: dedndave on November 02, 2010, 05:36:22 PM
i think i found it - lol
the value "stringLength" never gets saved
you intend to use that for something else
you may want to create a new variable called "InputFileLength" to save the length of the input file
then, use that as the number of bytes to write

NICE!!!
You found the error. All I had to do was    mov stringLength, eax    after the program read the input file !! :D

Thanks a bunch.

brethren

QuoteI was wondering how I can somehow combine the two inorder to create one program that will read an input file, alter the input, and then output to a new file.

here are the general steps

call OpenInputFile parameter is a filename ("input.txt") ps this file must already exist
save the return value, eax, which is a filehandle
call ReadFromFile, parameters are the saved filehandle, a pointer to a buffer and number of bytes to read
call CloseFile with the filehandle

manipulate the buffer in whatever way you see fit

call CreateOutputFile parameter is a filename ("output.txt")
save the return value, eax, which is a filehandle
call WriteToFile, parameters are a filehandle, a pointer to the buffer you manipulated and the number of bytes to write
call CloseFile with the filehandle

dedndave

seems like it should have created a 0-length file before the fix   :P

RuiLoureiro

Quote from: krikara on November 02, 2010, 02:53:24 AM
I was wondering how I can somehow combine the two inorder to create one program that will read an input file, alter the input, and then output to a new file.
                Try to use APIs and masm. It is easy. Why not ?
RuiLoureiro

dedndave

i am with you, Rui
i wouldn't use HLA - lol
but, it's for a school project i think
they are probably supposed to use Kip's library

RuiLoureiro

Quote from: dedndave on November 04, 2010, 06:50:21 PM
i am with you, Rui
they are probably supposed to use Kip's library

dedndave,
           Ok, so we need to know Irvine32 stuff, no ?  :wink
           We waste time with ...

brethren,
           It seems it doesnt work when inputbuffer is 50 and outputbuffer is 500
           
           So we need to read the input several times to fill in the outputbuffer
           and then alter the outputbuffer and at last we save the outputbuffer.

           If inputbuffer = outputbuffer = 500 or so, ok it seems to work
           We dont know all the problem ...
           We may use the outputbuffer as the inputbuffer ?
           What is the input file length ?

dedndave

well - i am familiar with Kip's older stuff - so that was painless
but - they would be better off to learn the API's
that is the real meat of writing windows code, in any language

btw, guys, that problem was fixed several posts ago - lol
http://www.masm32.com/board/index.php?topic=15210.msg123546#msg123546

RuiLoureiro

#23
dedndave,
            Try this Files2.zip (=.exe + .asm+ .inc+...).
            Whats wrong ?

dedndave

i like it   :U
but, it may be a bit complicated for the beginner   :P
(we are in the Campus sub-forum - lol)

RuiLoureiro

Quote from: dedndave on November 05, 2010, 04:10:07 PM
i like it
but, it may be a bit complicated for the beginner 

dedndave,
            Ok thank you   :green2
            It is simple ( and have some problems )
            It is based on 2 procedures: ReadText and WriteText
           
            Whenever it saves a text it saves 12000 bytes ( _lTextBuffer=12000 )
            whenever it reads, it try to read _lTextBuffer bytes only
            this was only to show the problem