That functionality is very useful. In Notepad+ it is Ctrl+F3/Ctrl+Shift+F3, but both allow you to change the shortcut keys.
Another trick I use to keep variables unique to my function is I make every variable begin with a prefix that denotes the function name… for example if I wanted a name$ in fn_what_ever, I’d probably call it We_Name$. It doesn’t help with recurision, but I can tell at a glance that it’s meant for that function and shouldn’t be used anywhere else.
-john
From: br_forum-bounces@ads.net [mailto:
br_forum-bounces@ads.net]
On Behalf Of Gabriel Bakker
Sent: Wednesday, May 27, 2009 3:11 PM
To: Business Rules Forum
Subject: Re: [BR_forum] OOP and BR!
I declare every variable I use in a function as a local parameter by listing it in the def statement. I only ran into line length problems once but its a pretty significant problem.
Declaring every temp variable used in a function as a local parameter is a really good practice to get into. It keeps your functions from stepping on each others toes in random ways, and it encourages the use of cleaner code.
Of course, I have had to resort to major workarounds when I want to use an array in a function recursively. For that I have had to make my own stack and write functions for placing arrays on it and popping arrays off of it.
Also, I have found MyEdit's CTRL+SHIFT+UP/DOWN (search for next/prior occurrence of current word) can also be a useful tool when determining if a variable is unique or not.
Gabriel
On Wed, May 27, 2009 at 1:55 PM, John Bowman <
gothnerd@gmail.com (
gothnerd@gmail.com)> wrote:
And there are limits to the length of a line… this limits the name lengths/number of variables that you can have defined within the scope of a function. That’s another problem with this being the only way to make variables within the scope of a function. And as was pointed out earlier, in recursive functions EVERY variable used must be in the def statement. Let’s hope they use small variables like O and F and not Payee_Name_Last$ and Account_Balance$.
-john
From: br_forum-bounces@ads.net (
br_forum-bounces@ads.net) [mailto:
br_forum-bounces@ads.net (
br_forum-bounces@ads.net)]
On Behalf Of George Tisdale
Sent: Wednesday, May 27, 2009 1:45 PM
To: Business Rules Forum
Subject: Re: [BR_forum] OOP and BR!
I don’t think I see the problem. If the “local” variables are all optional after the semi-colon and therefore not referenced in the call adding a variable/parameter to be passed is as simple as adding it either before or after the semi-colon.
If added before the semicolon then all calls must reference the parameter or you will get an error on the call. If added immediately after the semi-colon then only those calls that need to pass the parameter need to be changed. All of the trailing optional parameters are left off the call and default to NULL.
George L. Tisdale, CPA
Tisdale CPA
75 Junction Square Drive
Concord, MA 01742
(978) 369-5585
From: br_forum-bounces@ads.net (
br_forum-bounces@ads.net) [mailto:
br_forum-bounces@ads.net (
br_forum-bounces@ads.net)]
On Behalf Of John Bowman
Sent: Wednesday, May 27, 2009 12:07 PM
To: Business Rules Forum
Subject: Re: [BR_forum] OOP and BR!
but the functions get too long so quickly and with no overloading going back and adding a variable that needs to be passed could be a real p.i.t.a. after you've put a huge list of scope-variables.
I don't understand what you mean by documenting the parameters? i just comments at the top of the function to do this.
On Wed, May 27, 2009 at 11:35 AM, Gordon Dye <
gordon.dye@ads.net (
gordon.dye@ads.net)> wrote:
I realize it would be useful to have a way to declare local variables. However, in the final analysis optional parameters can be used, with proper naming conventions, for local variables. And functionally nothing is lacking because all such variables are created fresh on the stack each time a function is called. What is needed, in my opinion, is some way to document parameters better than what is presently available.
gordon
On Wed, May 27, 2009 at 8:39 AM, John Bowman <
gothnerd@gmail.com (
gothnerd@gmail.com)> wrote:
Kenvin - today doing a recursive function - I got to apply your tip (below).
Thank you!
-john
-----Original Message-----
From:
br_forum-bounces@ads.net (
br_forum-bounces@ads.net) [mailto:
br_forum-bounces@ads.net (
br_forum-bounces@ads.net)] On Behalf Of
Kevin Klappstein
Sent: Wednesday, May 20, 2009 4:14 PM
To: Business Rules Forum
Subject: Re: [BR_forum] OOP and BR!
Another way to fake OOP (or more specifically variable scope) is to put
any variable that needs to remain in scope for the duration of a
function into the parameter list. This is the only place where BR has
proper variable scope, and will allow for the same function to be run
while the previous copy remains uncorrupted. This does cause problems in
that it makes your function calls look like a dog's breakfast, and you
can't cheat with using global variables between functions any more, but
it will work. We use this technique any time we need to use recursion.
Kevin Klappstein
Western Canadian Software
kevin@wcs.ab.ca (
kevin@wcs.ab.ca)
_______________________________________________
BR_forum mailing list
BR_forum@ads.net (
BR_forum@ads.net)
http://ads.net/mailman/listinfo/br_forum_ads.net
_______________________________________________
BR_forum mailing list
BR_forum@ads.net (
BR_forum@ads.net)
http://ads.net/mailman/listinfo/br_forum_ads.net