home *** CD-ROM | disk | FTP | other *** search
- ********************
-
- FUNCTION Addkey
-
- PARAMETERS _tstring
-
- * first check the parameter
- * next see if the key is already in the stack
- * if so, just replace the element
- * If it is not in the stack, go to the next available
- * item and add it
- * If there is no longer any room to add the item, quit
- *
- * The follow is a table:
- * 0 = Did not add do improper parameter or array is not there
- * -1 = no longer any room to enter the item
- * >0 = the element position now assumed
-
-
- IF TYPE("_tstring") != "C"
- RETURN(0)
- ELSEIF EMPTY(AT("/", _tstring)) && Must be a good string
- RETURN(0)
- ELSEIF TYPE("setkeys") != "A" && No array is present
- RETURN(0)
- ENDIF
-
- PRIVATE _first, _second, _qaz, _return
-
- _first = LTRIM(TRIM(SUBSTR(_tstring, 1, AT("/", _tstring)-1 )))
- _second = TRIM(SUBSTR(_tstring, AT("/", _tstring)+1 ))
-
- FOR _qaz = 1 TO LEN(setkeys)
- IF _first = LTRIM(TRIM(SUBSTR(setkeys[_qaz], 1, AT("/", setkeys[_qaz])-1 )))
- EXIT
- ENDIF
- NEXT
-
- IF _qaz <= LEN(setkeys) && element was found
- setkeys[_qaz] = _tstring
- _return = _qaz && the return value
- ELSE
- FOR _qaz = 1 TO LEN(setkeys)
- IF EMPTY(setkeys[_qaz])
- EXIT
- ENDIF
- NEXT
- IF _qaz <= LEN(setkeys) && element was found
- setkeys[_qaz] = _tstring
- _return = _qaz
- ELSE
- _return = -1
- ENDIF
- ENDIF
- RETURN(_return)
-
- * End of File
-
-