home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a075 / 1.img / TOOLKIT1.EXE / SST185.PRG < prev    next >
Encoding:
Text File  |  1989-08-08  |  1.4 KB  |  51 lines

  1. ********************
  2.  
  3. FUNCTION Print_stri
  4.  
  5.    PARAMETER _thestr, _begmac, _endmac
  6.  
  7.    * _thestr is the string being parsed
  8.    * _begmac is the beginning macro character
  9.    * _endmac is the ending macro character
  10.  
  11.    IF PCOUNT() = 1
  12.       _begmac = CHR(174)
  13.       _endmac = CHR(175)
  14.    ELSEIF EMPTY(PCOUNT())
  15.       RETURN(0)
  16.    ENDIF
  17.  
  18.    IF TYPE("_thestr") + TYPE("_begmac") + TYPE("_endmac") != "CCC"
  19.       RETURN("")
  20.    ENDIF
  21.  
  22.    PRIVATE _xtimes, _qaz, _fstop, _bstop, _frontit, _midit, _restit, _newit
  23.  
  24.    * _fstop is the front stop where the macro is located
  25.    * _bstop is the back stop where the macro is located
  26.    * _frontit is the part of the string in the frount of the macro
  27.    * _midit is the part of the string in the middle of the macro to be expanded
  28.    * _restit is the rest of the string
  29.  
  30.    _xtimes = OCCURENCE(_begmac, _thestr)
  31.    IF EMPTY(_xtimes)
  32.       RETURN(_thestr)
  33.    ENDIF
  34.    FOR _qaz = 1 TO _xtimes
  35.       _fstop = AT(_begmac, _thestr)
  36.       _bstop = AT(_endmac, _thestr)
  37.  
  38.       _frontit = SUBSTR(_thestr, 1, _fstop-1)
  39.       _midit   = SUBSTR(_thestr, _fstop+1, _bstop-1-_fstop)
  40.       _restit  = SUBSTR(_thestr, _bstop+1)
  41.       IF "->"$_midit
  42.          _newit = &_midit
  43.          _thestr = _frontit + STRVALUE(_newit) + _restit
  44.       ELSE
  45.          _thestr = _frontit + STRVALUE(&_midit) + _restit
  46.       ENDIF
  47.    NEXT
  48.    RETURN(_thestr)
  49.  
  50. * End of File
  51.