Code Folding for Foxpro

This forum should be used for all code folding problems, questions or suggestions. You can also use this forum to request folding support for a new language.
Post Reply
jussij
Site Admin
Posts: 2429
Joined: Fri Aug 13, 2004 5:10 pm

Code Folding for Foxpro

Post by jussij » Sat Jan 28, 2006 3:48 am

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...
[ELSE]
 ** more comments...
ENDIF

**************************************************

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

**************************************************

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

**************************************************

SCAN
 ** used for looping through a table
ENDSCAN

**************************************************

FOR i = 1 to 10
 ? i
ENDFOR

**************************************************

frmMyForm = CREATEOBJECT("FormChild")

DEFINE CLASS FormChild AS FORM
 Height = 295
 Width = 524
ENDDEFINE

**************************************************

WITH oApp.oProgBar
 .width = 60
ENDWITH

**************************************************

FUNCTION AddNumbers
 LPARAMERS tNum1,tNum2
 nReturn = tNum1 + tNum2
RETURN nReturn

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

FUNCTION AddNumbers
 LPARAMERS tNum1,tNum2
 nReturn = tNum1 + tNum2
 RETURN nReturn
ENDFUNC

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 
ENDFUNC.

**************************************************

PROCEDURE ProcedureName
 x = 1
 ? x
RETURN

PROCEDURE ProcedureName2
 x = 2
 ? x
ENDPROC

PROCEDURE ProcedureName3
 x = 3
 RETURN x
ENDPROC

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

************************************************** 

jussij
Site Admin
Posts: 2429
Joined: Fri Aug 13, 2004 5:10 pm

Post by jussij » Sat Jan 28, 2006 7:11 am

The code folding for Foxpro has been implemented and the new xFolder.dll can be found here:

http://www.zeusedit.com/z300/xFolder.zip

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

jlanquist
Posts: 1
Joined: Mon Jan 30, 2006 3:49 am

You are my hero!

Post by jlanquist » Mon Jan 30, 2006 3:56 am

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

Post Reply
kuchnie warszawa opinie

Who is online

Users browsing this forum: No registered users and 3 guests