SUBROUTINE IFS(Results, TestValues, ThenValues, ElseValues) * --------------------------------------- * Copyright 1996, The Meme Factory Inc. * The Text of this program may be freely distributed so long as this * copyright notice is included in it's entirety and any changes from the * original text of the program are clearly noted. The inclusion of a diff * between the original and the modified version with the distribution * satisfies this requirement. This program * may be freely used by non profit organizations and individuals personal * use, all others are licensed to use this program upon payment of $10 * U.S. to: The Meme Factory, 5512 S. Woodlawn Ave., Chicago, IL 60637. * * The user assumes all liability and risk associated with the use of this * program. * --------------------------------------------- * BASIC Program * CREATED: January 29, 1996 * PROGRAMMER: Karl O. Pinc * * TITLE: Multi-Valued IF function. * * DESCRIPTION: Returns a multivalued dynamic array by examining each of * a multivalued test value array and choosing the corresponding value * from either a Then value array or an Else value array. * The dynamic array returned will have the structure of the TestValues * array in that it will have at least as many fields as the TestValues * array and each * of these fields will have at least as many values as the corresponding * TestValues, each of these values will have at least as many sub-values, * etc. The resulting dynamic array may have more fields, values, etc., * than the TestValues array when the chosen portion of ThenValues or * ElseValues has more than one element. * * Note that the entire ThenValues and ElseValues expressions are * evaluated, so any side effects will occur. * * MODIFICATIONS: * *========================================================================= * $INSERT EQU.FILE I_GLOBAL EQU CHAR.AFTER.LAST.ASCII TO 256 Results = "" * Reset REMOVE pointers. TestValues = TestValues ThenValues = ThenValues ElseValues = ElseValues * Accumulate results. REMOVE TestValue FROM TestValues SETTING TestValueDelim REMOVE ThenValuePart FROM ThenValues SETTING ThenValueDelim REMOVE ElseValuePart FROM ElseValues SETTING ElseValueDelim LOOP ThenValue = "" * Save all the lesser delimited pieces but the last. LOOP WHILE ThenValueDelim > TestValueDelim * Add in the value and the delim (which is different from the * test delim.) ThenValue := ThenValuePart : CHAR(CHAR.AFTER.LAST.ASCII - ThenValueDelim) REMOVE ThenValuePart FROM ThenValues SETTING ThenValueDelim REPEAT * Add in the value. ThenValue := ThenValuePart IF ThenValueDelim = TestValueDelim THEN REMOVE ThenValuePart FROM ThenValues SETTING ThenValueDelim END ELSE * Already used this dnyamic array element. ThenValuePart = "" END ElseValue = "" * Save all the lesser delimited pieces but the last. LOOP WHILE ElseValueDelim > TestValueDelim * Add in the value and the delim (which is different from the * test delim.) ElseValue := ElseValuePart : CHAR(CHAR.AFTER.LAST.ASCII - ElseValueDelim) REMOVE ElseValuePart FROM ElseValues SETTING ElseValueDelim REPEAT * Add in the value. ElseValue := ElseValuePart IF ElseValueDelim = TestValueDelim THEN REMOVE ElseValuePart FROM ElseValues SETTING ElseValueDelim END ELSE * Already used this dnyamic array element. ElseValuePart = "" END IF TestValue THEN Results := ThenValue END ELSE Results := ElseValue END UNTIL TestValueDelim = RC.EOS Results := CHAR(CHAR.AFTER.LAST.ASCII - TestValueDelim) REMOVE TestValue FROM TestValues SETTING TestValueDelim REPEAT RETURN END