Bladimir Silva Toro Active Member Licensed User Longtime User Jun 1, 2018 #1 Hello friends I need to send a list of products in Bytes to a thermal printer connected by bluetooth. To make this possible, I send the data by line of bytes to the printer. For this I create a variable type Byte using this code: Code: Copy Dim Line1Byte () as Byte The problem is that I do not know how many Byte variables I should create since the list of products can have from 1 product to N products. I wrote this code but it gives me error: Code: Copy For m = 0 To ListProd.Size-1 Dim Line&m&Byte () As Byte Next In the end, I need to create the same number of Byte variables that are in the list of products I need to know if in B4A it is possible to create these variables in a dynamic way. I am very grateful with the solution that you can give me.
Hello friends I need to send a list of products in Bytes to a thermal printer connected by bluetooth. To make this possible, I send the data by line of bytes to the printer. For this I create a variable type Byte using this code: Code: Copy Dim Line1Byte () as Byte The problem is that I do not know how many Byte variables I should create since the list of products can have from 1 product to N products. I wrote this code but it gives me error: Code: Copy For m = 0 To ListProd.Size-1 Dim Line&m&Byte () As Byte Next In the end, I need to create the same number of Byte variables that are in the list of products I need to know if in B4A it is possible to create these variables in a dynamic way. I am very grateful with the solution that you can give me.
KZero Active Member Licensed User Longtime User Jun 1, 2018 #2 Code: Copy 'to store bytes line For m = 0 To ListProd.Size-1 Dim LineByte() As Byte '= your bytes List1.Add(LineByte) Next 'to get bytes line Dim LineByte() As Byte LineByte = List1.Get(1) ' 1 is your line number Upvote 0
Code: Copy 'to store bytes line For m = 0 To ListProd.Size-1 Dim LineByte() As Byte '= your bytes List1.Add(LineByte) Next 'to get bytes line Dim LineByte() As Byte LineByte = List1.Get(1) ' 1 is your line number
Bladimir Silva Toro Active Member Licensed User Longtime User Jun 1, 2018 #3 Thank @KZero What I need, if I have 10 products in the list, for example, I have to create 10 Byte-type variables. The problem is that the list of products can have from 1 product to N products Thank you Upvote 0
Thank @KZero What I need, if I have 10 products in the list, for example, I have to create 10 Byte-type variables. The problem is that the list of products can have from 1 product to N products Thank you
MarkusR Well-Known Member Licensed User Longtime User Jun 1, 2018 #4 its more a class object, you have a product class and a function/sub that make this bytes for the printer or u store the bytes direct there. this product object variable you can hold in a list and the source from this maybe comes from a sqlite database or server side database. or store a product in a type / struct Code: Copy Type Product(Name As String,LineBytes() As Byte) Code: Copy Dim Products As List Products.Initialize Dim ProductX As Product ProductX.Name = "ABC" Dim Bytes(100) As Byte ProductX.LineBytes = Bytes Products.Add(ProductX) Last edited: Jun 1, 2018 Upvote 0
its more a class object, you have a product class and a function/sub that make this bytes for the printer or u store the bytes direct there. this product object variable you can hold in a list and the source from this maybe comes from a sqlite database or server side database. or store a product in a type / struct Code: Copy Type Product(Name As String,LineBytes() As Byte) Code: Copy Dim Products As List Products.Initialize Dim ProductX As Product ProductX.Name = "ABC" Dim Bytes(100) As Byte ProductX.LineBytes = Bytes Products.Add(ProductX)
Erel B4X founder Staff member Licensed User Longtime User Jun 3, 2018 #5 Use BytesBuilder: [B4X] BytesBuilder - simplifies working with arrays of bytes Upvote 0