need help converting old style def fn functions
#10
(07-23-2022, 07:27 AM)mnrvovrfc Wrote:
(07-14-2022, 07:12 PM)madscijr Wrote: I think this may have been created waaay back in the day, maybe in GW-BASIC or BASIC A?
The "DEF FN" assumes *all* variables are global, that's why it was eventually replaced with SUB/FUNCTION in M$QB. "DEF FN" has no way to declare a variable local, and not even to set its type. That's why when converting one of those to "FUNCTION" the programmer has to watch out for variables that weren't listed as parameters to the function. Also couldn't create a string function with "DEF FN".

Try compiling your code (which looks less than the spaghetti shown above) with "OPTION _EXPLICIT" at the top.

Good point, thanks. I always like to dim my variables at the top of the scope, a habit instilled in me in so many other languages!
Reply


Messages In This Thread
RE: need help converting old style def fn functions - by madscijr - 07-24-2022, 12:30 AM



Users browsing this thread: 2 Guest(s)