For example I’d want to output the strings “Test” and “String” as
T S
e t
s r
t i
n
g
I used the PREFORMATTED button but the n and g are still in the wrong place
For example I’d want to output the strings “Test” and “String” as
T S
e t
s r
t i
n
g
I used the PREFORMATTED button but the n and g are still in the wrong place
Output? I am unclear what you mean here. To PDF? To paper? To a Text Area? To a Canvas?
If it is in a Canvas, you can use this code:
Dim captions() As String = Array("Test", "String", "Vertical")
Dim x, y As Double
//Initialise x and y
x=0
y=g.FontAscent
Dim deltax, deltay As Double
deltax = g.TextWidth(&u09) //Width of a tabulation
deltay = g.TextHeight
For each caption as String in captions
y = g.FontAscent
//Split the caption in characters
Dim chars() as String = caption.Split("")
For each c as String in chars
g.DrawText( c, x, y )
y = y + deltay
Next c
x = x + deltax
Next caption
To console or System.DebugLog
It’s debugging only code.
Dim words() As String = Array("Test", "String", "Vertical")
OutputFormatVertical(words)
Private Sub OutputFormatVertical(words() As String)
//find the longest word
Dim maxLength As Integer
For each word as string in words
maxLength = max(maxLength, word.Length)
Next word
//Make each word the same length
for i as Integer = 0 to words.LastIndex
Dim word As String = words(i)
While word.Length < maxLength
word = word + " "
Wend
words(i) = word
next i
//Now create a line with one char from each word
Dim lines() As String
lines.ResizeTo(maxLength-1)
For i as Integer = 0 to maxLength-1
Dim lineChars() As String
For each word as String in words
lineChars.Append word.Middle(i, 1) + " "
Next word
lines(i) = String.FromArray(lineChars,"")
Next i
//Now output all lines
#if TargetConsole
Print String.FromArray(lines, EndOfLine)
#else
System.DebugLog String.FromArray(lines, EndOfLine)
#endif
End Sub