UE PRG Formatting

UE PRG Formatting

Postby TimStone » Mon Sep 29, 2008 3:34 pm

Since so many people use Ultra Edit, I would like to pose this question again.

I've used Multi Edit with Evolve for many years. Although I like Ultra Edit, there is one feature I wish it had that is in Multi Edit. In ME, I can have the program re-format the entire .prg file, indenting IF/ENDIF, DO/ENDDO, etc. This makes it very easy to find errors, and to check the flow of my work.

I do not see this capability in UE. I asked before and no one seemed to have an answer.

Multi Edit seems to be moving in other directions ( not xBase ) and the product lost some features under Vista. So it would be wise to move on to UE but the formatting does hold me back. Does anyone have a solution for this ?

Thanks.
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2905
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Postby Otto » Mon Sep 29, 2008 4:51 pm

Hello Tim,
that’s what I would like to have, too.
At the moment I cut & paste between UEStudio and ME which I use for re-format.

Regards,
Otto
User avatar
Otto
 
Posts: 6046
Joined: Fri Oct 07, 2005 7:07 pm

Postby Antonio Linares » Mon Sep 29, 2008 5:38 pm

Dear Tim,

With the UEStudio "fold" settings that Reinaldo commented yesterday:

http://forums.fivetechsoft.com/viewtopic.php?t=12910

it is very easy to match your if endif, for next, etc.

Please notice that we use UEStudio (not UltraEdit) :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41366
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Fold

Postby TimStone » Mon Sep 29, 2008 7:13 pm

I reviewed the comments but that won't bring about alignment.

The idea is this. In the code below, line 4 is not aligned. ME has a function to re-align the text that would bring it into the proper place.

Code: Select all  Expand view
IF abc = 123

   xyz = 1
        mno = 0
   def = 2
   cls = 3

ENDIF

With reformatting it would become:

Code: Select all  Expand view
IF abc = 123

   xyz = 1
   mno = 0
   def = 2
   cls = 3

ENDIF

Apparently Ultra Edit cannot do this ?

Tim
Last edited by TimStone on Tue Sep 30, 2008 2:28 pm, edited 1 time in total.
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2905
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Postby Antonio Linares » Mon Sep 29, 2008 8:47 pm

Tim,

Please use [ c o d e ] and [ / c o d e ] to place your code in, or it will be all left aligned (in these forums).

If you write your own code, why do you need it to get aligned ? I align it myself when I write it.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41366
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Revised

Postby TimStone » Tue Sep 30, 2008 2:31 pm

Thanks for the tip. I edited the previous post to show the formatting.

If it was just "stream of consciousness" and I wrote the code perfectly, and only once, no problem. But often I'll cut and paste something and modify it ... especially with long sections. Other times I will redo something. For example, if I write some code, and then I want to run it only with a flag so I go back and insert IF / ENDIF around that section. Then I would have to reindent everything manually. Now I hit one button and it handles it ...

It may not affect how the code runs, but it sure does effect how easy it is to read and debug.

Tim
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2905
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Postby Antonio Linares » Tue Sep 30, 2008 2:39 pm

Tim,

I guess we could implement a macro in UEStudio to do it.

Lets google for some info about UEStudio and indentation...
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41366
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Antonio Linares » Tue Sep 30, 2008 2:51 pm

Tim,

ReIndent Selection command (Format menu)
This command allows the user to reformat the selected text within the active file. This is typically used by programmers to reformat existing text according to the indentation settings in configuration and the automatic indent settings for Syntax Highlighting (see the indentation section under Syntax Highlighting for details).

When the reindenting is performed, UltraEdit will reindent the file line by line, starting with the indentation of the first selected line.

If the indentation of the first selected line is less than the indent setting, or falls between multiples of the indent setting then the indentation will be rounded down to match the value or multiple of the indent setting. (If the indent value is 4, and the first selected line is indented to 2 then the line will be assumed not to be indented as it will be rounded down to 0. If the line was indented to 6 then the line will be adjusted to be indented to 4 as it falls between the indent values of 4 and 8).

UltraEdit does try and determine if the statement causing a change in the indentation is commented out, or part of a string and ignores it in this case. However, if the file contains preprocessor conditional statements (#ifdef, #ifndef, etc.) UltraEdit does not attempt to determine which text is valid and which is not. This may cause lines to be adjusted incorrectly.

To avoid problems with conditional statements it is suggested that all conditional sections include the same number of open and close conditional statements. If an "if (test) {" statement is in the conditional text, make sure the closing brace ("}") is also in the conditional text and there should not be a problem.

In some cases it may be desirable not to indent lines such as compiler directives or comments. UltraEdit provides for this capability by allowing strings to be ignored to be defined in the wordfile.txt file. This is covered under the Syntax Highlighting section.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41366
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Antonio Linares » Tue Sep 30, 2008 2:53 pm

Indentation

UltraEdit provides for automatic indentation based on the specific language to indent a block of code or to unindent a block of code.

For indentation for a specific language add a line similar to the following line under the particular language section:

/Indent Strings = "{"

Any number of words may be specified in quotes (each word/string must be in a separate set of quotes ""). If an indent string occurs anywhere on a line it will be used for indenting (except when it occurs in quoted/commented text). The indentation is the next TAB stop from the indentation of the preceding line (same as if a TAB key was pressed).

For out-denting for a specific language add a line similar to the following line under the particular language section:

/Unindent Strings = "}"

Any number of words may be specified in quotes (each word/string must be in a separate set of quotes ""). If an indent string occurs anywhere on a line it will be used for indenting (except when it occurs in quoted/commented text). If the line that contains the string is indented LESS than the preceding line an indentation does not occur, otherwise the matching character/word is out-dented to the preceding TAB stop and the new line is indented to the same point.

For reindenting of files it may be undesirable to indent certain lines that are commented out, or compiler directives. This can be avoided by specifying lines that should not be indented. To do this add a line similar to the following to the appropriate language section in the wordfile:

/Ignore Strings SOL = "#" "//"

Any number of words may be specified in quotes (each word/string must be in a separate set of quotes ""). For the word to match it must be the FIRST character(s) of the line. If a line matches this, it would not be indented, however the indenting of the next line would be performed as if this line was not present.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41366
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Thank you

Postby TimStone » Wed Oct 01, 2008 1:49 am

Thanks Antonio,

That does exactly what I want. I appreciate it.
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2905
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Postby Otto » Wed Oct 01, 2008 9:01 am

Hello Tim,

would you be so kind to descript the steps you are doing.
Thanks in advance
Otto
User avatar
Otto
 
Posts: 6046
Joined: Fri Oct 07, 2005 7:07 pm

Otto

Postby TimStone » Wed Oct 01, 2008 3:34 pm

I did exactly what Antonio suggested in this thread, and what was suggested in the article he referenced. Once I added those lines to the wordfile, I was able to use the section reindent command on areas I highlighted. So if I worked on a Function, and then highlighted it, and selected the Section Reindent menu option ( bottom of the Format menu ), it did it successfully.

Tim
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2905
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Postby Otto » Wed Oct 01, 2008 4:07 pm

Tim, could you please post the "Indent Strings" and "Unindent Strings".
Best would be your whole file.

Thanks in advance
Otto
User avatar
Otto
 
Posts: 6046
Joined: Fri Oct 07, 2005 7:07 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 45 guests