C+ C NAME: C Int2Str C PURPOSE: C Write integer to string using constraints set by Int2StrSet C CATEGORY: C Strings: write integer into string C CALLING SEQUENCE: function Int2Str(I,cInt) C INPUTS: C I integer integer to be processed C OUTPUTS: C Int2Str integer length non-trivial part of output string C cInt character*(*) output string C CALLS: C icompress C INCLUDE: include 'str2str_inc.h' C PROCEDURE: C Four constraints can be set with Int2Str: C STR__TRIM: no leading or trailing blanks C STR__LEFTADJUST: no leading blanks C STR__RIGHTADJUST: no trailing blanks C STR__ZERORIGHTADJUST: no trailing blanks, zeroes instead of leading blanks C The parameters are declared in include file str2str_inc.h) C The input integer is put in the output string subject to the C constraints set by Int2StrSet. C C A sequence of Str2Str, Int2Str and Flt2Str calls can be used to build C a string without explicitly referring to locations in the destination C string: C I = 0 C I = I+Str2Str(cStr1, cStrO(I+1:)) C I = I+Int2Str(iNum , cStrO(I+1:)) C I = I+Str2Str(cStr2, cStrO(I+1:)) C MODIFICATION HISTORY: C JAN-1995, Paul Hick (UCSD) C- integer I character cInt*(*) character cTmp*12 ! Don't remove cTmp integer iFill /STR__TRIM/ save iFill if (iFill .eq. STR__ZERORIGHTADJUST) then write (cTmp,'(I12.12)') I Int2Str = len(cInt) K = Int2Str-12 do J=1,K cInt(J:J) = '0' end do cInt(max(0,K)+1:) = cTmp(max(0,-K)+1:) else if (iFill .eq. STR__RIGHTADJUST) then write (cTmp,'(I12)') I Int2Str = len(cInt) K = Int2Str-12 cInt = ' ' cInt(max(0,K)+1:) = cTmp(max(0,-K)+1:) else if (iFill .eq. STR__LEFTADJUST) then write (cTmp,'(I12)') I Int2Str = icompress(cTmp,cInt) Int2Str = min(12,len(cInt)) else if (iFill .eq. STR__TRIM) then write (cTmp,'(I12)') I Int2Str = icompress(cTmp,cInt) end if return C+ C NAME: C Int2StrSet C PURPOSE: C Set constraints to be used with href=Int2Str= C CATEGORY: C Strings: write integer to string C CALLING SEQUENCE: entry Int2StrSet(I) C INPUTS: C I integer mode: STR__TRIM, STR__LEFTADJUST, STR__RIGHTADJUST, STR__ZERORIGHTADJUST C OUTPUTS: C Int2StrSet integer previous setting of mode C SEE ALSO: C Str2StrSet C PROCEDURE: C Int2StrSet is an entry point in function Int2Str. C Typically it is used before and after one or more Int2Str calls to C restore a previously set insertion mode: C C iSet = Int2StrSet(STR__NOTRIM) Set new insertion mode, save old one C ( calls to Int2Str ) C iSet = Int2StrSet(iSet) Restore old insertion mode C MODIFICATION HISTORY: C JAN-1995, Paul Hick (UCSD) C- Int2StrSet = iFill iFill = I return end