Can I declare and use a function within a function?
Posted: Mon Feb 23, 2009 9:10 pm
Sorry for what is likely a simple question. I searched on "function" before posting but got 4500+ hits, and the Basic doc is unclear. Couldn't find it on Google either.
So...can I declare and use utility functions within a function? What I want to do is something like:
* Declare function (this is the main function)
DEFFUN MyFunction(pInputValue, pInputPattern) Calling "DSU.MyFunction"
* Declare utility function, which is a sub-function in this file
DEFFUN MatchPattern(pInputValue, pInputPattern)
... stuff in MyFunction function
Return(Ans)
* ===== Subroutines =====
Sub1:
If Not(MatchPattern(foo,bar)) Then Return(1)
... stuff
Return(0)
Sub2:
If Not(MatchPattern(bar,foo)) Then Return(1)
... different stuff
Return(0)
* ===== Utility Functions =====
Function MatchPattern(pInputValue, pInputPattern)
... stuff
Return pInputValue Matches pInputPattern
End
This is an oversimplification of what I want to do. I know I can use subroutines - my question is whether I can declare and use additional sub-functions.
Thanks,
Scott
So...can I declare and use utility functions within a function? What I want to do is something like:
* Declare function (this is the main function)
DEFFUN MyFunction(pInputValue, pInputPattern) Calling "DSU.MyFunction"
* Declare utility function, which is a sub-function in this file
DEFFUN MatchPattern(pInputValue, pInputPattern)
... stuff in MyFunction function
Return(Ans)
* ===== Subroutines =====
Sub1:
If Not(MatchPattern(foo,bar)) Then Return(1)
... stuff
Return(0)
Sub2:
If Not(MatchPattern(bar,foo)) Then Return(1)
... different stuff
Return(0)
* ===== Utility Functions =====
Function MatchPattern(pInputValue, pInputPattern)
... stuff
Return pInputValue Matches pInputPattern
End
This is an oversimplification of what I want to do. I know I can use subroutines - my question is whether I can declare and use additional sub-functions.
Thanks,
Scott