' Hi, my name is Steve. This is my example. It works just like a
' comment and is excluded from my code, Because of the undefined $IF block.
' Instead of an all inclusive word wrap, I’d love to see a “PRINT PREVIEW” tool.
' For example, let’s say I’m working in a SCREEN 0 environment. What I’d love
' to do is hit CTRL-P (for preview) and then have a screen pop-up which I can
' click to set to a 80x25 text screen, and then type on.... Thus, if I type,
' “Hello my name is Steve. I like to program in QB64, but sometimes I run into
' issues with formatting and output being longer than a single line.”, I can see
' the text on my desired output screen and adjust it so my words are spaced
' properly and don’t break in the middle. Once finished, all I need to do is
' CTRL-V to copy the properly formatted text, close the preview, and then paste
' it into the IDE where I was working last. Word wrap doesn’t seem too useful
' to me, but a print preview sounds like it’d be a real winner!
' I dont think word wrap would do the IDE justice. Its perfect. Its a simple
' intuitive IDE. Line continuations can be done using the underscore, I think.
' For wrapping printouts, that would be a project for notepad. But onscreen, I
' just cant see the necessity. It would be nice to be able to continue really
' long literals using a system like that, though.
' With all the under the hood work that would be needed to deal with syntax
' checking, code flow, indentations, ect. ect. When we already have this nice
' and handy key on the keyboard to deal with it labeled ENTER why waste the
' time and potential can of worms trying to force the QB64 IDE to do even more.
' It already has too much glut clutter anyway. You want word wrap then use
' notepad or a word document processor.
' Quote If theres one thing I would love to see, it would be a way to collapse
' SUB/FUNCTION blocks that one is finished working with. I presume that would be
' challenging to implement or it would have been done by now. Well I have a
' suggestion for that, build a custom library for the app and who knows if it
' might not be helpful for others or serve as a starter with code already
' tested? When you have one worked out move it into library.
Above is some example text I pulled out of this thread and ran through following code Not in IDE but a Stand Alone .exe that takes contents of clipboard and rearranges them as word wrapped comments with a width limit of 80 including a single quote and space.
_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$
Merely click the exe maybe sitting on your desktop and automatically the contents of the clipboard is wrapped to 80 char widths with comment space starting each line.