I thing that my problem are in the line writefile...I only send one letter. If I want to send the word UPDATE only the U are sended...
I send my code to the Mr. angevoyageur. He is a moderator if Im correct. If he help-me I send to you...
I don't know if this has any value to resolve your issues or not, but remember that in the new MT4 build, strings are 16bit Wide Unicode characters, not the usual 8-bit ASCII/ANSII Characters.
ASCII characters in Wide Unicode are separated by ZERO bytes, and since many functions that work with ASCII/ANSI end a string with a ZERO byte (ASCIIZ), they will usually only process ONE character. A behaviour which you have just described for your "writefile" case.
So make sure you are using the appropriated functions that are able to handle and manipulate Wide Unicode and not ASCII/ANSI.
This line call the namedpipe in mt4 and mt4 send a message for him.
I try to change to CallNamedPipeW but any thing happens.
So I back with ansi mode and read the cbRead result. If I have the text in mt4 to send "123456" the cbRead is = 7. I put any text, if length = 100 I receive 101. But only the first charecter is read like in UPDATE where I receive U and cbRead = 7.
To get the value in cbRead I use it
For i = 0 To cbRead - 1
textIn = textIn & Chr(textInArray(i))
Next i
the textInArray.length is ever = 257. If my string are UPDATE is 257 and if my string are UP is 257.
EDIT: I know why is = 257:
Dim res As Integer = 0
Dim cbRead As Integer
Dim textInLength As Integer
Dim textOut() As Byte
Dim textIn As String
Dim textInArray() As Byte
Message_To_MT4 = Comando 'La no script mql ele vai analisar o comando e nos responder. Abaixo, ele envia o comando e lê a resposta.
textOut = System.Text.Encoding.Default.GetBytes(Message_To_MT4)
textInLength = 256
ReDim textInArray(textInLength)
Do 'Wait for a connection, block until a client connects
'Dim exists As Boolean = WaitNamedPipe(szPipeName, NMPWAIT_WAIT_FOREVER)
Try
res = CallNamedPipeA(szPipeName, textOut(0), Message_To_MT4.Length + 1, textInArray(0), textInLength, cbRead, PIPE_NOWAIT)
Catch ex As Exception
MsgBox(Err.LastDllError.ToString)
End Try
If Err.LastDllError = 231 Then
Thread.Sleep(1000)
Envia_APP_TO_MT4(Comando)
Exit Sub
End If
If res = 0 Then
Debug.Print(Err.LastDllError)
'significa que deu erro
Server_PIPE.Text = "MT4 Server PIPE"
Server_PIPE.Icon = New Icon("D:\ProgressError.ico")
Else
'Conexão estabelecida
'string from MT4 = UPDATE
textIn = ""
MsgBox(cbRead.toString) '=7
MsgBox(textInArray.Length) '=257
For i = 0 To cbRead - 1
textIn = textIn & Chr(textInArray(i))
Next i
MsgBox(textIn)
rohitkat: Any success friends. Me also stuck with NamedPips communication issue on new MT4 build 600. I have tested for change of 'A' to 'W' but not working.
It seems to me that if you change your DLL call using 'W' function instead of 'A', you have also to change your pipe server code. A better approach can be to convert your Unicode strings to ANSI with StringToCharArray() (link provided is for mql5, but you can find help in MQL4 reference by pressing F1 in MetaEditor). See here and here.
I don't know if this has any value to resolve your issues or not, but remember that in the new MT4 build, strings are 16bit Wide Unicode characters, not the usual 8-bit ASCII/ANSII Characters.
ASCII characters in Wide Unicode are separated by ZERO bytes, and since many functions that work with ASCII/ANSI end a string with a ZERO byte (ASCIIZ), they will usually only process ONE character. A behaviour which you have just described for your "writefile" case.
So make sure you are using the appropriated functions that are able to handle and manipulate Wide Unicode and not ASCII/ANSI.
This is not necessarily true, it depends of the encoding, which Unicode is used. An Unicode character can be from 1 to 4 byte(s).
SRC Edited. Still having issues with calling upon the server file after updating to 'W'. Any suggestions?
I have the same problem...
I thing that my problem are in the line writefile...I only send one letter. If I want to send the word UPDATE only the U are sended...
I send my code to the Mr. angevoyageur. He is a moderator if Im correct. If he help-me I send to you...
I have the same problem...
I thing that my problem are in the line writefile...I only send one letter. If I want to send the word UPDATE only the U are sended...
I send my code to the Mr. angevoyageur. He is a moderator if Im correct. If he help-me I send to you...
I don't know if this has any value to resolve your issues or not, but remember that in the new MT4 build, strings are 16bit Wide Unicode characters, not the usual 8-bit ASCII/ANSII Characters.
ASCII characters in Wide Unicode are separated by ZERO bytes, and since many functions that work with ASCII/ANSI end a string with a ZERO byte (ASCIIZ), they will usually only process ONE character. A behaviour which you have just described for your "writefile" case.
So make sure you are using the appropriated functions that are able to handle and manipulate Wide Unicode and not ASCII/ANSI.
Thanks Sir FMIC, I thing that you are correct.
I am testing and I will post the results.
I my app side, in vb.net I have this code:
This line call the namedpipe in mt4 and mt4 send a message for him.
I try to change to CallNamedPipeW but any thing happens.
So I back with ansi mode and read the cbRead result. If I have the text in mt4 to send "123456" the cbRead is = 7. I put any text, if length = 100 I receive 101. But only the first charecter is read like in UPDATE where I receive U and cbRead = 7.
To get the value in cbRead I use it
the textInArray.length is ever = 257. If my string are UPDATE is 257 and if my string are UP is 257.
EDIT:
I know why is = 257:
Dim res As Integer = 0 Dim cbRead As Integer Dim textInLength As Integer Dim textOut() As Byte Dim textIn As String Dim textInArray() As Byte Message_To_MT4 = Comando 'La no script mql ele vai analisar o comando e nos responder. Abaixo, ele envia o comando e lê a resposta. textOut = System.Text.Encoding.Default.GetBytes(Message_To_MT4) textInLength = 256 ReDim textInArray(textInLength) Do 'Wait for a connection, block until a client connects 'Dim exists As Boolean = WaitNamedPipe(szPipeName, NMPWAIT_WAIT_FOREVER) Try res = CallNamedPipeA(szPipeName, textOut(0), Message_To_MT4.Length + 1, textInArray(0), textInLength, cbRead, PIPE_NOWAIT) Catch ex As Exception MsgBox(Err.LastDllError.ToString) End Try If Err.LastDllError = 231 Then Thread.Sleep(1000) Envia_APP_TO_MT4(Comando) Exit Sub End If If res = 0 Then Debug.Print(Err.LastDllError) 'significa que deu erro Server_PIPE.Text = "MT4 Server PIPE" Server_PIPE.Icon = New Icon("D:\ProgressError.ico") Else 'Conexão estabelecida 'string from MT4 = UPDATE textIn = "" MsgBox(cbRead.toString) '=7 MsgBox(textInArray.Length) '=257 For i = 0 To cbRead - 1 textIn = textIn & Chr(textInArray(i)) Next i MsgBox(textIn)If I use CallNamedPipeW I receive the error number 2 ERROR_FILE_NOT_FOUND
Any success friends. Me also stuck with NamedPips communication issue on new MT4 build 600. I have tested for change of 'A' to 'W' but not working.
I don't know if this has any value to resolve your issues or not, but remember that in the new MT4 build, strings are 16bit Wide Unicode characters, not the usual 8-bit ASCII/ANSII Characters.
ASCII characters in Wide Unicode are separated by ZERO bytes, and since many functions that work with ASCII/ANSI end a string with a ZERO byte (ASCIIZ), they will usually only process ONE character. A behaviour which you have just described for your "writefile" case.
So make sure you are using the appropriated functions that are able to handle and manipulate Wide Unicode and not ASCII/ANSI.