_Title "Wrap up comments" 'b+ 2021-04-21 'Alter clipboard contents so that you can take some text while editing in IDE and paste it back altered and word wrapped to a given width.
'Try the above line with this one.
'And let's add some more stuff here.
' Ha, and even more stuff here.
'Hey, this is fun, let's keep going.
'And going, and going... like the Energizer bunny ;-))
ClipCommentsWrap 80 ' and here is clipboard paste in paragraph below
' Alter clipboard contents so that you can take some text while editing in IDE
' and paste it back altered and word wrapped to a given width. Try the above
' line with this one. And lets add some more stuff here. Ha, and even more stuff
' here. Hey, this is fun, lets keep going. And going, and going... like the
' Energizer bunny ;-))
' unfortunately, in order for the program to run you have to comment the lines.
s$
= StrReplace$
(s$
, Chr$(13) + Chr$(10), " ") s$
= StrReplace$
(s$
, Chr$(13), " ") s$
= StrReplace$
(s$
, Chr$(10), " ") s$ = StrReplace$(s$, "' ", "")
s$ = StrReplace$(s$, "'", "")
b$ = "' " + wrap$(s$, maxWidth - 2, t$)
s$ = t$
b$
= b$
+ Chr$(10) + "' " + wrap$
(s$
, maxWidth
- 2, t$
)
'This function returns the first segment of string less than or equal to maxLen AND
'the remainder of the string (if any) is returned in tail$ to be used by wrap$ again
p = MaxLen + 1
p = p - 1
wrap$
= Mid$(S$
, 1, MaxLen
): Tail$
= Mid$(S$
, MaxLen
+ 1) wrap$
= Mid$(S$
, 1, p
- 1): Tail$
= Mid$(S$
, p
+ 1) wrap$ = S$: Tail$ = ""
Function StrReplace$
(s$
, replace$
, new$
) 'case sensitive 2020-07-28 version added to oh 3/16 for inpbs LR
= Len(replace$
): lNew
= Len(new$
)
sCopy$ = s$ ' otherwise s$ would get changed
p
= InStr(sCopy$
, replace$
) sCopy$
= Mid$(sCopy$
, 1, p
- 1) + new$
+ Mid$(sCopy$
, p
+ LR
) p
= InStr(p
+ lNew
, sCopy$
, replace$
) StrReplace$ = sCopy$