Hi all,
It's been a while since i've been here since i'm awfully busy the last couple of months, but now i have another question to ask:
I'm writing a program which needs to read from a ini file one line at the time.
I know i am able to read the file until the newline character is reached but i was actually hoping for a function that already has that ability since i need to make the code as easy to understand for others as possible. Especially for people with no coding experience it is hard to understand such a function.
Anyone knows of such a function i can invoke which is already part of the windows API's or part of the masm library?
Thanks in advance!
Kind regards,
Mark
This procedure in the masm32 library is designed for that purpose.
readline proc source:DWORD,buffer:DWORD,spos:DWORD
Have a look at the example in the service pack called GETINI, it uses the macro for the same procedure "linein$" and it shows you how to use it.
Thanks hutch!
Btw, i just had to re-download masm32 after a reinstall and i saw that you haven't got a mirror in the Netherlands yet. Let me know if you are interested then i will put it on my site as well.
Regards,
Mark
Here is a quick example :
.386
.model flat,stdcall
option casemap:none
include \masm32\include\windows.inc
include \masm32\include\masm32.inc
include \masm32\include\kernel32.inc
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\masm32.lib
.data
spos dd 0
source db 'This is line 1 , ',13,10,'This one is line 2 , '
db 'Finally, this is line 3',13,10
.data?
buffer db 100 dup(?)
.code
start:
invoke readline,ADDR source,ADDR buffer,spos
or eax,eax
jz @f
mov spos,eax
invoke StdOut,ADDR buffer
jmp start
@@:
invoke ExitProcess,0
END start
Hello,
You can also have a look on my site,The source of my library (coming with the download of editmasm) contain proc usable to load a textfile,call the lines of the textfiles by there numbers, in any order that you want and with saving time of scrutation.
ToutEnMasm
Thanks guys, but the following lines already work like they should:
mov hFile, InputFile("inifile.ini")
mov rpos,0
my_loop:
mov rpos,linein$(hFile,ADDR buffer,rpos)
lea eax,buffer
cmp byte ptr [eax],'#'
jz my_loop
invoke lstrlen,addr buffer
.IF eax==0
jmp next
.ENDIF
invoke MessageBoxA,NULL,addr buffer,addr buffer,MB_OK
jmp my_loop
next:
invoke CloseHandle,hFile
invoke ExitProcess,0
If the first character of a line contains a # then it is seen as comment and not used.