>>Is there any reason to not pass file handles as parameters to methods?
>>
>>I have a class that formats data into html...
>>
>>
>>=fwrite(f,htmlformat.td(table.field))
>>
>>
>>This writes
'<td>My Data</td>'
to file handle f.
>>
>>I could save a lot of coding if it is an ok practice to pass the file handle. Therefore it would become...
>>
>>
>>htmlformat.td(f,table.field)
>>
>>
>>...with the fwrite happening in the method.
>
>No, there's no reason not to, but, as Michel mentioned, it's better design to create a class wrapping the low level file I/O routines. The reason for this is two fold.
>
>One, you can store the file handle in a custom property. This means that the individual routines don't have to be passed the value, and, thus, are more cohesive.
>
>Two, when the object is destroyed, you can release the handle in the Destroy event regardless of whether or not the object's destruction is intentional or not.
Thank you both!