Dim Translation As String = MarcoStrikesAgain("Try to write chr")
Log(Translation)
'pads a string with spaces at start, to length L, returns first L characters
Sub LeftPad(S As String, L As Int) As String
Do While S.Length < L
S = " " & S
Loop
Return S.SubString2(0, L)
End Sub
'translates string to match example layout structure
Sub MarcoStrikesAgain(StringToTranslate As String) As String
Dim Index As Int = 0
Dim NumOnLine As Int = 0
Dim OutputString As String
For I = 0 To StringToTranslate.Length - 1
If NumOnLine = 0 Then
If Index = 0 Then
OutputString = OutputString & "Index Bit 31-24 Bit 23-16 Bit 15-8 Bit 7-0" & CRLF
End If
Index = Index + 1
OutputString = OutputString & LeftPad(Index, 5)
End If
OutputString = OutputString & LeftPad(StringToTranslate.CharAt(I), 11)
NumOnLine = NumOnLine + 1
If NumOnLine >= 4 Then
OutputString = OutputString & CRLF
NumOnLine = 0
End If
Next
If NumOnLine > 0 Then
OutputString = OutputString & CRLF
NumOnLine = 0
End If
Return OutputString
End Sub