• Welcome to Theos PowerBasic Museum 2017.

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.

Paul Elliott

Dominic,

Thanks. That's cleared up some things I couldn't understand.

As far as I knew, the big push for this version of the program was to handle the new items
in PB v10. But at first all I saw were some MACROs switching between ANSI & UNICODE.
Which were not needed to handle the data files ( only plain BAS code usable by the IDE and
compiler ... NO UNICODE there ). And not needed in any of the existing functions of the program
and I couldn't see any need of them for future functions dealing with the programs main
purpose. They might have been useful in some way dealing with a GUI to handle setting/saving
the formatting options if the GUI needed to handle UNICODE. But as it is, I just don't see any
advantage to the program as it sits.

But I'll continue to do what I can to help.


Peter Weis

Hi Paul,

if you have time could sometimes look here. Here's another mistake! Have code formatter can go through and that's come out here

original code

FUNCTION CodeFormatter_InitApplication _
  ( _
  BYVAL hInstance AS DWORD, _ ' handle of current instance
  BYVAL lParam    AS LONG _   ' address of command line
  ) AS LONG

  LOCAL lpszcmdline AS WSTRINGZ PTR                     '20.11.2011 Muss Bei PowerBasic 10 WStringz Ptr
  LOCAL filenum AS LONG
  LOCAL ztext , zOut AS XASCIZ * %MAX_PATH
  DIM Built AS GLOBAL IPOWERTIME


code Formatter

FUNCTION CodeFormatter_InitApplication _
   (_
   BYVAL hInstance AS DWORD, _                   ' handle of current instance
   BYVAL lParam AS LONG _                        ' address of command line
   ) AS LONG

  LOCAL lpszcmdline AS WSTRINGZ PTR                     '20.11.2011 Muss Bei PowerBasic 10 WStringz Ptr
  LOCAL filenum AS LONG
*ERR LOCAL  0 but need  5
  LOCAL  AS XASCIZ * %MAX_PATH
*ERR LOCAL  0 but need  4       


I'm still working with Progress bar in status bar

regards Peter

Paul Elliott

Peter,

Simple fix.  Add fo.ascolumn = 40  after you  GET fo in FUNCTION CodeFormatter_InitApplication.

Better fix.  Add the ascolumn variable to the Options page.

Small variable that got lost in the shuffle.


Peter Weis

#93
Hi Paul,
  ascolumn inserted in the Options page :)

regards Peter

Paul Elliott

Peter,

Close but ascolumn goes with split variables and should be next to it. and entry disabled when
split variables is unchecked.


Peter Weis

#95
Hi Paul,
Here again an update that disabled split variable!

Did not have much time today!

regards Peter

Paul Elliott

Hi Peter,

Not bad but I would have just inserted the As Column ( or Column AS ) below the split variable
check box and bumped the fields below it down. That way you wouldn't have had to increase
the tab/dialog size.

Did you realize that you can get the program's command line  via COMMAND$ and get a plain
string? No mucking about with wasciiz ptr. not sure if there is any difference in the result as
you're only dealing with 1 field ( source file name ).

Just to be doing something, I worked up a DDT version starting with PBForms and manually adding
controls to the tab pages. Not very difficult but I admit that Phoenix does a lot of the work for you.
Biggest trouble was putting in the event code & copying/modifying the Phoenix event functions.
Got most of it converted except for the progress bar and a few controls on the 2nd tab page.


Peter Weis

#97
Hallo Paul,

Quote
Not bad but I would have just inserted the As Column ( or Column AS ) below the split variable
check box and bumped the fields below it down. That way you wouldn't have had to increase
the tab/dialog size.

IDE have reprogrammed again, hope you like it better

Quote
Did you realize that you can get the program's command line  via COMMAND$ and get a plain
string? No mucking about with wasciiz ptr. not sure if there is any difference in the result as
you're only dealing with 1 field ( source file name ).


But already I get the pointer function of delivered, why should I then command can generate a string again! Command reads out the pointer and generates a string!

Quote
Just to be doing something, I worked up a DDT version starting with PBForms and manually adding
controls to the tab pages. Not very difficult but I admit that Phoenix does a lot of the work for you.
Biggest trouble was putting in the event code & copying/modifying the Phoenix event functions.
Got most of it converted except for the progress bar and a few controls on the 2nd tab page.

Hi Paul, it remains open to you all the way! You can reprogram it to DDT! Send me the code but then! I want to watch it!

In addition, today I have the function reprogrammed DoFormat, possessions disappear all Goto I do not like in programs and I also have changed the format of local variables Variable Split who is turned on. The format has not voted namely

regards Peter



Paul Elliott

Peter,

Old way or new way the GUI works. Just make sure you have the tab order matching the
natural order of the controls on screen.

Personally I like/use GOTOs to simplify a big block of code. For me it is much easier to make
major changes when needed without trying to figure out all the gotcha's when several levels
of if/then deep.

If you're going to indent the variables make sure you indent them correctly for all the functions/
methods/whatevers in a Class. And does that change the Column AS ? Because if you get
too many levels deep you will probably not have enough room between the variable and
the AS type.

I've noticed a couple errors in my splitting routine but am not sure it would fit in with your
programming structure now.
1) if there is something like   DIM A(1, 4) as LONG needs extra processing.
2) and  LOCAL a, b, c as LONG, d, e, f AS DWORD also need more work.
I got no responses either good/bad when I posted the code so I didn't do any further
work on this program. I made my changes in my program that all it does is split the
variables.

I don't really think posting my DDT version would do anything but confuse people.
I left out everything but the basic clicking/text changing code. No re-sizing or other
things taken care of by Phoenix. And haven't even looked at the progress bar other than
to disable the simple one used in the original program.

I finally found out why you added the extra check for #PBFORM. It really only matters when
it is in the middle of a procedure.
I don't know if there are other keywords that need the same treatment or not.

Keep going.


Peter Weis

#99
Hi Paul,

have new version. Can retrieve backup.
I answer your questions tomorrow!

Do not worry keep working :)

Peter Weis

Hi Paul,

Quote
Just make sure you have the tab order matching the
natural order of the controls on screen.

I want to give the program a lot of possibilities. While many controls are needed. Tab Order point, I then finally one!


Quote
Personally I like/use GOTOs to simplify a big block of code. For me it is much easier to make
major changes when needed without trying to figure out all the gotcha's when several levels
of if/then deep.

It must always decide themselves whether to use goto! I use it for 20 years not only in an emergency who can not be done differently. If Then blocks can be read much better.
Quote

If you're going to indent the variables make sure you indent them correctly for all the functions/
methods/whatevers in a Class. And does that change the Column AS ? Because if you get
too many levels deep you will probably not have enough room between the variable and
the AS type.

The function DoFormat is simply not mature! They should only is the entire function, class method should read all read AS variable, and put it in the beginning of the function! Then there are no space problems with AS

Quote
I've noticed a couple errors in my splitting routine but am not sure it would fit in with your
programming structure now.
1) if there is something like   DIM A(1, 4) as LONG needs extra processing.
2) and  LOCAL a, b, c as LONG, d, e, f AS DWORD also need more work.
I got no responses either good/bad when I posted the code so I didn't do any further
work on this program. I made my changes in my program that all it does is split the
variables.

There are certainly still many errors in the split routine. Send me your. Have you already written one above approach.
So all read from file function. Could work by Function End Function then to be used only for the Collection Class

Quote
I finally found out why you added the extra check for #PBFORM. It really only matters when
it is in the middle of a procedure.
I don't know if there are other keywords that need the same treatment or not.

There are many exceptions, the determined, we must note. But which are to come up with the times already! We will solve this already, because I'm sure! The function DoFormat is bad but we still need to work to find ways

regards Peter

Paul Elliott

Peter,

Sorry. I understand that English is not your primary language. But some of your responses don't
make sense to me.

1) I think it get it.
2) Personally I have an extreme dislike of nesting so many levels deep. it is only understandable
when fully documented on each level.
3) not sure I understand. an additional problem occurs when tab is set to 8 and very long variable
names are used.
4) only the 2 that I know of and I've run several source files from the PB forums thru it. and indenting
for Class Method variables which I only saw for the first time a couple weeks ago and have admitted
that I know nothing about & my programs might not work with that code.
but did not understand at all the 2nd line.
5) seems to me as you add more exceptions that the nesting level ( and complexity ) also expands.



Theo Gottwald

Peter, i offer you tranlation here. Write it in german and drope me a note then I'll translate it for you into english.

Peter Weis

Hi Paul,
my English is very bad! But I think that we already manage! And who it was not supposed to go I take Theo's supply!

Greetings Peter

Paul Elliott

Peter,

At least you're making an attempt. I can only speak English. Took 2 classes of French in school but
was never able to "think" in French.

Over the years, I've dealt with French, Spanish, Portugese, Italian and Singaporian people  and was always
amazed at their ability to not only speak English but to understand the culture.  Sorry to say I still
haven't learned anough of the culture of those people to understand some of their comments.