Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Passing file handle as parameter?
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 7
OS:
Windows '98
Network:
SAMBA Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
00981603
Message ID:
00981964
Views:
36
>>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!
Previous
Reply
Map
View

Click here to load this message in the networking platform