Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Gene Wirchenko
  Where is Gene Wirchenko?
 Gene Wirchenko
Subject: Useful Routine Related to ICASE()
Thread ID: 416529 Message ID: 416529 # Views: 63 # Ratings: 1
Version: Not Applicable Category: General VFP Topics
Date: Tuesday, December 30, 2014 8:16:56 PM         

Dear Vixens and Reynards:

In another thread, someone suggested using ICASE(). It is a useful function, and I had a procedure called icase that I posted to USENET four years before VFP got ICASE(). Here is another related procedure that I occasionally find useful:

* ion
* Interactive On
* Last Modification: 2000-10-30
* The parameters are interpreted follows:
*   1) If no parameters, return .null..
*   2) Consider the value of parm1 against the succeeding pairs (2&3, 4&5,
*      etc.)  If the value of parm1 = the first of the pair, return the
*      second of the pair.
*   3) None of the pairs hit: if there is a parameter left over, return it
*      else return .null..

procedure ion
lparameters parm1, parm2, parm3, parm4, parm5,;
 parm6, parm7, parm8, parm9, parm10,;
 parm11, parm12, parm13, parm14, parm15,;
 parm16, parm17, parm18, parm19, parm20,;
 parm21, parm22, parm23, parm24, parm25,;
 parm26, parm27

   local parmcount

   if parmcount=0
      return .null.

   local parmptr, parmptrstr
   for parmptr=2 to parmcount-1 step 2
      if (parm&parmptrstr)=parm1
         return parm&parmptrstr

   if parmcount%2=0
      return parm&parmptrstr
      return .null.


This is a syntactic sugar function, but it is useful in cases where the first parameter is "long", but the values to match on and values to return are short. Example:

WARNING: All parameters will be evaluated.


Gene Wirchenko


Useful Routine Related to ICASE() Posted by Gene Wirchenko @ 12/30/2014 8:16:56 PM