• Welcome to Theos PowerBasic Museum 2017.

News:

Attachments are only available to registered users.
Please register using your full, real name.

Main Menu

Code-Formatter PB 10

Started by Theo Gottwald, January 18, 2011, 07:58:28 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Theo Gottwald

This is our first community project - a Code-Formatter for PB 9.
Of course it should be extended also to PB 10 immediately when its available.
But anyway - maybe its not yet perfect on your code?

Tweak it, and post the improved version and the List of changes you did.
Let's see if we can get this Project forward together.

Added: I Have changed the Title as it looksl ike that the Code-Formatter now is ready for PB 10.
I'LL also remove old versions now.

Paul Elliott

#1
Ok, here's my little contribution.

Added ability to split multiple Global/Local variables out to 1 per line and line up the AS info.
It could be expanded to handle DIM & STATIC but I wasn't worried about them.

Redid the TAB expansion as pointed out to me.

Think I semi-fixed the space problem with +=  -=  *=  OR=  AND= . They compile with a space
before the = but it just doesn't look right to me.

Not sure why the following got unfixed:
original at least 2 spaces on left

 s$ = $Title
  i = INSTR(s$, "(")
  s$ = LEFT$(s$, i - 1)
 Prgzqnam = s$


after no spaces on left

s$ = $TITLE
i = INSTR(s$, "(")
s$ = LEFT$(s$, i - 1)
Prgzqnam = s$


not sure if it matters but this is part of a Callback Function. reran original program and it does the
same output. so I didn't mess up something. just couldn't find out why.

05/09/2011  Please note: new zip is in message dated 05/09/2011. Small fixes.


Paul Elliott

Found the problem but not the solution ( yet ).

It never allowed for Callback Function and thinks it's still in the middle of some construct which has
reset the indent level.

If someone else would care to handle this, I won't get upset.  ;)

Also noticed that "function" & "sub" are checked twice in a CASE statement. Should be fixed but
no hurry.

And if you figure out how to align the AS items of a Type that would be helpful.

Paul Elliott

#3
Fixed Callback Function not indenting the code of the function.

zip file updated as of 05/09/2011 01:09pm ( or around 7:10pm here ).

If you have downloaded the v2 zip from the previous message, you probably want this new one.

Not sure if I can delete it from the previous message or not.

Enjoy.

Paul Elliott

#4
Made some minor changes for v2a. Updated 6/21/2011 around 08:30am ( or 02:30pm here ).

Got Global/Regsiter/Dim/Local/Static all into 1 routine for splitting variables.

There are still some that I don't handle.
Multiple AS type on 1 line.
Multiple AS type  on line split with "_" on end.
Lines mixing old style ( w/ & ! $ ... ) on same lines with different AS type but this should show
up as compile error.

Am looking at Type/End Type to align the AS type. But this routine would also not really fit into
the way the program was originally structured.

Any  of the 18 who downloaded v2 should download v2a.
I'll see if I can remove v2 zip just to avoid confusion.

Any comments are welcome ( unless you're just going to yell at me  ;)  ).
   

Theo Gottwald

It should be adopted for PB 10, as I am only compiling with PB 10 actually.

Paul Elliott

Theo,

If that last comment was to me, I'll have to pass. Don't have v10 and there doesn't seem like
there's much interest in my modifications.


Theo Gottwald

Paul, actually there is some interest (17 downloads is ok).
Also there are only some who like to contribute to the public, like Jose and others (we know their names).

Anyway let me recommend you PB 10. For me its the berst PB ever.

Theo Gottwald

#8
Ok, Peter Weiss made a PB 10 conversion as a next step!
If i understand Peter right, it eats now PB 10.
Testers welcome-

Thanks Peter!

(Attached file).

Peter Weis

Hi,
tests all come out, if something does not work tell me about it! :'(
regards Peter

Paul Elliott

Sorry if I'm missing something but how does this new version handle PB 10?

Aside from the addition of a couple lines dealing with PBForms, I don't see anything new.
The MACROs are nice but it won't compile if you add %UNICODE = 1 before them.

Also won't there be a problem of passing BYREF w()  if it's defined as STRING
and the receiving function say BYREF w() as STRING or XSTRING?



Theo Gottwald

Paul, this is still "work in progress". If you want continue to contribute, you are welcome.
While at this time, maybe Peter is "on it" so it makes sense,  to wait until he says that he's done.

Paul Elliott

Sorry, I guess I misunderstood what you meant by "it eats PB 10".

Frankly I couldn't understand why the program was adding UNICODE support for a source file.
The PB IDE/Compiler will only read ANSI text and not Unicode.

I'll wait for a higher version number before I test again.


Peter Weis

#13
Hi Paul,
you are right when you say the source text is ANSI code. But to call the Windows API functions, it makes sense to work even with UNICODE.

Therefore, code with ANSI code.
API calls with Unicode.

I've changed it now so you can try it.

regards Peter

Norbert Spoerl

Hello Peter


I've tried the formatter. In principle it works. I like some of the results of the  structure not to 100%.

In addition I have the following questions.
Why do you want to have the opportunity to make the code to a DLL (your reference to global variables). Who should use it? I would prefer a good user interface. Selection of options for formatting, the benefit of the clipboard. Specifying a filename to save the formatted text. I find it problematic when the old source code is simply overwritten.


Greetings