Page 1 of 1

Code Folding for Foxpro

Posted: Sat Jan 28, 2006 3:48 am
by jussij
Hi! this is for a Foxpro prg.

Code: Select all

  Extensions: .prg
Line Comment: *
Block Comment: N/A

For begin/end, stuff inside [brackets] are, except for CASE,
optional but would be nice if they could be folded too :)

       Begin: IF
         End: [ELSE]         (Optional)
         End: ENDIF

       Begin: DO CASE
    Alt. Beg:   [CASE]       (Required)
    Alt. Beg:   [OTHERWISE]  (Optional)
         End: ENDCASE

       Begin: DO WHILE
         End: ENDDO

DO is also another keyword separate from the DO CASE and the
DO WHILE.  It is used for calling another prg, procedure, or
function so don't fold on it.  Example:

DO SomeOtherPRG

This would run SomeOtherPRG.PRG and continue on.  You wouldn't
want to fold on this since there is no ending keyword.

       Begin: SCAN
         End: ENDSCAN

       Begin: FOR
         End: ENDFOR

       Begin: DEFINE CLASS
         End: ENDDEFINE

       Begin: WITH
         End: ENDWITH

WITH can also be used with other keywords, but will not start
out the line this way.  When the line starts out with WITH
then it will be the one you want to fold.

       Begin: FUNCTION
         End: ENDFUNC
    Alt. End: RETURN

I don't use the ENDFUNC, but rather the RETURN since I'm
returning a value.

       Begin: PROCEDURE
         End: ENDPROC
    Alt. End: RETURN

I end most of my procedures with a RETURN instead of using
the ENDPROC.  I don't return anything, but it's kind of a
bad habit from using the FUNCTION :(   so you could end
with either a RETURN or ENDPROC.  They do the same thing.

Also, you can have a comment on the same line as code.
(A && will do this)  Example can be found below in the
IF/ENDIF block.

 Sample Code:

IF nValue = 1  && This comment is ignored by the compiler
 * Some comments...
 ** more comments...


 CASE nValue = 1
   *** Some code would go here, blah blah
 CASE nValue = 2
   *  indenting is not required like in python
   ** optional and used if nvalue = something
   ** other than 1 or 2


bError = .F.
DO WHILE bError <> .T.
 bError = .T.


 ** used for looping through a table


FOR i = 1 to 10
 ? i


frmMyForm = CREATEOBJECT("FormChild")

 Height = 295
 Width = 524


WITH oApp.oProgBar
 .width = 60


 LPARAMERS tNum1,tNum2
 nReturn = tNum1 + tNum2
RETURN nReturn

That's how I use it, but this is also ok.

 LPARAMERS tNum1,tNum2
 nReturn = tNum1 + tNum2
 RETURN nReturn

My preference would be to fold on RETURN since
a function returns a value.  But if a ENDFUNC
appears before a RETURN, end folding on the 


PROCEDURE ProcedureName
 x = 1
 ? x

PROCEDURE ProcedureName2
 x = 2
 ? x

PROCEDURE ProcedureName3
 x = 3

These are all correct.  I would recommend folding
on either RETURN or ENDPROC, whichever come first.


Posted: Sat Jan 28, 2006 7:11 am
by jussij
The code folding for Foxpro has been implemented and the new xFolder.dll can be found here:

To install this new dll backup the current dll and replace it with the one contained in the zip file.

To complete the install you will need to create a Foxpro document type and enable the code folding option.

Cheers Jussi

You are my hero!

Posted: Mon Jan 30, 2006 3:56 am
by jlanquist
Thanks a bunch! Instead of adding the new visual foxpro doc type, I edited the Clipper Doc Type and changed the Description to "VFP Document Type" so it now shows as that. Thanks again for your work :D