I am calling an as400 Rpg program from C#. I pass it 6 parameters with value and a 7th that is null and to be returned from the program. 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.
I have tried using this string result = System.Text.Encoding.UTF8.GetString(byteArray);
Which returns this � symbol. I have tried converting to Hex which returns F1. How can i get the value of that byte in C#? Again i know that the only possible values are 1 or 0.
Update if I use stringConverter.FromBytes(parameters["p7"].Value i always receive a 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);