home *** CD-ROM | disk | FTP | other *** search
- ********************
-
- FUNCTION Inlist
-
- *
- * The INLIST() function validates that the parameter passed
- * in found in the of elements in the string of options.
- *
- * This function was written by Joseph D. Booth and contributed
- * to the Steve Straley ToolkiT.
- *
- * Modified to accept an array element by reference.
- *
-
- PARAMETER _testcode, _thelist, _thereq, _thecolor
-
- PRIVATE _retval, _piece, _wrow, _wcol, _wcolor, _anarray
- PRIVATE _helplist[ OCCURENCE("/",_thelist)+1 ], _ctr, _pick
-
- IF LASTKEY() = 5
- RETURN(.T.)
- ENDIF
-
- IF PCOUNT() = 2
- _thereq = .T.
- _thecolor = SETCOLOR()
- ELSEIF PCOUNT() = 3
- _thecolor = SETCOLOR()
- ENDIF
- IF ( EMPTY(_testcode) .AND. !_thereq ) && If up arrow was pressed, do not
- RETURN(.T.) && validate the field
- ENDIF
-
- IF TYPE("_testcode") = "L"
- _anarray = .F.
- ELSE
- _anarray = ("["$_testcode) && This tests to see if the element passed to the
- && function was a memeber of an array. If so, then
- && the function will macro the string which creates
- && the effect of passing the parameter by reference.
- && Otherwise, the "@" sign will be used and the
- && parameter will ideed be passed by reference
- ENDIF
-
- _retval = .F.
- _ctr = 0
- _wrow = ROW()
- _wcol = COL()
- _wcolor = Set_color(Attribute(_wrow, _wcol) )
-
- SETCOLOR(IF( (ISCOLOR() .AND. !(IF(TYPE("scrmono")="U", .T., scrmono))), _thecolor, SETCOLOR()))
-
- DO WHILE ! EMPTY(_thelist)
- SETCOLOR(_wcolor)
- _piece = PARSING(@_thelist)
- _ctr = _ctr +1
- _helplist[_ctr] = _piece
- IF !_anarray
- IF TYPE("_testcode") != "L"
- IF _testcode = LEFT( _piece,1) .AND. ! EMPTY( _piece )
- @ _wrow,_wcol+1 SAY _piece
- _retval = .T.
- EXIT
- ENDIF
- ELSE
- _retval = .F.
- ENDIF
- ELSE
- IF TYPE(_testcode) != "L"
- IF &_testcode. = LEFT(_piece,1) .AND. ! EMPTY( _piece )
- @ _wrow,_wcol+1 SAY _piece
- _retval = .T.
- EXIT
- ELSE
- _retval = .F.
- ENDIF
- ENDIF
- ENDIF
-
- ENDDO
-
- SETCOLOR(_thecolor)
-
- _a1row = ROW()
- _a1col = COL() + 2
-
- IF _a1col + IF((Length_el(_helplist) < 15), 15, Length_el(_helplist)) > 80
- _a1col = 78 - IF((Length_el(_helplist) < 15), 15, Length_el(_helplist))
- _a1row = _a1row + 1
- ENDIF
-
- IF _a1row + LEN(_helplist) + 5 > 24
- _a1row = 24 - LEN(_helplist) - 7
- ENDIF
-
- IF ! _retval
- _pick = Apop( _a1row, _a1col, _ctr+4,LENGTH_EL(_helplist)+8,_helplist )
- SETCOLOR(_wcolor)
- IF _pick > 0
- _retval = .T.
- IF !_anarray
- IF TYPE("_testcode") != "L"
- _testcode = LEFT( _helplist[_pick],1 )
- _joecolor = SETCOLOR()
- SETCOLOR(Set_color(Attribute(_wrow,_wcol-1)))
- @ _wrow,_wcol-1 SAY _testcode
- SETCOLOR(_joecolor)
- @ _wrow, _wcol+1 SAY _helplist[_pick]
- ENDIF
- ELSE
- IF TYPE(_testcode) != "L"
- &_testcode. = LEFT( _helplist[_pick],1 )
- _joecolor = SETCOLOR()
- SETCOLOR(Set_color(Attribute(_wrow,_wcol-1)))
- @ _wrow,_wcol-1 SAY &_testcode.
- SETCOLOR(_joecolor)
- @ _wrow, _wcol+1 SAY _helplist[_pick]
- ENDIF
- ENDIF
- ENDIF
- ENDIF
- SETCOLOR(_thecolor)
- RETURN(_retval)
-
- * End of File
-
-
-