%BEGIN
%STRING(40)T
%ROUTINE DESPACE(%STRINGNAME S)
%INTEGER I, J, K, CH
      J = LENGTH(S)
      %RETURN %IF J = 0
      K = 0
!
      %CYCLE I = 1, 1, J
         CH = CHARNO(S, I)
         %UNLESS CH = ' ' %START
            K = K + 1
            CHARNO(S, K) = CH %IF I > K
         %FINISH
      %REPEAT
!
      LENGTH(S) = K %IF J > K
%END; ! DESPACE
      T=""
      DESPACE(T)
      T="A S P A C E D O U T N A M E"
      DESPACE(T)
      %IF T="ASPACEDOUTNAME" %THEN PRINTSTRING("TEST OK") %C
         %ELSE PRINTSTRING("FAILED '".T."'")
%ENDOFPROGRAM

