Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Function exists in a PRG?
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01204677
Message ID:
01204867
Views:
15
>Dear all,
>
>Wondering if there is a way to find out if a function is defined in a PRG without actually running the function?
>
>Thanks!

Dear all, to wrap up, the following is a routine to find out if a function is defined in a PRG. FYI.
*------------------------------------------------------------------------
* syIsFuncDefined()
*   Check if a function is defined in a PRG file.
*
* PARAMETERS:
*   tcFuncName - name of function, case insensitive
*   tcPrgFile  - full path to the PRG file.
*
* RETURNS:
*   .t. if function is defined, .f. otherwise.
*
* EXAMPLE:
*   llDefined = syIsFuncDefined('UnitTest','c:\path\utilapp.prg')
*
* NOTES
*   1. return .f. is the PRG file does not exist
*
*------------------------------------------------------------------------
function syIsFuncDefined(tcFuncName, tcPrgFile)

   local lnCount, laProc[1], llDefined, lnRow
   
   if vartype(tcFuncName)<>'C' or empty(tcFuncName) ;
         or vartype(tcPrgFile)<>'C' or empty(tcPrgFile) ;
         or not file(tcPrgFile)
      return .f.
   endif
   
   llDefined = .f.
   lnCount = aprocinfo(laProc, tcPrgfile)
   lnRow = ascan(laProc, tcFuncName, 1, lnCount, 1, 15)
   if lnRow<>0 and lower(laProc(lnRow,3))=='procedure'
      llDefined = .t.
   endif
      
   return llDefined

endfunc
Previous
Reply
Map
View

Click here to load this message in the networking platform