Forum Discussion
Hi Marsha
I created a function which can be used for positive testing (where data is expected to be shown in the grid) and negative testing (data is not expected to be shown in the grid). I use Log.Message and Log.Error consecutively. Now I need to replace those log functions with variable so I don't need to go into script every time based on what type of message I need.
Thanks for response!
I experimented a little and kept running in circles trying to evaluate those strings as objects and back again.
Instead of passing in "Log.Message" and "Log.Error", could you pass in "M" or "E" and then choose the log statement inside the code?
- Vivek7210 years agoContributor
Hi Marsha,
Sorry, Doesn't work that way either.
Thanks a lot for suggestions. Hoping to find solution!
- joseph_michaud10 years agoModerator
You could always use your own function to switch which log method gets called. Something like this:
function TestMe() { WriteLog("message", 2); WriteLog("anything", 5); WriteLog("error", 1); } function WriteLog(message, type) { switch (type) { case 1: Log.Error(message); break; case 2: Log.Message(message); break; default: Log.Warning(message); break; } }
- Marsha_R10 years agoModerator
What Joseph outlined is what I was trying to explain. Can you give us some more details as to why this won't work for you?
Related Content
- 4 years ago