Skip to main content

Posts

PowerBuilder Code Beautifier / Formatter

A new code beautifier for PowerBuilder (PowerScript) code has been added to NotepadPB:https://powertothebuilder.com/NotepadPB.html This is the first and initial version which uses a very simple approach to formatting the code. NotepadPB will use multiple passes to adjust spacing, casing, and indenting of the script. The process works as follows:Start by tokenizing the script by splitting everything into words or characters (characters for things like quotes). We then loop through each token and determine if it's a keyword, datatype, quote, comment, carriage return, or user defined text (like variable names). We change the case on keywords and datatypes, and track indent level if the keyword is an indent-able keyword (e.g. IF, FOR, CHOOSE, etc). Comments and quoted text are ignored, we don't want to modify them. At the end, we reassemble our script.

In our second pass, we parse our script by line. We will apply some formatting on a line by line bases. The second pass is meant to…

Develop a web browser in PowerBuilder.

The inclusion of the new Chromium Web Browser control in PowerBuilder 2019R2 gave us the possibility to develop our own web browser in PowerBuilder. We could have done this already with the MS Web Browser control but we would have had to accept the limitation of IE. With the new PowerBuilder control, we know that we'll have maximum compatibility with the most up to date web sites. Microsoft even accepts this after converting Edge to use Chromium. 
So the big question, why? The short answer to that is... to learn something new. I've been developing software for 20 years. In those years I've developed countless of useless applications just for the sake of learning (I once developed a fully functional version of Mine Sweeper in Silverlight).
Below is what we'll create. We'll use the PB Chromium Web Browser control with the Ultimate Suite for PowerBuilder Tabbed Caption window.



Some things we'll accept right away; 1) This browser is extremely basic so we won't hav…

Custom captions, everyone's doing it...

We see custom captions all over the place, used by many software vendors. Microsoft even prefers them for their largest applications (Office, VS, Edge, etc). Why use a custom caption in your window? The simplest answer is, you get to make use of otherwise wasted real estate. With a custom caption you can add buttons, search boxes, status messages, tabs, etc., you name it.

Ultimate Suite for PowerBuilder offers 3 different types of custom captions window.

1) Basic

With the basic option you get the ability to add toolbar buttons to the caption. You can also add any other control you like in the window painter. The controls you add would simply overlay the caption.



2) Tabbed

The tabbed caption window is extremely unique to Ultimate Suite for PowerBuilder. It allows you to have a browser like UI. This is prefect for single purpose applications (like a web browser). A perfect example of where this UI fits perfect can be found here: https://powertothebuilder.com/NotepadPB.html



3) Caption-le…

Update the look of all your PowerBuilder message boxes in a few easy steps

One simple way to update your PowerBuilder application is to convert all your message boxes to use the Windows 10 style PowerMessage object from Ultimate Suite for PowerBuilder:


Having to change all message boxes one by one would be too time consuming. You also run the risk of missing some. Instead, what we can do is create a new, overloaded, global function that overrides the built in PowerBuilder MessageBox function.

Before we do this, let's setup PowerMessage.

Make sure you have the Ultimate Suite for PowerBuilder PBL's or PBD's added to your library list.

Next, create a new global variable:

n_cst_powermessage PowerMessage

In the Open event of your main frame window, register your window with PowerMessage:

PowerMessage.of_Register(THIS)

PowerMessage is now setup and ready to be used. Note that at this point, if you like, you call call into PowerMessage directly to display the updated message:

PowerMessage.MessageBox("Title", "Message Text")

But we want …