Protected Function Dumbtext2BF(ByVal textstr As String, ByVal numBins As Short)
If numBins <= 0 Then
Throw New Exception("error: too few bins")
End If
Dim bins(numBins - 1) As Integer
Dim diff As Integer = Math.Floor(127 / numBins)
For i As Integer = 0 To numBins - 1
bins(i) = (i + 1) * diff
Next
Dim codestr As String = writeBins(numBins, diff)
Dim counter As Long = 0
Dim currbin As Integer = 0
Dim newbin As Integer = 0
Dim c As Integer
While (counter < textstr.Length)
c = AscW(textstr(counter))
newbin = findClosestBin(c, bins, currbin)
codestr &= printDifference(newbin - currbin, ">", "<")
codestr &= printDifference(c - bins(newbin), "+", "-")
codestr &= "."
currbin = newbin
bins(newbin) = c
counter += 1
End While
Return codestr
End Function