A new code beautifier for PowerBuilder (PowerScript) code has been added to NotepadPB:
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 adjust alignments for lines that end in ampersand. We'll also take the opportunity to remove blank lines.
e.g. IF val = TRUE OR &
val2 = FALSE THEN <----add spacing to align this line with the top line
- The third will also deal with the script on a per line basis. This time we'll apply some line spacing around code blocks:
IF val = TRUE THEN
IF val2 = FALSE THEN
- The forth and final pass will again remove any unneeded line spacing.
- Syntax highlighting
- Syntax folding
- Go to definition when viewing a PowerBuilder source file (.sr*)