Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Passing file handle as parameter?
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 7
OS:
Windows '98
Network:
SAMBA Server
Database:
Visual FoxPro
Divers
Thread ID:
00981603
Message ID:
00981964
Vues:
35
>>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!
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform