Code Folding for Powerflex

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
gwgs
Posts: 87
Joined: Tue Nov 21, 2006 6:30 pm
Location: Auckland

Code Folding for Powerflex

Post by gwgs »

Can this language be added to the code folding routines please.
Extensions: .pfx .pfi .pfm .inc
Line Comment: //
Block Comment:
Begin: begin
End: end

Begin: #IF #IFDEF #IFNDEF #IFSAME #ELSE #ELIF #IFCLASS #IFTYPE
End: #ENDIF

Begin: function
End: end_function

Begin: procedure
End: end_procedure

Begin: for // can mix and match
Begin: while // these four cmds
End: loop //
End: until //

Begin: entergroup
End: endgroup

Begin: switch
Begin: when otherwise
End: endswitch

Begin: report
Begin: section
End: reportend

Begin: enter
End: enterend

Begin: #COMMAND
End: #ENDCOMMAND

Begin: constraint
End: end_constraint

Begin: Class
End: end_class

Begin: object
End: end_object

Begin: event
End: end_event

Begin: / at position 1 followed by a-z and other alpha numerics, continues until another / at column 1 but not //
Sample Code:

Code: Select all

/sampleform

enter this: __________

           _[_ all correct?

/header
    sample report

code  description
-----------------
/body
_____ ___________
/*
// include common variables
#include common.inc

// define testind if required
#IFNDEF testind
   indicator testind
#ENDIF
   indicate tesetind false

// reset teststr or define teststr if required
#IFDEF teststr
   teststr=""
#ELSE
   string teststr 30
#ENDIF

function testfunction string instr returns string
   integer ctr   
   result=""
   for ctr from length(instr) to 1 step -1
      result=result+mid(instr,1,ctr)
   loop
end_function

procedure testprocedure string instr
   integer ctr   
   ctr=length(instr)
   while ctr>0
      showln mid(instr,1,ctr)
      ctr=ctr-1
   until ctr=0
end_procedure


   entergroup
      accept sampleform.1  {capslock}
      accept sampleform.2  {checkbox}
   endgroup

   teststr=sampleform.1
   for ctr from 1 to length(teststr) step 1
      showln mid(teststr,1,ctr)
   loop

   switch sampleform.2
      when 1
         showln "YES"
      otherwise
         showln "NO"
   endswitch

   open testfile

   report testfile by index.1
      
      section header
         output header

      section body
         print testfile.code
         print testfile.desc
         output body

#include RPTKEY.inc
   reportend

   showln testfunction(sampleform.1)
         
/sampleform2
   code:        _____
   description: ___________
/*

   enter testfile
      entry testfile.code testform2.1 {capslock}
      entry testfile.desc testform2.2 
   enterend


keyproc key.escape
   abort

keyproc key.field
   backfield
return

keyproc key.return
   ifwindow eq testform2.1 begin
      clear tsetfile
      testfile.code=testfile.1
      find eq testfile by index.1
      [found] entdisplay testfile
   end
return


// general code formating comments:
// there are no case restrictions or strict formating other than syntactical restrictions
// the above code could have been all uppercase, without any indentation
jussij
Site Admin
Posts: 2650
Joined: Fri Aug 13, 2004 5:10 pm

Post by jussij »

Hi Grant,

Here is the first cut at adding code folding for Power Flex: http://www.zeusedit.com/z300/xFolderPF.zip

To install this dll make a backup copy of the current xFolder.dll and replace it with the one found in the zip file.

Please post any bugs/suggeastions to this thread ;)

Cheers Jussi
gwgs
Posts: 87
Joined: Tue Nov 21, 2006 6:30 pm
Location: Auckland

wow that was quick :)

Post by gwgs »

A couple of things from my testing:
1. all keywords need to be case insensitive when matching

2. /... folding not working properly. In the sample code i posted the forms should have folded as below.
/sampleform ...
/header ....
/body ...
/*

Instead it folded as:
/sampleform ...

and the whole program was folded.
/body folded correctly
jussij
Site Admin
Posts: 2650
Joined: Fri Aug 13, 2004 5:10 pm

Post by jussij »

2. /... folding not working properly. In the sample code i posted the forms should have folded as below.

Code: Select all

/sampleform ... 
/header .... 
/body ... 
/*
I'm not sure I fully understand how this is meant to fold :?

To fold correctly Zeus needs a begin pattern and corresponding end matching pattern.

So this was implemented as a begin fold defined as a / found as the first non-white space token of any given line, with the matching end of fold defined as a /* also at the start of line.

So in other words you code folds down to this:

Code: Select all

/sampleform ... /*
Cheers Jussi
gwgs
Posts: 87
Joined: Tue Nov 21, 2006 6:30 pm
Location: Auckland

Post by gwgs »

In the example /sampleform is ended by the definition of /header, and /header likewise is terminated by /body, and /body terminated by /*

If form folding can't be done, it's no biggie.

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

Post by jussij »

Could you try this version and once again post your feedback: http://www.zeusedit.com/z300/xFolderPF.zip

Cheers Jussi
gwgs
Posts: 87
Joined: Tue Nov 21, 2006 6:30 pm
Location: Auckland

Post by gwgs »

looking good. :D

I see the form folding has gone. I guess a way of doing it will be to use the /* as the end text.

Another begin end combination is:
begin: keyproc key. (at position 1, once whitespace is removed)
begin return

an example of it is in the sample code I supplied.

I look forward to seeing the next version of the folding code, including other begin/end combinations

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

Post by jussij »

Hi Grant,
I guess a way of doing it will be to use the /* as the end text.

Having never coded PowerFlex myself, I am still not sure what these characters signify :?

Are the like free format text, or like a comment string, or can there be code between the starting / and the ending /* and what is the significance of the text following the / character :?:

But what about this case:

Code: Select all

+ keyproc key.escape
  abort

+ keyproc key.field
  backfield
- return
This code does not have matching fold points, or is the abort also a fold point :?:

If the keyproc can exist without a matching return then it really can't be used as a fold point.

Cheers Jussi
gwgs
Posts: 87
Joined: Tue Nov 21, 2006 6:30 pm
Location: Auckland

Post by gwgs »

Here's an excerpt from the Powerflex manual regarding the / in column 1

An image header line begins with slash character "/c" where c is not a slash or asterisk.
An image end line begins with slash asterisk "/*".
Each image includes all lines of program text up to the next line starting with slash "/". It should be noted that a line starting with double slash "//" would be regarded as a comment if it occurred in the Statement section, but would be the start of a new image in the Image section.

An image may start anywhere in a program, and there may be zero, one or more images in the program. Images may follow immediately after each other, with each image header line ending one image and starting another, or each may end with an image end line.
Immediately after the slash in the image header line is the name of the image, which conforms to the usual rules for an identifier (see later). It is an error if it does not.
The header line may contain the word HELP to signify that this is a help screen (see the HELP statement). For compatibility, the word HELP may appear anywhere on the line, in upper or lower case, even forming part of the image name. The image may not be called HELP, however.
The header line is followed by 0, 1 or more image lines consisting of background text and windows.

The width of the image is limited by the length of a program line (a maximum of 300 characters), but the length of the image is not limited. Portions of images outside the displayable area (generally 24 or 25 lines of 80 columns) are not displayed on the screen but may be printed in reports.

· Example

Here is an example Image Section from a program making use of many of the available options.

Code: Select all

// EXAMPLE.PFX - example program showing image formats

// (comments look like blank lines, and are ignored
/PAGE_1	first image
Example version _.__                            __/__/__
--------------------------------------------------------
   Send report to file [_C__________________]
/PAGE_1H HELP
   Enter the name of the file and press Enter
   or press Escape to exit
/*
   name page_1 version_ date_	program text between images
/SUMMARY
   Month to date                   _$,___.__
   Year to date                    _$,___.__
   Hash total    _0_____.   Exceptions    _Z_____.
   Summary for _@_____. transactions
/*
... program continues

As to the keyproc key. question, in my sample code the key.escape commands should have had a trailing return. so the code should have looked like:

keyproc key.escape
abort
return

I was just being lazy when i coded the sample, as the abort command terminated the program.

The abort command should not be used as a fold point.

Hope that helps. :D

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

Post by jussij »

Code: Select all

// EXAMPLE.PFX - example program showing image formats 

// (comments look like blank lines, and are ignored 
/PAGE_1   first image 
Example version _.__                            __/__/__ 
-------------------------------------------------------- 
   Send report to file [_C__________________] 
/PAGE_1H HELP 
   Enter the name of the file and press Enter 
   or press Escape to exit 
/* 
   name page_1 version_ date_   program text between images 
/SUMMARY 
   Month to date                   _$,___.__ 
   Year to date                    _$,___.__ 
   Hash total    _0_____.   Exceptions    _Z_____. 
   Summary for _@_____. transactions 
/*

I think that Zeus will have to treat these as fold comment areas so that the free format text within these areas is not incorrectly interpreted as a fold point keyword.

This means the above code would fold down to this:

Code: Select all

/PAGE_1H HELP .. /* 
   name page_1 version_ date_   program text between images 
/SUMMARY .. /*

and your original example:

Code: Select all

/sampleform

enter this: __________

_[_ all correct?

/header
sample report

code description
-----------------
/body
_____ ___________
/*

would folds down to this:

Code: Select all

/sampleform .. /*

But notice how it also means this line within the sampleform would no longer be identified as a fold point:

Code: Select all

enter this: __________

What do you think :?:

Cheers Jussi
gwgs
Posts: 87
Joined: Tue Nov 21, 2006 6:30 pm
Location: Auckland

Post by gwgs »

that is how it should work, as there are no keywords or fold points within a form, so your example of /sampleform ... /* is correct.

thanks

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

Post by jussij »

I have uploaded another version of the xFolder.dll that implements the image folding as I described earlier:

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

This version also adds the keyproc, return fold points ;)

Cheers Jussi
Post Reply