[Stackoverflow] [Progress OpenEdge ABL] how to convert octal to binary with field input in PROGRESS OpenEdge 4gl..?

Status
Not open for further replies.
A

Arifudin

Guest
I want the result to be output using input field please help me.

function oct2bin returns character ( input octalString as character ):

define variable i as integer no-undo. define variable n as integer no-undo. define variable c as character no-undo. define variable result as character no-undo.

n = length( octalString ).

if n < 2 or substring( octalString, 1, 1 ) <> "~" then /* a valid octalString begins with "" */ result = ?. else do i = 2 to n:

Code:
  c = substring( octalString, i, 1 ).

  if asc( c ) < 48 or asc( c ) > 55 then                        /* a valid octalString only contains the digits 0 thru 7        */
    do:
      result = ?.
      leave.
    end.

  case c:
    when "0" then result = result + "000".
    when "1" then result = result + "001".
    when "2" then result = result + "010".
    when "3" then result = result + "011".
    when "4" then result = result + "100".
    when "5" then result = result + "101".
    when "6" then result = result + "110".
    when "7" then result = result + "111".
  end.

  /* message octalString n c result.    */
  /* pause.                             */

end.

return result.

end.

display.

Continue reading...
 
Status
Not open for further replies.
Top