Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
PrintW - print a long string, breaking it at the last space or hyphen before col. 79
#15
(04-19-2024, 12:22 AM)PhilOfPerth Wrote:
(04-17-2024, 08:57 PM)mdijkens Wrote: If you test your code, always test the limits.
empty strings, long strings, etc.
Yours does not like long lines without dashes or spaces

Not sure I understand @mdijkens...  I thought word-wrap meant to wrap the next word if the line was too long. Are you refering to extra-long words, and splitting them at a syllable with a hiphen? Long strings are handled ok with my line-wrap, but, no it doesn't split words. And as for empty strings... why would you wrap them?  Confused

perhaps this
Code: (Select All)
PrintW "abcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"
Sub PrintW (Msg$)
    Dim Temp$, Split$, breakspace%, breakdash%
    Temp$ = Msg$
    While Len(Temp$) > 79
        ''   Print Len(Temp$)
        Split$ = Left$(Temp$, 79)
        breakspace% = _InStrRev(Split$, " ")
        breakdash% = _InStrRev(Split$, "-")
        ''   Print Split$
        ''   Print breakspace%; breakdash%
        ''   Input X$
        If breakspace% > breakdash% Then
            Split$ = Left$(Split$, breakspace%)
            Temp$ = Mid$(Temp$, breakspace% + 1, Len(Temp$))
        Else
            Split$ = Left$(Split$, breakdash%)
            Temp$ = Mid$(Temp$, breakdash% + 1, Len(Temp$))
        End If
        ''  Print "*"; Len(Temp$)
        Print Split$
    Wend
    Print Temp$
End Sub
b = b + ...
Reply


Messages In This Thread
RE: PrintW - print a long string, breaking it at the last space or hyphen before col. 79 - by bplus - 04-19-2024, 12:32 AM



Users browsing this thread: 1 Guest(s)