The MASM Forum Archive 2004 to 2012

General Forums => The Workshop => Topic started by: mdp on May 13, 2006, 03:42:10 AM

Title: file handle
Post by: mdp on May 13, 2006, 03:42:10 AM
how to a=fopen(file,"w"); fprint(a,"test");fclose(a); with MASM ?
Title: Re: file handle
Post by: hutch-- on May 13, 2006, 03:47:22 AM
Hi mdp,

Welcome on board. You could try formatting it like masm code to start with, the trailing C ";" is a comment in MASM so you will need to put each macro command on a seperate line.

LOCAL hFile :DWORD
  ....
mov hFile, fcreate("yourfile.ext")
     ; or
mov hFile, fopen("yourfile.ext")  ; if it already exists

fprint hFile,"Howdy Folks"
fclose hFile
Title: Re: file handle
Post by: mdp on May 13, 2006, 03:54:12 AM
and how to do that, please? :)
thanks
Title: Re: file handle
Post by: Ar-ras on May 13, 2006, 03:59:54 AM
LOL
hutch wrote everything you need

write the normal masm file structure
put a proc
put the data which posted into the proc
call the proc
Title: Re: file handle
Post by: mdp on May 13, 2006, 04:03:47 AM
well, I can't find any tutorial about file handling
Title: Re: file handle
Post by: mdp on May 13, 2006, 04:05:20 AM
can someone give me a small example? please
Title: Re: file handle
Post by: hutch-- on May 13, 2006, 04:48:42 AM
mdp,

The reference for macros of this type are in the helpfle HLHELP.HLP.

I have already posted the working code for you so there is little else I can do for you but you will have to learn how to write some of this stuff, not just ask people to do it for you.
Title: Re: file handle
Post by: mdp on May 13, 2006, 04:59:52 AM
thanks hutch, but ...
Assembling: test.asm
test.asm(83) : error A2008: syntax error : fprint
test.asm(84) : error A2008: syntax error : fclose
test.asm(81) : error A2006: undefined symbol : fopen
Title: Re: file handle
Post by: hutch-- on May 13, 2006, 05:20:16 AM
Try posting your TEST.ASM and someone may be able to help you.
Title: Re: file handle
Post by: Ar-ras on May 13, 2006, 02:08:35 PM
he uses c routines
he should include the lib and the inc.....
Title: Re: file handle
Post by: mdp on May 14, 2006, 11:01:57 AM
Is posible to use all C stdio.h functions in MASM?
Title: Re: file handle
Post by: hutch-- on May 14, 2006, 11:05:40 AM
Yes but you wil have to write your own prototypes and they will end up a lot larger than using the masm32 macros which are pure API code. You also have another option and that is to use MSVCRT which provides most of this functionality. MSVCRT has direct support in masm32 so you can use the C runtime DLL.
Title: Re: file handle
Post by: Mark Jones on May 15, 2006, 07:29:43 PM
Quote from: hutch-- on May 14, 2006, 11:05:40 AM
MSVCRT has direct support in masm32 so you can use the C runtime DLL.

Hi Mdp. This is how you "include" the functions from MSVCRT.DLL:


include \masm32\include\masm32rt.inc  ; includes most typical .DLL prototypes and definitions
include \masm32\include\msvcrt.inc
includelib \masm32\lib\msvcrt.lib


Then try your f* functions. Have fun! :bg