chad.stout Posted July 10, 2008 Posted July 10, 2008 Hi, I'm wondering if there is a way of getting the values of all the parameters of a given function (similar to how you can get command line arguments via $CmdLine[]) returned in an string/array. I'd like to do this so I can easily debug what data is being passed into my functions during runtime (I'd be writing to a text file). For example: Func MyFunction($param1, $param2, $param3 = 'default') FileWriteLine("c:\log.txt", "MyFunction(" & ParamsToString() & ")") .... .... .... EndFunc I'd like to somehow output a line of text formatted as follows: MyFunction("value1", "value2", "default") At the moment I'm just formatting a string based on each individual parameter, but that's time consuming and not very elegant. Any help is much appreciated! Thanks
aslani Posted July 10, 2008 Posted July 10, 2008 Well this one no matter what the value of your $params will show up as is; Func MyFunction($param1, $param2, $param3 = 'default') FileWriteLine("c:\log.txt", "MyFunction(" & $param1 & ", " & $param2 & ", " & $param3 & ")") .... .... .... EndFunc [font="Georgia"]Chances are, I'm wrong.[/font]HotKey trouble?Stringregexp GuideAutoIT Current Version
chad.stout Posted July 10, 2008 Author Posted July 10, 2008 Well this one no matter what the value of your $params will show up as is; Func MyFunction($param1, $param2, $param3 = 'default') FileWriteLine("c:\log.txt", "MyFunction(" & $param1 & ", " & $param2 & ", " & $param3 & ")") .... .... .... EndFunc This is what I'm currently doing, however I'd like to have a generic function that will do this for me so I don't have the need to go through each function and type out the names of the parameters individually. I'd be using this in a rather large project (13K lines and counting) so you can imagine how maintainability and tediousness of doing it in this fashion would be a factor. Thanks
aslani Posted July 10, 2008 Posted July 10, 2008 The way I see it is this; $value1 = 123 $value2 = 456 $value3 = 789 MyFunction($value1) ; will log MyFunction(123,,default) MyFunction($value1,$value1) ; will log MyFunction(123,123,default) MyFunction($value1,$value3,$value2) ; will log MyFunction(123,789,456) This is not what it's doing? muttley [font="Georgia"]Chances are, I'm wrong.[/font]HotKey trouble?Stringregexp GuideAutoIT Current Version
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now