home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a067 / 1.img / GRUMP501.EXE / GFINDGET.PRG < prev    next >
Encoding:
Text File  |  1991-05-02  |  1.3 KB  |  46 lines

  1. /*
  2.     Function: GFindGet()
  3.     Purpose:  Locate a GET in the getlist array
  4.     Author:   Greg Lief
  5.     Dialect:  Clipper 5.x
  6.     Copyright (c) 1991 Greg Lief
  7. */
  8. function gfindget(victim)
  9. local ret_val, ele
  10. memvar getlist
  11. //───── first verify that GETLIST is a non-empty array
  12. if valtype(getlist) == "A" .and. len(getlist) > 0
  13.    do case
  14.  
  15.       //───── if param is character string, search GETLIST for that name
  16.       case valtype(victim) == 'C'
  17.          if (ele := ascan(getlist, { | a | upper(victim) $ upper(a:name) })) > 0
  18.             ret_val := getlist[ele]
  19.          endif
  20.  
  21.       //───── if param is numeric, much simpler... range check only
  22.       case valtype(victim) == 'N'
  23.          do case
  24.  
  25.             //───── within valid range
  26.             case victim <= len(getlist) .and. victim >= 1
  27.                ret_val := getlist[victim]
  28.  
  29.             //───── greater than length of getlist -- return maximum length
  30.             case victim > len(getlist)
  31.                ret_val := atail(getlist)
  32.  
  33.             //───── default to 1
  34.             otherwise
  35.                ret_val := getlist[1]
  36.          endcase
  37.  
  38.       //───── if no parameter passed, use current GET
  39.       otherwise
  40.          ret_val := getactive()
  41.    endcase
  42. endif
  43. return ret_val
  44.  
  45. * eof GFINDGET.PRG
  46.