B4J Question JShell how to clean the buffer()

Omar Moreno

Member
Licensed User
Longtime User
Hello everyone.
Thank you for the help that you may be able to provide.
I have created a module with JShell to execute another program type Server and to be able to catch the LOG.
The problem I have is that the Buffer() parameter is not cleaned every time it catches new LOGs.

B4X:
Sub sh1_StdOut (Buffer() As Byte, Length As Int)
...
'how to clean the buffer()
End Sub

In each event that a LOG catches, when I print the data it leaves with the data of the previous LOG.
I have placed two examples programs the ShellLog.jar is responsible for calling the JarX.jar.
In the JarX.jar press the test buttons and you will see that in the window of the ShellLog.jar the LOGs come out but mixed with the data of the previous LOG.
How can this be resolved.
Thank you.
 

Attachments

  • ShellLogs.zip
    2.7 KB · Views: 181
  • JarX.zip
    2.4 KB · Views: 152

Erel

B4X founder
Staff member
Licensed User
Longtime User
There are several mistakes in your code.

Start with this:
B4X:
Sub sh1_StdOut (Buffer() As Byte, Length As Int)
   Log(BytesToString(Buffer, 0, Length, "utf8"))
End Sub

The output here is:

***
SERVIDOR INICIADO EL: 14/06/2018 08:59:44
CONECTADO A LA BASE DE DATOS: OK
***
P1 SE HA EJECUTADO OK
P2 SE HA EJECUTADO EN 20 SEGUNDOS
P3 NO SE HA EJECUTADO, VERIFIQUE
P4 SE HA EJECUTADO OK

Looks correct.
 
Upvote 0

Omar Moreno

Member
Licensed User
Longtime User
Thank you for the correction.
It worked very well with the real server.

Another question: the parameter for the encoding "utf8" or "UTF-8" does not show the tildes
 
Upvote 0
Top