1. Berka Frenfert
  2. PowerBuilder
  3. Tuesday, 16 August 2022 08:14 AM UTC

Sometimes script is divided into multiple events because of script length exceeds the limit which is i guess 1500 or 1000 lines. Having proper indentation is big problem with even smaller than 500 lines. I have no idea if any PowerBuilder version have code formatting option.

Better option is to use online formatter for PowerScript which i think Appeon can do for good.  Anyway idea is good. Please provide the url if its there on web already. Thanks

Accepted Answer
Andreas Mykonios Accepted Answer Pending Moderation
  1. Wednesday, 17 August 2022 05:50 AM UTC
  2. PowerBuilder
  3. # Permalink

PBLPeeper has a tool to format scripts.

Also NotepadPB has a code beautifier (PowerBuilder Code Beautifier / Formatter (powertothebuilder.blogspot.com)).

Andreas.

Comment
  1. Berka Frenfert
  2. Wednesday, 17 August 2022 07:17 AM UTC
That nice little tool still helping. I did not know about it. It worked nicely.

another post by Bruce Armstrong : https://community.appeon.com/index.php/qna/q-a/pbl-peeper



Thanks a lot.
  1. Helpful
  1. Andreas Mykonios
  2. Wednesday, 17 August 2022 07:26 AM UTC
By the way the three following choices (sql formatter, stringer and sql parser) are also pretty nice. For sql formatter the only limitation i've found is that it works only with select statements, and has issues sometimes with really complex statements.

Andreas.
  1. Helpful
  1. Berka Frenfert
  2. Wednesday, 17 August 2022 09:21 AM UTC
Hi Andres,

Code I am dealing with used very little hand written Sql and used datastores and hidden datawindows instead. Yes, very complex sql statements are very difficult to handle. I once used to deal with those when i was trying to create crosstab at runtime. I remember once a complex sql statement was good but not accepted by grid datawindow. I had to make a view of the sql and used the view instead. I strictly instructed other developers to avoid using sql directly in scripts.
  1. Helpful
There are no comments made yet.
Roland Smith Accepted Answer Pending Moderation
  1. Tuesday, 16 August 2022 20:28 PM UTC
  2. PowerBuilder
  3. # 1

At one time in the single digit versions of PowerBuilder there was a script limit of 64k. That limit was eliminated at some point.

Having really long scripts makes it difficult for any developer other than the original to understand. Long scripts should be broken out into functions in the same object or in the case of windows, in a non-visual object.

 

Comment
  1. Berka Frenfert
  2. Wednesday, 17 August 2022 07:33 AM UTC
Hi Chris,

You are right , for me that code in always headache. It was modified by more than 10 developers in 2 decades. I have no heart to add even comments because in many places code makes no sense. ... lol ... I just do 1 task at one time and expect no more when i am done. My code is short and well commented because no other developer gonna read and fix it except for me.



PB12.5 still have that limit.
  1. Helpful
There are no comments made yet.
Benjamin Gaesslein Accepted Answer Pending Moderation
  1. Tuesday, 16 August 2022 08:56 AM UTC
  2. PowerBuilder
  3. # 2

Hi Berka,

I don't know of an online formatter that can handle PowerScript. Some code editors like VS Code can highlight corresponding brackets/if-then-pairs/etc which might help you identify what needs to be indented. Someone has provided syntax highlighting for PB in Vs Code, too: https://marketplace.visualstudio.com/items?itemName=florianbaer.pb-syntax

But long methods are generally considered a code smell. They're very hard to understand and just tend to get bigger and bigger. Many levels of indentation are hard to read per se. The best way to improve readablity would be to refactor and extract meaningfully-named smaller methods.

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.