简体   繁体   English

从As400 RPG程序读取值到字符串

[英]Read value from As400 RPG program to string

I am calling an as400 Rpg program from C#. 我正在从C#调用as400 Rpg程序。 I pass it 6 parameters with value and a 7th that is null and to be returned from the program. 我将值为6的参数和值为7的null传递给它,并将其从程序中返回。 I do receive a value from the program in the form of a byte. 我确实从程序中接收了一个字节形式的值。 The returned value is supposed to be either 1 or 0 depending on the execution of the program. 返回值应为1或0,具体取决于程序的执行情况。 在此处输入图片说明

在此处输入图片说明

I have tried using this string result = System.Text.Encoding.UTF8.GetString(byteArray); 我试过使用此string result = System.Text.Encoding.UTF8.GetString(byteArray);

Which returns this symbol. 会返回这个符号。 I have tried converting to Hex which returns F1. 我尝试转换为返回F1的十六进制。 How can i get the value of that byte in C#? 如何在C#中获取该字节的值? Again i know that the only possible values are 1 or 0. 再一次,我知道唯一可能的值是1或0。

Update if I use stringConverter.FromBytes(parameters["p7"].Value i always receive a 1. 如果我使用stringConverter.FromBytes(parameters [“ p7”]。Value,我总是收到1。

  ProgramParameters parameters = new ProgramParameters();
                parameters.Append("P1", cwbrcParameterTypeEnum.cwbrcInout, 3);
                parameters["P1"].Value = stringConverter.ToBytes(uwDecision.Param1.PadRight(paramLength, ' '));
                parameters.Append("P2", cwbrcParameterTypeEnum.cwbrcInput, 10);
                parameters["P2"].Value = stringConverter.ToBytes(uwDecision.Param2.PadRight(parmlenth2, ' '));
                parameters.Append("P3", cwbrcParameterTypeEnum.cwbrcInput, 10);
                parameters["P3"].Value = stringConverter.ToBytes(uwDecision.Param3.ToUpper().PadRight(parmlenth2, ' '));
                parameters.Append("P4", cwbrcParameterTypeEnum.cwbrcInput, 1);
                parameters["P4"].Value = stringConverter.ToBytes(uwDecision.Param4.PadRight(paramlength3, ' '));
                parameters.Append("P5", cwbrcParameterTypeEnum.cwbrcInput, 3);
                parameters["P5"].Value = stringConverter.ToBytes(uwDecision.Param5.PadRight(paramLength, ' '));
                parameters.Append("P6", cwbrcParameterTypeEnum.cwbrcInput, 3);
                parameters["P6"].Value = stringConverter.ToBytes(uwDecision.Param6.PadRight(paramLength, ' '));
                parameters.Append("P7", cwbrcParameterTypeEnum.cwbrcInout, 1);
                program.Call(parameters);


                var read = stringConverter.FromBytes(parameters["P7"].Value);

                isValid = read == "1";
                system.Disconnect(cwbcoServiceEnum.cwbcoServiceAll);

It appears that the message is using a Extended Binary Coded Decimal Interchange Code. 似乎该消息正在使用扩展二进制编码的十进制交换码。 You will need to convert or translate, however, it appears the system is attempting to send 0 and 1, just in it's representation. 您将需要转换或翻译,但是,系统似乎正尝试以其表示形式发送0和1。

EBCDIC Hex              EBCDIC Text        ASCII Translation
------------------    --------------     -----------------
       F1                    1                 241 = 0xF1
       F0                    0                 240 = 0xF0  

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM