Author Topic: Code-Formatter PB 10  (Read 160126 times)

0 Members and 1 Guest are viewing this topic.

Offline Peter Weis

  • Sr. Member
  • ****
  • Posts: 326
  • User-Rate: +15/-4
  • Gender: Male
Re: Code-Formatter PB 9
« Reply #15 on: November 11, 2011, 01:32:43 PM »
Hello Norbert,

I already turn a surface for the program to write. But only had time for the program are the core! The old file is not deleted but stored as a file Bak.

regards Peter

Offline Norbert Spoerl

  • Newbie
  • *
  • Posts: 37
  • User-Rate: +1/-0
Re: Code-Formatter PB 9
« Reply #16 on: November 11, 2011, 03:09:10 PM »
Hello Peter


that with the BAK I have not noticed, as previously there was already a BAK with the same name.

Because the surface - I might do something about it. But I have no problem with global variables, and would that use with.


Have a nice weekend!


Offline Norbert Spoerl

  • Newbie
  • *
  • Posts: 37
  • User-Rate: +1/-0
Re: Code-Formatter PB 9
« Reply #17 on: November 14, 2011, 08:31:36 AM »
I think PBNote2.bas from ...\Samples\SDK is a good start for a frame and surface. But at last weekend, I had no time for it.

Offline Larry Charlton

  • Newbie
  • *
  • Posts: 14
  • User-Rate: +5/-3
Re: Code-Formatter PB 9
« Reply #18 on: November 14, 2011, 01:25:24 PM »
Needs a small update for properties.  What's interesting is one of those looks right.

Code: [Select]
        Property Get Value() As String
            Property = value_
            End Property
            Property Set Value(value As String)
                value_ = value
            End Property

            Property Get ColorSize() As Long
                Property = colorSize_
                End Property
                Property Set ColorSize(ByVal value As Long)
                    colorSize_ = value
                End Property

                Property Get ColorIsRound() As Long

Commenting out line 536 seemed to fix the problem.

Code: [Select]
Construct( "PROPERTY", "END PROPERTY")
I liked the option of specifying the file on the command line or else getting an open file dialog.  Would be nice if I could enter multiple files or select multiple files.

Also saw the note about the settings being hardcoded for demo purposes.  Would be nice if those values were constants at the top of the program, it would make changing them until there's an alternative way, just a bit easier.

Probably too much effort but might be nice if one of the options was lower, upper, or mixed case PB keywords similar to the IDE.

I see you can split global/local variables, might be nice to have a pack global/local variables also

Along those lines, making three line IF THEN's, 1 line, or making 1 line IF THEN's 3 lines might be a nice option as well.

Removing extra blank lines (if there are two or more consecutive blank lines)

Also same for Case condition: statement
to
Case condition
    statement

Also statement:statement:statement to multi-line might be nice

Inserting blank lines (maybe before multi-line constructs, after Dim/local/global/instance line sets)

Flipping !, ', and ? back to REM, ASM, and PRINT might be a nice option

Adding or removing the [RE]DIM x(xxx) AS Instance/Global/Local Type might be nice.

It's a nice program as is, I was just thinking about the things I never did when writing a similar program.  Also while there are 3 or 4 source code formatters on the PB forums, might be nice to post or link from there.

Offline Paul Elliott

  • Full Member
  • ***
  • Posts: 164
  • User-Rate: +40/-32
Re: Code-Formatter PB 9
« Reply #19 on: November 14, 2011, 02:59:01 PM »
Larry,

I think it needs an update to handle Class and all that goes with that.
Seems to have a problem with Interface and End Interface and having
Method declares (?) between.

I don't know how to do Class code and don't want to start making changes
in the middle of code when someone else is already working on it.

I'm wondering if the problem you show has to do with the underline on the end.
Try adding something after it ( maybe even a remark ) just to see if it resets the
indentation back to where it should.

I took your test.bas from GDIPlus project and copied all the #Includes to the end of it.
Ran that thru the formatter and it started indenting at Interface IStream Guid$(.... and
never really reset to the left ( except for the constants which it did put in column 1 ).
By the way, what did you have the tab size set at? Was it 8?


« Last Edit: November 14, 2011, 03:11:41 PM by Paul Elliott »

Offline Peter Weis

  • Sr. Member
  • ****
  • Posts: 326
  • User-Rate: +15/-4
  • Gender: Male
Re: Code-Formatter PB 9
« Reply #20 on: November 14, 2011, 04:08:37 PM »
Hi Paul,

I'm glad that you like to do something. I am currently working on the dialogue to set the options and file names, and I'm still busy two days. If you want to do something at the core format. Feel free to you and do it! I have since the last release, no longer made ​​in this core!

regards Peter
« Last Edit: November 14, 2011, 04:59:25 PM by Peter Weis »

Offline Paul Elliott

  • Full Member
  • ***
  • Posts: 164
  • User-Rate: +40/-32
Re: Code-Formatter PB 9
« Reply #21 on: November 14, 2011, 08:40:29 PM »
Ok. I did a few things to format Class code a little better.
It may not be perfect but it works on Larry's GDIPlus project.

I renamed this to Code-Formatter v2c just to keep the different versions seperate.

Sorry it took so long but it took me a LONG time to remember that the formatting routine
only gets fed 1 line at a time. I had to move my inClass variable out of that function and
I put it in the fo UDT for convenience.

Hope I didn't mess up any other part. Tested with PB Win v10.

Offline Peter Weis

  • Sr. Member
  • ****
  • Posts: 326
  • User-Rate: +15/-4
  • Gender: Male
Re: Code-Formatter PB 9
« Reply #22 on: November 14, 2011, 09:07:15 PM »
Hi Paul,
  Thank you for your efforts. :) I will install it. I fucked up today have found that Phoenix had made ​​a mistake. Then I hand-written file Form.frm and have destroyed my dialogue! I could annoy me so! The program went so well. Was on target. And now, three days' work for the cat!  >:( But I get the point again!
 regards Peter

Offline Theo Gottwald

  • Administrator
  • Hero Member
  • *****
  • Posts: 1050
  • User-Rate: +30/-4
  • Gender: Male
    • it-berater
Re: Code-Formatter PB 10
« Reply #23 on: November 15, 2011, 08:04:42 AM »
Hallo Peter,

did i get this right, this is yourfinal version, anybody else can now test it and
start adding to the project by changing the code?

Offline Paul Elliott

  • Full Member
  • ***
  • Posts: 164
  • User-Rate: +40/-32
Re: Code-Formatter PB 10
« Reply #24 on: November 15, 2011, 12:54:07 PM »
Theo,

You're confusing me.

Did you see an attachment in Peter's latest post that I didn't?   ???

He had said before that he was working on the GUI for setting options and getting files to work on.
And that it was okay for me to see if I could fix the code dealing with Class. That's all I did.
I worked from the archive that he had previously posted.

As I inderstood his last post, there was a problem on his computer with Phoenix and he lost the work
he had done on the GUI. But he is working to re-create it.


Offline Norbert Spoerl

  • Newbie
  • *
  • Posts: 37
  • User-Rate: +1/-0
Re: Code-Formatter PB 10
« Reply #25 on: November 15, 2011, 02:38:25 PM »
Hello

This
Code: [Select]
  l_style_listbox       = %WS_CHILD OR %WS_VISIBLE OR %WS_VSCROLL OR %WS_TABSTOP OR _
                          %LBS_OWNERDRAWFIXED OR %LBS_HASSTRINGS OR %LBS_NOTIFY  'OR %LBS_NOINTEGRALHEIGHT
is after the formatting that.
Code: [Select]
l_style_listbox = %WS_CHILD OR %WS_VISIBLE OR %WS_VSCROLL OR %WS_TABSTOP OR _
'OR %LBS_NOINTEGRALHEIGHT
%LBS_OWNERDRAWFIXED OR %LBS_HASSTRINGS OR %LBS_NOTIFY

The code is too complex for me. I do not find personally the right place, to be able to undertake a change.

Regards

Offline Paul Elliott

  • Full Member
  • ***
  • Posts: 164
  • User-Rate: +40/-32
Re: Code-Formatter PB 10
« Reply #26 on: November 15, 2011, 02:54:44 PM »
Norbert,

I admit that some of the adjustments need either some work or another option.

** just ignore the part about fo.lineupequates .... I didn't search far enough
**  but the part about length of line & fo.remcol is good
What happens if you set fo.lineupequates = 0  ?  With it set to 1 the program tries to put
any trailing comments at fo.remcol. If the line is already past that point it puts it on a new line.

A new choice might be to indent continuation lines. And if the first line has an equal sign  then
line up the following lines indented at least past the equal sign.

One of the considerations for modifications is that the program doesn't have any real Global
variables. Any change like the above will need either Global variables or additions to the fo UDT
( such as I did for inClass ) or maybe a new UDT that will hold line status information that needs
to be saved between input lines and passed back/forth between routines.

Just my thoughts and maybe Peter has better choices.    :-\

« Last Edit: November 15, 2011, 03:05:39 PM by Paul Elliott »

Offline Theo Gottwald

  • Administrator
  • Hero Member
  • *****
  • Posts: 1050
  • User-Rate: +30/-4
  • Gender: Male
    • it-berater
Re: Code-Formatter PB 10
« Reply #27 on: November 15, 2011, 05:50:59 PM »
I am also confussed :-) . Who is actually working on it and who has the final version ?

Offline Paul Elliott

  • Full Member
  • ***
  • Posts: 164
  • User-Rate: +40/-32
Re: Code-Formatter PB 10
« Reply #28 on: November 15, 2011, 07:09:31 PM »
If you start with the post by Larry Charlton on the 14th  you'll see that I then said where the problem
could be but didn't want to make changes when someone else was working on it.

Peter said he was working on the GUI and it was ok if I made changes to the core code.

I did and posted v2c ( based on Peter's v2a which I consider v2b ).
I only added 1 variable to the fo UDT and made changes to some of the rebuild function.

Peter then said he would take the code I posted. He said that he had an accident earlier in the day
and lost GUI code that he had worked on. But he was recreating it. This accident had to have happened
before I posted v2c as I changed the BAS file name and shouldn't have been able to cause any
trouble.

So, unless there is something that Peter wants me to help with,  Peter has the code and is working
on getting the GUI in place with the rest of the code.


Clear?


Offline Peter Weis

  • Sr. Member
  • ****
  • Posts: 326
  • User-Rate: +15/-4
  • Gender: Male
Re: Code-Formatter PB 10
« Reply #29 on: November 15, 2011, 07:39:21 PM »
Hello,
 Have written on my user interface. Despite that yesterday I had a total failure, they will again have the following problem identified during the formatting is not in me but!

original code
Code: [Select]
hWndChild = CreateWindowEx(%NULL, _                                             ' extended styles
                                 "SysTabControl32", _                                 ' class name
                                 "", _                                                ' caption
                                 %WS_CHILD OR %WS_VISIBLE OR %WS_GROUP OR _           ' window styles
                                 %WS_TABSTOP OR _
                                 %TCS_TABS OR %TCS_SINGLELINE OR _                    ' class styles
                                 %TCS_RAGGEDRIGHT, _
                                 11, 18, _                                            ' left, top
                                 489, 303, _                                          ' width, height
                                 hWnd, %IDC_FORM1_TAB1, _                             ' handle of parent, control ID
                                 ghInstance, BYVAL %NULL)                             ' handle of instance, creation parameters
      SendMessage hWndChild, %WM_SETFONT, hFont, %TRUE
       

Formatted code
Code: [Select]
hWndChild = CreateWindowEx(%NULL, _  ' extended styles
            "SysTabControl32", _                 ' class name
            "", _                                ' caption
            ' window styles
            %WS_CHILD OR %WS_VISIBLE OR %WS_GROUP OR _
            %WS_TABSTOP OR _
            %TCS_TABS OR %TCS_SINGLELINE OR _    ' class styles
            %TCS_RAGGEDRIGHT, _
            11, 18, _                            ' left, top
            489, 303, _                          ' width, height
            hWnd, %IDC_FORM1_TAB1, _             ' handle of parent, control ID
            ghInstance, BYVAL %NULL)             ' handle of instance, creation parameters
            SendMessage hWndChild, %WM_SETFONT, hFont, %TRUE
                                                             

The code after formatting not only looks terrible, and still has an error, it does not compile anymore


     
« Last Edit: December 26, 2011, 10:17:26 AM by Peter Weis »