This part as you can see from the images Aligns the = in a block via finding the space required to align the block. Hope some find it useful
Zebuddi.
Simply set up as a tool no params
1. select the group to align, RCM select copy, select tool name from menu or click tool icon if set up that way and the paste to the already highlighted block.
Alignment is mostly instantaneous, error msg's and beep if no alignment required or no = symbols found
On a side note of all the programming languages I have and keep playing with! I always come back here and to pb. I was going to try something like this in C++ but being 58 it's a bit late in life.
Code: Select all
Procedure.s AlignEqualsInGroup(sGroup.s)
EnableExplicit
Protected iRegex = CreateRegularExpression(#PB_Any, "(.+\=)((?<=\=).*)", #PB_RegularExpression_MultiLine)
If MatchRegularExpression(iRegex, sGroup)
Protected iDiffFlag.i, iNbr.i, iIndex.i, iMaxSpace.i, sReplacementString.s, sReturnString.s, Dim t$(0)
iNbr = ExtractRegularExpression(iRegex, sGroup, t$())
; *** Init 1st Element for Comparison
iMaxSpace = FindString(t$(0), Chr(61))
;
For iIndex = 1 To (iNbr-1) ; Start Loop at 2nd Element
If FindString(t$(iIndex), Chr(61)) > iMaxSpace
iMaxSpace = FindString(t$(iIndex), Chr(61))
iDiffFlag + 1
EndIf
Next
If Bool(iDiffFlag) > 0 ; If previously done 0r nothing to change
For iIndex = 0 To iNbr-1
If ExamineRegularExpression(iRegex, t$(iIndex))
NextRegularExpressionMatch(iRegex)
sReplacementString = Left(RegularExpressionGroup(iRegex, 1),Len(RegularExpressionGroup(iRegex, 1))-2) +
Space(iMaxSpace - (Len(RegularExpressionGroup(iRegex, 1))-2)) +
Chr(61) + RegularExpressionGroup(iRegex, 2)
sReturnString + sReplacementString
EndIf
Next
Else ; iDiffFlag = 0 Nothing to Align
MessageBeep_(1000)
MessageRequester("Equals Alignment ERR", "Nothing to Align")
EndIf
;{ *** CleanUp
FreeRegularExpression(iRegex)
FreeArray(t$())
;}
ProcedureReturn sReturnString
Else
MessageBeep_(1000)
MessageRequester("Equals Alignment ERR", "No Equals Statements Found")
ProcedureReturn #Null$
EndIf
DisableExplicit
EndProcedure
SetClipboardText(AlignEqualsInGroup(GetClipboardText()))