Stuart, Yours is pretty clever. Not sure my solution is any simpler:
@VM:TRANS('FILEA',CUST.ID,CAT.CODE,'X'):@VM;@VM:CAT.CODE:@VM;@1[1,INDEX(@1,@2 ,1)];COUNT(@,@VM);TRANS('FILEA',CUST.ID,CAT.DESC,'X');IF @4 < 1 THEN "" ELSE FIELD(@,@VM,@4,1) First, I surround the target cat code field with value marks so that I can locate the unique cat code from FILEB. I don't want a partial match to fool me. The second phrase only builds the search term; the cat code surrounded by value marks. The third phrase locates the cat code. The fourth phrase tells me how many value marks I found up to the cat code string. Since I placed a value mark at the start of the cat code string to be searched I end up with the correct value pointer. The fifth phrase gets the cat description attribute. The fifth phrase returns the description after testing that we did, in fact, find a match in phrase three. I was getting an error trying to use the (..)<1,1,@2> logic (UniData 5.2.15 on AIX 4.3.2) so I used the FIELD construct instead. Karjala >>> [EMAIL PROTECTED] 07/27/2004 7:12:56 AM >>> I have a requirement for a quick extract from an MV field set in a file. The itype I built proved weirder than I anticipated. Here's the scenario. There's a set of mv fields on FILEA that contain a category code and description. In basic I would do a LOCATE and retrieve the associated element. For a listing of FILEB that contains the key to FILEA and a CAT.CODE it requires a devious itype to extract the associated mv field. I'm wondering how others may have tackled this (without resorting to subr()), is there a simple way and my medication is blocking my synapse from working? FILEA (CUST.ID) 000 12345 ... (CAT.CODE) 050 a]b]c]d (CAT.DESC) 051 blah1]blah2]blah3]blah4 FILEB (TRANS.ID) 000 99999 (CUST.ID) 006 12345 (CAT.CODE) 012 c This is the Itype I built - it seems overly difficult without a locate() function available. EQS(TRANS('FILEA', CUST.ID,CAT.CODE,''),REUSE(CAT.CODE)); (INDEX(@1,@TRUE,1)+1)/2; IF SUM(@1) THEN TRANS('FILEA',CUST.ID,CAT.DESC,'')<1,1,@2> ELSE '' synopsis: eqs, get an array of true/false matches; index, find the char pos for the first true value, add 1 and div by 2 to give the array element; sum, if there was a match, get the description field and extract the (svm) element indicated by previous op LIST FILEB CAT.CODE CAT.DESC 99999 c blah3 -- Regards, Stuart Boydell ********************************************************************** This email message and any files transmitted with it are confidential and intended solely for the use of addressed recipient(s). If you have received this email in error please notify the Spotless IS Support Centre (61 3 9269 7555) immediately who will advise further action. This footnote also confirms that this email message has been scanned for the presence of computer viruses. ********************************************************************** ------- u2-users mailing list [EMAIL PROTECTED] To unsubscribe please visit http://listserver.u2ug.org/ ------- u2-users mailing list [EMAIL PROTECTED] To unsubscribe please visit http://listserver.u2ug.org/