[Gambas-user] Text-Wrapping
Brian G
brian at westwoodsvcs.com
Thu Nov 12 16:24:53 CET 2020
Hans,
Your method outputs some strange lines for example the following original line
Stephen, taking his ashplant from its leaningplace, followed them out and, as they went down the ladder, pulled to the slow iron door and locked it. He put the huge key in his inner pocket.
Sample of normal wrap
Stephen, taking his ashplant from its leaningplace, followed
them out and, as they went down the ladder, pulled to the slow
iron door and locked it. He put the huge key in his inner pock-
et.
Output from your wrap
Stephen, taking
his ashplant from its leaningplace, followed them out and, as they
went down the ladder, pulled to the slow iron door and locked it. He
put the huge key in his inner pocket.
There are a few other strange outputs as well.
Thank You
Brian G
From: "Hans Lehmann" <hans at gambas-buch.de>
To: "Gambas mailing list" <user at lists.gambas-basic.org>
Sent: Thursday, November 12, 2020 12:54:52 AM
Subject: Re: [Gambas-user] Text-Wrapping
Hello,
after the hints in the list and with regard to the case of application (description in a RSS feed) this solution was found:
8<---- Using Recursion ------------------------------------------------
' Gambas module file
Public Sub Main()
Dim sFile As String = File.Load("./testtext.txt")
Print W(sFile, 70)
End
Private Function W(TextToWrap As String, iLength As Integer) As String
Dim iIndex As Integer
Dim sTL, sTR As String
Dim aLines As String[]
If Len(TextToWrap) <= iLength Then Return TextToWrap
aLines = Split(TextToWrap, gb.NewLine)
iIndex = RInStr(TextToWrap, " ", iLength)
If iIndex = 0 Then iIndex = iLength
sTL = RTrim(Left(TextToWrap, iIndex - 1))
sTR = LTrim(Right(TextToWrap, -iIndex))
Return sTL & gb.lf & W(sTR, iLength)
End
8<---------------------------------------------------------------------
With kind regards
Hans
ORIGINAL:
Die Fehlerbehandlung beginnt mit einer Analyse von Fehlerkategorien, beschreibt die Fehleranalyse zur Entwicklungszeit eines Programms (Debugger) und verweist auf Strategien, wie Sie Fehler erkennen, abfangen und vermeiden können.
RESULT:
Die Fehlerbehandlung beginnt mit einer Analyse von Fehlerkategorien,
beschreibt die Fehleranalyse zur Entwicklungszeit eines Programms
(Debugger) und verweist auf Strategien, wie Sie Fehler erkennen,
abfangen und vermeiden können.
----[ http://gambaswiki.org/wiki/doc/netiquette ]----
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20201112/cedab5c2/attachment-0001.htm>
More information about the User
mailing list