hi friends,

have you tried this customized intellisense script?

 

what is  “zproc” intellisence snippet?

the “zproc” is a customized script to alert the vfp editor to brigs up defined/native procedures, while coding. you can activate this custom script by just type “zproc” in your code editor window.

 

 

“zproc” script will display the following information

  • procedures/functions defined in the current program
  • procedures/functions defined in the program which is set in procedure stack (using set                 procedure to) command.
  • vfp native functions.
  • declared api functions( in current program and in procedure stack)
  • parameter list for each functions/procedures
  • parameter, function type, api library name for api functions.

 

installing zproc

                you can install this script by simply unzipping the zip file to vfp root directory and enter the following command in your vfp command window.

 

cd home()

do install_zproc

 

how to uninstall zproc script?

                you can uninstall this script by entering following command in your vfp command window.

 

use (_foxcode)

delete for alltrim(lower(abbrev)) == "zproc"

 

download this script from following locations

 

http://www.foxite.com/uploads/6cc79fe8-f9b7-4d01-9380-7ba8dd6b6a1b.zip

 

please let me know your comments..

 

please find the updated script here

http://www.foxite.com/uploads/f606979d-a024-4c69-a4d1-f86118b0c3b5.zip

thanks,

jijo

 

One Response to "zproc" – Customized IntelliSense Script

  • michaelk says:

    Hi Jijo,

    Excellent stuff!!!

    But there is one problem with code. You asume that in procedure will be "SET PROCEDURE TO" and for that procedure that works. If I issue SET PROCEDURE TO in MAIN.prg and want use "zproc" in form code editor or class code editor; there will be no intellisense for that!

    I was free to modify your code to acomplish that :

    *——————————————————————————-

    *- Program             : zproc

    *- Author              : Jijo Pappachan

    *- Date                : 12/04/09 03:07:46 PM

    *- Copyright           :

    *- Description         : Script to bring up list of UDFs

    *- Revision Information:

    *——————————————————————————-

    Lparameter oFoxcode

    Private lcfxtoollib, lnProcCount, lcLparaLine, lcIconFile

    lcLparaLine = ""

    #Define PROCSNIPET #Proc

    lcfxtoollib   = Sys(2004)+"FOXTOOLS.FLL"

    lnProcCount   = 0

    lcIconFile = IIF(FILE(HOME() + "zproc_method.bmp"), HOME() + "zproc_method.bmp", HOME() + "ffc\Graphics\method.bmp")

    If File(_CODESENSE)

     Local eRetVal, loFoxCodeLoader

     Set Procedure To (_CODESENSE) Additive

     loFoxCodeLoader = Createobject("FoxCodeLoader")

     eRetVal = loFoxCodeLoader.Start(m.oFoxcode)

     loFoxCodeLoader = Null

     Release Procedure (_CODESENSE)

     Return m.eRetVal

    Endif

    Define Class FoxCodeLoader As FoxCodeScript

     pcSetAdded = .F.

     

     Procedure Main

       

       If !File(lcfxtoollib)

         Return .F.

       Endif

       Set Library To (m.lcfxtoollib) Additive

       Dimension This.oFoxcode.Items[1 , 2]

       lnWinHdl = _WONTOP()

       _wselect(lnWinHdl)

       Dimension laEnv[25]

       _EdGetEnv(lnWinHdl ,@laEnv)

       *– Get contents from code which is being edited

       lcCodeStr = _EDGETSTR(lnWinHdl , 0, laEnv[2] -1)

       This.CheckCode(lcCodeStr)

    *    This.GetNativeFuncs()

       *– Remove Position identifier

       This.ReplaceWord("")

       This.oFoxcode.ValueType = "L"

       This.oFoxcode.Itemsort = .T.

       Return This.AdjustCase()

     Endproc

     Procedure CheckCode(pcCodeStr)

       Local lcCodeStr, lnLineCnt, laCodeArray[1]

       lcCodeStr = pcCodeStr

       lnLineCnt = Alines(laCodeArray, lcCodeStr)

       For lnLineIndx = lnLineCnt To 1 Step -1

         lcProcName     = ""

         lcProcParams  = ""

         lnProcLine    = 0

         lcLine       =  Alltrim(laCodeArray[lnLineIndx])

         If This.GetLocProcs(lcLine, @lcProcName, @lcProcParams)

           This.AddToList(lcProcName, lcProcParams, "M")

         ELSE

      This.GetDllFuncs(@laCodeArray, lnLineIndx)

         Endif

       ENDFOR

     

     Endproc

     Procedure AddToList(lcProc, lcParamList, pcType)

       If Empty(lcProc)

         Return

       Endif

       lcProc = Alltrim(lcProc)

       lcParamList = Alltrim(lcParamList)

       lnProcCount = lnProcCount + 1

       If lnProcCount > 1

         Declare This.oFoxcode.Items[lnProcCount, 2]

       Endif

       This.oFoxcode.Items[lnProcCount, 1] = lcProc && Proc/func name

       This.oFoxcode.Items[lnProcCount, 2] = lcParamList

       This.oFoxcode.Icon = lcIconFile

     Endproc

     Procedure GetLocProcs(pcLine, pcProcName, pcParamList)

       Local llProcFound, llProtected

       llProcFound = .F.

       llProtected  = .F.

       If Upper(Left(Getwordnum(pcLine, 1), 4)) == "PARA" Or ;

           UPPER(Left(Getwordnum(pcLine, 1), 4)) == "LPAR"

         *– Parameter line found. Stote it

         lcLparaLine = Strtran(pcLine, Getwordnum(pcLine, 1), "")

       Endif

       If Upper(Left(Getwordnum(pcLine, 1), 4)) == "PROT" Or ;

           UPPER(Left(Getwordnum(pcLine, 1), 4)) == "HIDD"

         llProtected = .T.

       Endif

       If Upper(Left(Getwordnum(pcLine, Iif(llProtected, 2, 1)), 4)) == "PROC" Or ;

           UPPER(Left(Getwordnum(pcLine, Iif(llProtected, 2, 1)), 4)) == "FUNC"

         pcProcName = Strtran(pcLine, Getwordnum(pcLine, 1), "")

         If llProtected

           *– PROTECTED/HIDDEN procedure. Get rid off the keyword

           pcProcName = Strtran(pcProcName, Getwordnum(pcProcName, 1), "")

         Endif

         If "(" $ pcProcName

           pcParamList = Strextract(pcProcName , "(", ")")

           pcProcName  = Strextract(" " + pcProcName , " ", "(")

         Else

           pcParamList = lcLparaLine && Get from last parameter line

         Endif

       Endif

       If Upper(Getwordnum(pcLine, 1)) == "SET" And ;

           UPPER(Left(Getwordnum(pcLine, 2), 4)) == "PROC"

         This.ParseSetProcs(pcLine, @pcProcName)

       Endif

    IF !This.pcSetAdded THEN

    LOCAL lcSetProcVal, lcProcName2, pcLine2

    This.pcSetAdded   = .T.

       lcSetProcVal = SET("Procedure")

       IF !EMPTY(lcSetProcVal) THEN

        FOR i = 1 TO GETWORDCOUNT(lcSetProcVal, ",")

        pcLine2 = GETWORDNUM(GETWORDNUM(lcSetProcVal, i, ","), 1, ".") + [.prg"]

        This.ParseSetProcs2(pcLine2, @lcProcName2)

        ENDFOR

       ENDIF

    ENDIF

       llProcFound = !Empty(pcProcName)

       Return llProcFound

     Endproc

     Procedure ParseSetProcs(pcLine, pcProcName)

       Local lcProcFile, lcCodeStr

       lcProcFile = Getwordnum(pcLine, 4)

       If Empty(Justext(lcProcFile))

         lcProcFile = Forceext(lcProcFile, "prg")

       Endif

       If File(lcProcFile)

         lcCodeStr = Filetostr(lcProcFile)

         This.CheckCode(lcCodeStr)

       Endif

     Endproc

     Procedure ParseSetProcs2(pcLine, pcProcName)

       Local lcProcFile, lcCodeStr

       lcProcFile = ALLTRIM(pcLine)

       If Empty(Justext(lcProcFile))

         lcProcFile = Forceext(lcProcFile, "prg")

       Endif

       If File(lcProcFile)

         lcCodeStr = Filetostr(lcProcFile)

         This.CheckCode(lcCodeStr)

       Endif

     Endproc

     Procedure GetNativeFuncs

       Local Array laNativFun[1, 2]

       Local lnFunIndx

       lcCurs = Sys(3)

       Select expanded, tip From (_Foxcode) Where Type == "F" And !Deleted() ;

         INTO Array laNativFun

       For lnFunIndx = 1 To _Tally

         This.AddToList(laNativFun[lnFunIndx, 1], laNativFun[lnFunIndx, 2], "F")

       Endfor

     Endproc

     Procedure GetDllFuncs(paCodeAray, pnLineIndx)

       Local lcDLLDeclaration, lnFuncPos, ;

         lnLineIndx, lcAPIFunction, lcAPIdll, lcAPIparams, ;

         lcAPIreturn, llAliasFound, lcTip

       lnFuncPos       = 2

       lnLineIndx      = pnLineIndx

       lcAPIFunction   = ""

       lcAPIdll        = ""

       lcAPIparams     = ""

       llAliasFound    = .F.

       lcDLLDeclaration = Alltrim(paCodeAray[lnLineIndx])

       Do While Right(lcDLLDeclaration, 1) == ";" And ;

           lnLineIndx <= Alen(paCodeAray, 1)

         lnLineIndx = lnLineIndx + 1

         *– Get continuation line

         lcDLLDeclaration = Left(lcDLLDeclaration, Len(lcDLLDeclaration) – 1) + " " + ;

           ALLTRIM(paCodeAray[lnLineIndx])

       Enddo

       lcDLLDeclaration = Strtran(Strtran(Strtran(lcDLLDeclaration, Chr(9), " "), Chr(10), " "), Chr(13), " ") + " "

       If Not (Left(Upper(Getwordnum(lcDLLDeclaration, 1)), 4) == "DECL" And ;

           " IN " $ lcDLLDeclaration)

         Return .F.

       Endif

       *– Get return type

       If Lower(Getwordnum(lcDLLDeclaration, 2)) $ ;

           " short integer single double long string object "

         lcAPIreturn = Proper(Getwordnum(lcDLLDeclaration, 2))

         lnFuncPos = 3

       Endif

       If " AS " $  Upper(lcDLLDeclaration)

         *– Function has alias name. Get it

         lcAPIFunction = Strextract(lcDLLDeclaration, " AS ", " ")

         llAliasFound  = .T.

       Else

         *– Get module name

         lcAPIFunction = Getwordnum(lcDLLDeclaration, lnFuncPos)

       Endif

       *– Gel Library name

       lcAPIdll = Strextract(lcDLLDeclaration, " IN ", " ")

       If llAliasFound

         lcAPIparams = Strtran(Strextract(lcDLLDeclaration + "~", " AS ", "~"), lcAPIFunction, "")

       Else

         lcAPIparams = Strtran(Strextract(lcDLLDeclaration + "~", " IN ", "~"), lcAPIdll,"")

       Endif

       Set Textmerge To Memvar lcTip Noshow

       Set Textmerge On

       If !Empty(lcAPIparams)

           \Parametes : <<lcAPIparams>>

       Endif

       If !Empty(lcAPIreturn)

           \Function Type: <<PROPER(lcAPIreturn)>>

       Endif

       \Library: <<lcAPIdll>>

       Set Textmerge Off

       Set Textmerge To

       This.AddToList(lcAPIFunction, lcTip)

     Endproc

    Enddefine

Leave a Reply

Your email address will not be published. Required fields are marked *