|
 |
kurtz le pirate <kur### [at] free fr> wrote:
>
>
> Of course this code work :
> --------------------------------------------------------------------------
> #fopen FileHandle1 "test1.txt" write
> #fopen FileHandle2 "test2.txt" write
> #fopen FileHandle3 "test3.txt" write
>
> #write (FileHandle1, "writing to test1\n")
> #write (FileHandle2, "writing to test2\n")
> #write (FileHandle3, "writing to test3\n")
>
> #fclose FileHandle3
> #fclose FileHandle2
> #fclose FileHandle1
> --------------------------------------------------------------------------
>
> ...but the advantages of having one and only one macro that writes to
> files are lost :(
>
>
You could put each of those sections in their own macro.
like:
macro OpenW(F,FileName)
#switch(F)
#case(1) #fopen Afile FileName write #break
#case(2) #fopen Bfile FileName write #break
#case(3) #fopen Cfile FileName write #break
#end
#macro Write(F,String)
#switch(F)
#case(1) #write(Afile,String,"\n") #break
#case(2) #write(Bfile,String,"\n") #break
#case(3) #write(Cfile,String,"\n") #break
#end
#end
#macro Close(F)
#switch(F)
#case(1) #fclose Afile #break
#case(2) #fclose Bfile #break
#case(3) #fclose Cfile #break
#end
#end
You'll notice different names here that because I tested the Idea and just
copied the code.
Have Fun
Post a reply to this message
|
 |