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

  1. ********************
  2.  
  3. FUNCTION Addkey
  4.  
  5.    PARAMETERS _tstring
  6.  
  7.    * first check the parameter
  8.    * next see if the key is already in the stack
  9.    *      if so, just replace the element
  10.    * If it is not in the stack, go to the next available
  11.    *      item and add it
  12.    * If there is no longer any room to add the item, quit
  13.    *
  14.    * The follow is a table:
  15.    *     0 = Did not add do improper parameter or array is not there
  16.    *    -1 = no longer any room to enter the item
  17.    *    >0 = the element position now assumed
  18.  
  19.  
  20.    IF TYPE("_tstring") != "C"
  21.       RETURN(0)
  22.    ELSEIF EMPTY(AT("/", _tstring))   && Must be a good string
  23.       RETURN(0)
  24.    ELSEIF TYPE("setkeys") != "A"     && No array is present
  25.       RETURN(0)
  26.    ENDIF
  27.  
  28.    PRIVATE _first, _second, _qaz, _return
  29.  
  30.    _first  = LTRIM(TRIM(SUBSTR(_tstring, 1, AT("/", _tstring)-1 )))
  31.    _second = TRIM(SUBSTR(_tstring,    AT("/", _tstring)+1 ))
  32.  
  33.    FOR _qaz = 1 TO LEN(setkeys)
  34.       IF _first = LTRIM(TRIM(SUBSTR(setkeys[_qaz], 1, AT("/", setkeys[_qaz])-1 )))
  35.          EXIT
  36.       ENDIF
  37.    NEXT
  38.  
  39.    IF _qaz <= LEN(setkeys)         && element was found
  40.       setkeys[_qaz] = _tstring
  41.       _return = _qaz               && the return value
  42.    ELSE
  43.       FOR _qaz = 1 TO LEN(setkeys)
  44.          IF EMPTY(setkeys[_qaz])
  45.             EXIT
  46.          ENDIF
  47.       NEXT
  48.       IF _qaz <= LEN(setkeys)      && element was found
  49.          setkeys[_qaz] = _tstring
  50.          _return = _qaz
  51.       ELSE
  52.          _return = -1
  53.       ENDIF
  54.    ENDIF
  55.    RETURN(_return)
  56.  
  57. * End of File
  58.  
  59.  
  60.