Android Question How translate Java code to B4A

vecino

Well-Known Member
Licensed User
Longtime User
Hello, how you can translate that code?, Mainly "(byte)"

java:

final byte txt_big[] = { 0x1b, 0x21, (byte) 0xb0, '-', '-', '-', '-', '-', 'H', 'e', 'l', 'l', 'o', '-', '-', '-', '-', '-', '-', '\n' };

B4A:

txt_big() = chr(0x1b) & chr(0x21) & ?????

Thanks and regards.
 

derez

Expert
Licensed User
Longtime User
From the documentation, Keywords :
15.png
Array

Creates a single dimension array of the specified type.
The syntax is: Array As type (list of values).
Example:
Dim Days() As String
Days = Array As String("Sunday", "Monday", ...)

In your case:
B4X:
Dim txt_big() as byte
txt_big = Array as byte (0x1b, 0x21, ....)

If you need to translate the string to chars then:
B4X:
Dim txt_big() As Byte
Dim bc As ByteConverter
Dim c() As Byte = bc.StringToBytes("    hello      " ,"UTF8")
txt_big = Array As Byte (0x1b, 0x21,c(0),c(1),c(2)...c(15),10)
As far as I know, "\n" = CRLF and is 10 ascii so put 10 as last item.
 
Last edited:
Upvote 0
Top