function s = s_adjustl ( s ) %% S_ADJUSTL flushes a string left. % % Discussion: % % Both blanks and tabs are treated as "white space". % % This routine is similar to the FORTRAN90 ADJUSTL routine. % % Examples: % % Input Output % % ' Hello' 'Hello ' % ' Hi there! ' 'Hi there! ' % 'Fred ' 'Fred ' % % Modified: % % 31 January 2001 % % Author: % % John Burkardt % % Parameters: % % Input, character ( len = * ) S, the string to be shifted left. % % Output, character ( len = * ) S, has been shifted left. % TAB = char ( 9 ); % % Check the length of the string to the last nonblank. % If nonpositive, return. % len = s_len_trim ( s ); if ( len <= 0 ) return end % % Find NONB, the location of the first nonblank, nontab. % nonb = 0; for i = 1 : len if ( s(i) ~= ' ' & s(i) ~= TAB ) nonb = i; break end end if ( nonb == 0 ) s = ' '; return end % % Shift the string left. % if ( 1 < nonb ) for i = 1 : len + 1 - nonb s(i) = s(i+nonb-1); end end % % Blank out the end of the string. % s(len+2-nonb:len) = ' ';