Code folding request for Informix 4gl

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.
Mark Peenstra
Posts: 15
Joined: Mon Apr 09, 2007 5:24 pm

Code folding request for Informix 4gl

Post by Mark Peenstra » Thu Jun 18, 2009 9:21 pm

Jussi;

I would like to request support in code-folding for the Informix 4gl language. Here are the details requested by the first post in this area.

Extensions: .4gl
Line Comment1: #
Line comment2: --
Block Comment: { }
Case Sensitive: NO
Begin: FOR
End: END FOR
Begin: CASE
End: END CASE
Begin: WHILE
End: END WHILE
Begin: FOREACH
End: END FOREACH
Begin: FUNCTION
End: END FUNCTION
Begin: REPORT
End: END REPORT
Begin: GLOBALS
End: END GLOBALS
Begin: INPUT
End: END INPUT
Begin: INPUT ARRAY
End: END INPUT
Begin: DISPLAY ARRAY
End: END DISPLAY
Begin: CONSTRUCT
End: END CONSTRUCT
Begin: MENU
End: END MENU
Begin: IF
End: END IF

Sample Code:

MAIN

DEFINE i integer
FOR i = 1 to 100
-- do something
END FOR

DECLARE t_curs CURSOR FOR
SELECT * FROM TABLE

FOREACH t_curs into p_rec.*
-- some statements
END FOREACH

CALL display_func()

IF int_flag THEN
EXIT PROGRAM(1)
ELSE
EXIT PROGRAM(0)
END IF


END MAIN

FUNCTION display_func()
DISPLAY ARRAY la_array.* TO sr_array

-- some statements
END DISPLAY

RETURN

END FUNCTION

If you need any other information on this please email me.
Thanks

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

Post by jussij » Fri Jun 19, 2009 2:15 am

Hi Mark,

A first cut of the new xFolder.dll can be found here: http://www.zeusedit.com/z300/xFolder.zip

To install the new file just backup the xFolder.dll in the Zeus install folder and replace it with the one in the zip file.

If you find any issues please report them here.

Cheers Jussi

Mark Peenstra
Posts: 15
Joined: Mon Apr 09, 2007 5:24 pm

Some issues with informix 4gl code folding

Post by Mark Peenstra » Fri Jun 19, 2009 12:25 pm

Jussi;

Thanks for the quick turnaround on the folding. :D

A couple of issues so far:

1) It seems to be getting confused by comments on the same line as the keywords. Comments are allowed on the same line as a keyword, such as:

FUNCTION func_name
-- statements
END FUNCTION ##DECLARE_CURSORS

In this case it is folding up down to a line with just "END FUNCTION" on it, not the END FUNCTION it is supposed to use. (it may fold up the rest of the file if all the END FUNCTION's have comments.)

The keywords may not be the ONLY thing on a line, but it will be the FIRST thing on the line, after any whitespace.

2) There is a DISPLAY function in addition to the DISPLAY ARRAY that I had in the list. DISPLAY does not have a corresponding END statement, so we can't fold that. Can you look for both words together: DISPLAY ARRAY ?

3) The INPUT/END INPUT construct is folding up the whole rest of the document, and I don't see any comments after the END INPUT. There are variables on the line with the INPUT. Not sure if that is the cause.

Can you take a look at these?

Thanks
Mark

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

Post by jussij » Fri Jun 19, 2009 2:06 pm

Hi Mark,
Can you take a look at these?

Can you post a short snippet of code that shows these foldling errors :?:

With a simple example it should be easy enough to fix these folding issues ;)

Cheers Jussi

Mark Peenstra
Posts: 15
Joined: Mon Apr 09, 2007 5:24 pm

Sample for Informix 4gl folding

Post by Mark Peenstra » Fri Jun 19, 2009 2:28 pm

Jussi;

Here is a sample. It may be just the DISPLAY by itself that is causing all the issues I am seeing. When I comment out the DISPLAY statements, things appear to work much better.

Thanks


MAIN

DEFINE i integer
FOR i = 1 to 100
-- do something
END FOR #comment

DECLARE t_curs CURSOR FOR
SELECT * FROM TABLE

FOREACH t_curs into p_rec.*

-- some statements
DISPLAY t_curs to S_rec
END FOREACH #comment

CALL display_func()

IF int_flag THEN
EXIT PROGRAM(1)
ELSE
EXIT PROGRAM(0)
END IF


END MAIN

FUNCTION display_func()
DISPLAY ARRAY la_array.* TO sr_array

LET something = something_else
DISPLAY something TO screen

-- some statements
END DISPLAY

RETURN

END FUNCTION

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

Post by jussij » Fri Jun 19, 2009 3:37 pm

Hi Mark,

The new version of the xFolder.dll that fixes the problem with the display can be found here:

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

Cheers Jussi

Mark Peenstra
Posts: 15
Joined: Mon Apr 09, 2007 5:24 pm

One more folding issue

Post by Mark Peenstra » Fri Jun 19, 2009 4:05 pm

This is very Cool...

We are almost there.

I forgot about this goofy syntax that is allowed. You can have an IF THEN/END IF all on one line, so if it is a simple one, people do use it this way.

The folding is going all the way down to the END FUNCTION. See the last few lines in the modified sample.

MAIN

DEFINE i integer
FOR i = 1 to 100
-- do something
END FOR #comment

DECLARE t_curs CURSOR FOR
SELECT * FROM TABLE

FOREACH t_curs into p_rec.*

-- some statements
DISPLAY t_curs to S_rec
END FOREACH #comment

CALL display_func()

IF int_flag THEN
EXIT PROGRAM(1)
ELSE
EXIT PROGRAM(0)
END IF


END MAIN

FUNCTION display_func()
DISPLAY ARRAY la_array.* TO sr_array

LET something = something_else
DISPLAY something TO screen
IF u2 > u3 THEN
-- output something
END IF


-- some statements
END DISPLAY


INPUT ARRAY array_new FROM screen_rec
-- this type of if/then/end if is a problem.
IF joe > bob THEN EXIT INPUT END IF

END INPUT

RETURN

END FUNCTION

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

Post by jussij » Sat Jun 20, 2009 4:50 am

Hi Mark,

Here is another version to try out: http://www.zeusedit.com/z300/xFolder.zip
I forgot about this goofy syntax that is allowed.
It usually takes a few goes to get the foldign working, as most languages seem to have their little quirks.

Cheers Jussi

Mark Peenstra
Posts: 15
Joined: Mon Apr 09, 2007 5:24 pm

Code folding for Informix 4gl

Post by Mark Peenstra » Mon Jun 22, 2009 12:31 pm

Jussi;

One more little quirk.

The folding process seems to be confused by a section called "options". Something in there is making it miss all other keywords and fold all the way to the end of the file.

In the updated example, the MAIN/END MAIN does this as well as the IF/END IF section at lines 66-77.

I have added MAIN & END MAIN to the list of Begin/End tags. I didn't have this before for some reason but I think you figured it out.

Thanks


{
Extensions: .4gl
Line Comment1: #
Line comment2: --
}
-- Block Comment: { }
{
Case Sensitive: NO
Begin: FOR
End: END FOR
Begin: CASE
End: END CASE
Begin: WHILE
End: END WHILE
Begin: FOREACH
End: END FOREACH
Begin: FUNCTION
End: END FUNCTION
Begin: REPORT
End: END REPORT
Begin: GLOBALS
End: END GLOBALS
Begin: INPUT
End: END INPUT
Begin: INPUT ARRAY
End: END INPUT
Begin: DISPLAY ARRAY
End: END DISPLAY
Begin: CONSTRUCT
End: END CONSTRUCT
Begin: MENU
End: END MENU
Begin: IF
End: END IF
Begin: MAIN
End: END MAIN

Sample Code:
}
MAIN

DEFINE i integer
FOR i = 1 to 100
-- do something
END FOR #comment

DECLARE t_curs CURSOR FOR
SELECT * FROM TABLE

FOREACH t_curs into p_rec.*

-- some statements
DISPLAY t_curs to S_rec
END FOREACH #comment

CALL display_func()

IF joe > bob THEN EXIT INPUT END IF

IF int_flag THEN
EXIT PROGRAM(1)
ELSE
EXIT PROGRAM(0)
END IF

IF gv_mode_flag IS NULL THEN
CLEAR SCREEN

OPTIONS MESSAGE LINE 22,
COMMENT LINE 23,
ERROR LINE 24,
MENU LINE FIRST,
FORM LINE 3,
INPUT WRAP,
HELP KEY CONTROL-w,
HELP FILE "zzz_help"
END IF


END MAIN

FUNCTION display_func()
DISPLAY ARRAY la_array.* TO sr_array

LET something = something_else
DISPLAY something TO screen
IF u2 > u3 THEN
-- output something
END IF


-- some statements
END DISPLAY


INPUT ARRAY array_new FROM screen_rec
-- this type of if/then/end if is a problem.
IF joe > bob THEN EXIT INPUT END IF

END INPUT

RETURN

END FUNCTION

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

Post by jussij » Mon Jun 22, 2009 1:42 pm

MENU LINE FIRST,
INPUT WRAP,
Ther problem is these two lines.

Because they are MENU and INPUT lines they are both seen as point points but there are no matching END MENU and END INPUT end of fold points.

For example if you comment these lines out the folding will be fine.

So what happend to these end points?

For every point that is defined as a begin fold there must be a matching end fold otherwise the Zeus folding logic will just fail as it has in this case.

Cheers Jussi

PS: Is 4gi a valid file extension in addition to 4gl :?:

Mark Peenstra
Posts: 15
Joined: Mon Apr 09, 2007 5:24 pm

Questions reply

Post by Mark Peenstra » Mon Jun 22, 2009 2:18 pm

Jussi;

Do you have any kind of an 'exclusion list' where you can say: First word= INPUT but not if second word = WRAP ?

A 4gi is a compiled version of a 4gl, so one would not bring it up in an editor. We can ignore it.

Thanks
Mark

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

Post by jussij » Mon Jun 22, 2009 2:49 pm

Do you have any kind of an 'exclusion list' where you can say: First word= INPUT but not if second word = WRAP ?
That is easy enough to do.

Is there any similar rule for the MENU case :?:

Cheers Jussi
Last edited by jussij on Mon Jun 22, 2009 3:04 pm, edited 1 time in total.

Mark Peenstra
Posts: 15
Joined: Mon Apr 09, 2007 5:24 pm

Folding reply

Post by Mark Peenstra » Mon Jun 22, 2009 3:02 pm

Jussi;

Inside of an OPTIONS section you can have:

INPUT WRAP
INPUT NO WRAP
MENU LINE

We would want to ignore all of these in favor of INPUT and MENU. Those are the only ones I can find that would interfere with begin/end points.

I think you are already handling the DISPLAY word by itself? It should be ignored in favor of DISPLAY ARRAY.

Thanks
Mark

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

Post by jussij » Mon Jun 22, 2009 3:11 pm

Inside of an OPTIONS section you can have:

INPUT WRAP
INPUT NO WRAP
MENU LINE
The Zeus folder has to decide if a line is a fold point using nothing but the information found in that line. I other words it will not know if it is or isn't inside a OPTIONS section.

So for example the best the folder can do in these cases is ignore INPUT lines that are followed by WRAP and NO WRAP and ignore the MENU lines if it is follwed by LINE.

But will this be enough to stop invalid fold points :?:

If it isn't then the best thing to do is just remove INPUT nad MENU as fold points.
I think you are already handling the DISPLAY word by itself? It should be ignored in favor of DISPLAY ARRAY.
Will do ;)

Cheers Jussi

Mark Peenstra
Posts: 15
Joined: Mon Apr 09, 2007 5:24 pm

Folding

Post by Mark Peenstra » Mon Jun 22, 2009 3:42 pm

Jussi;

Yes I agree, the Options statement cannot not come into play. It should be enough to look for the second word in these cases.
Thanks
Mark

Post Reply
kuchnie warszawa opinie

Who is online

Users browsing this forum: No registered users and 2 guests