TSV Posted November 9, 2014 Share Posted November 9, 2014 I use GetResponseEx function in my C# app to get values from Clipper board. But when I try to get values of several consecutive variables, "P1..3" for example, I get reply without spaces, so it's impossible to split it to individual values. So if P1=10, P2=200, P3=3, I get "102003". RawGetResponseEx function gives the same result but with "-" sign at the end: "102003-". How can I get many values, separated with specified (known) charachter? Something like "10 200 3" or "10&200&3". Link to comment Share on other sites More sharing options...
TSV Posted November 9, 2014 Author Share Posted November 9, 2014 I use GetResponseEx function in my C# app to get values from Clipper board. But when I try to get values of several consecutive variables, "P1..3" for example, I get reply without spaces, so it's impossible to split it to individual values. So if P1=10, P2=200, P3=3, I get "102003". RawGetResponseEx function gives the same result but with "-" sign at the end: "102003-". How can I get many values, separated with specified (known) charachter? Something like "10 200 3" or "10&200&3". Link to comment Share on other sites More sharing options...
TSV Posted November 10, 2014 Author Share Posted November 10, 2014 I've been exploring the problem and found that actually there are separators (new line symbols I suppose) between values in the received string. The problem is that TextBox control does not show it, but the simple Label control does! So the reason is in my app, not in PMAC. [attachment=862] Link to comment Share on other sites More sharing options...
TSV Posted November 10, 2014 Author Share Posted November 10, 2014 I've been exploring the problem and found that actually there are separators (new line symbols I suppose) between values in the received string. The problem is that TextBox control does not show it, but the simple Label control does! So the reason is in my app, not in PMAC. Link to comment Share on other sites More sharing options...
fahmad Posted November 10, 2014 Share Posted November 10, 2014 PMAC's handshake control variable I3 controls handshake characters that come back from PMAC along with the response. For I3=2 (Pewin32Pro2 default), response to multiple queries are as follows: With I3=2: P1..3...... ; Valid command requiring data response 255075 #1J+........ ; Valid command not requiring data response ....... ; Acknowledging character UUU .......... ; Invalid command ............. ; PMAC reports error It is responsibility of caller to handle all control characters. TextBox does not add line with . In GetResponseEx() if you pass the bAddlf flag as TRUE then it will replace with . See the code bellow from PcommServer getResponseEx() function. rret = GetLineEx( dwDevice, str, 255); cc = COMM_CHARS(rret); if(cc > 0) { // Change '\r' or add linefeed if requested if(bAddLF && str[cc - 1] == '\r') str[cc - 1] = '\n'; ret += cc; answer += str; } Link to comment Share on other sites More sharing options...
fahmad Posted November 10, 2014 Share Posted November 10, 2014 PMAC's handshake control variable I3 controls handshake characters that come back from PMAC along with the response. For I3=2 (Pewin32Pro2 default), response to multiple queries are as follows: With I3=2: P1..3...... ; Valid command requiring data response 255075 #1J+........ ; Valid command not requiring data response ....... ; Acknowledging character UUU .......... ; Invalid command ............. ; PMAC reports error It is responsibility of caller to handle all control characters. TextBox does not add line with . In GetResponseEx() if you pass the bAddlf flag as TRUE then it will replace with . See the code bellow from PcommServer getResponseEx() function. rret = GetLineEx( dwDevice, str, 255); cc = COMM_CHARS(rret); if(cc > 0) { // Change '\r' or add linefeed if requested if(bAddLF && str[cc - 1] == '\r') str[cc - 1] = '\n'; ret += cc; answer += str; } Link to comment Share on other sites More sharing options...
fahmad Posted November 10, 2014 Share Posted November 10, 2014 After I posted the response I noticed that this text box ate all my control characters Correct sequence of response with I3=2 is (I removed <> around the control characters) With I3=2: P1..3 CR ...... ; Valid command requiring data response 25 CR 50 CR 75 CR ACK ; PMAC responds with requested data Link to comment Share on other sites More sharing options...
fahmad Posted November 10, 2014 Share Posted November 10, 2014 After I posted the response I noticed that this text box ate all my control characters Correct sequence of response with I3=2 is (I removed <> around the control characters) With I3=2: P1..3 CR ...... ; Valid command requiring data response 25 CR 50 CR 75 CR ACK ; PMAC responds with requested data Link to comment Share on other sites More sharing options...
Recommended Posts