Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Passing form properties to a function
Message
From
30/06/1999 04:20:06
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
 
 
To
29/06/1999 16:26:03
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00235492
Message ID:
00235729
Views:
23
>In an existing application which I am modifying an auditlog which records values before and after the changes to the fields.Currently audit log is done by calling a generic function, i.e.
>
> x = auditlog('table','key','keyvalue')
>
>For a few fields in one table a comment also has to entered if the field changes. I do not want to rewrite the function since I do not know how many comments I will have and I do not want to break existing code. What is best way of doing this. Some possiblities I condidered,
>1. add some form properties to hold the comments but can I use them in the function with out explicitly passing then to the function, if so how?
>2. create public variables that get released as soon as I return form function, do not care for this one if I can avoid it.
>3. other ideas?

It is quite customary for me (may someone call this a "design pattern") to add another parameter to the function, and provide a default value for it in the function. So the first lines of your function may be:

Parameters pTable, pKey, pKeyValue, pComment
pComment=iif(empty(pComment, "", pComment)

The second line will just make sure that the pComment is made a string if the function is called with only three parameters. Somewhere in the function, add a few lines to deal with the case when len(pComment)#0. That way your function uses the fourth parameter if it's there, and works just like before if it's not.

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Previous
Reply
Map
View

Click here to load this message in the networking platform