One of the new features of v19 is the ability to return multiple values from a procedure. That came in real handy for me this week!
While working on the JQuery Slider date selection control that some of you have seen, I needed to be able to find the begin and end dates for a Quarter, based on any date. For instance if I have Feb 2, 2014, I needed Jan 1, 2104 and Mar 31, 2014.
So I wrote the following function.
Nothing fancy there, except the RESULT statement. That is the new v19 feature. I am returning 2 variables at once.
But here is where it really gets cool! So the reason I needed the quarter begin and end dates was to call my function to filter the transaction list, like this:
In the “old” days we would have had to either call 2 functions, one to get the begin date, one to get the end date, or we would have had to pass the from and to date by address to the function, so they function could set them and we would have access to them after the call. With the new v19 feature, instead you could call the function like this instead.
FromDate is Date ToDate is Date (FromDate,ToDate) = QuarterDate(Today())
But wait it gets even better. I can put this all together, and not even create local variables, like this:
Remember GetFilteredTransactions required 2 parameters, but since our function is returning 2 parameters we can make an “inline” call to the function to pass both parameters. Much cleaner and similar code that any of the “old” ways!!!!
Just another example of how WX continues to advance and push the envelope.
Now, back to your regular schedule program….
One thought on “Multiple Return Values from a Function”