TEF.TOTAL.VAL isn't a variable. For the most part, equates are just replacements. Everywhere you have TEF.TOTAL.VAL in your code gets replaced with SUM(TEF.VAL) so TEF.TOTAL.VAL=0 Becomes SUM(TEF.VAL)=0 Which of course is illegal and won't compile.
You can see the replacements at work with vlist. Compile this program: 0001 EQU TEF.TOTAL.VAL TO SUM(TEF.VAL) 0002 CRT TEF.TOTAL.VAL 0003 CRT SUM(TEF.VAL) And then vlist it: 00001: EQU TEF.TOTAL.VAL TO SUM(TEF.VAL) 00002: CRT TEF.TOTAL.VAL 00002 00000 : 198 sum TEF.VAL => $R0 00002 00006 : 046 crtcrlf $R0 00003: CRT SUM(TEF.VAL) 00003 0000C : 198 sum TEF.VAL => $R0 00003 00012 : 046 crtcrlf $R0 00004 00018 : 190 stop The equate line doesn't generate any code, and the two CRTs generate identical code. So, just like when you use define in C, you need to be careful about what you equate. For example: 0001 C=0 0002 EQU A TO CHAR(C) 0003 C=1 0004 CRT A Is going to print char(1) on line 4 instead of the maybe expected char(0). > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Burwell, Ed > Sent: Friday, April 06, 2007 3:43 PM > To: [email protected] > Subject: [U2] [UD] Dynamic variable > > > Just discovered something kinda cool that I want to share: > > Here are a set of equates: > > COM.DEFS TEST.FILE > 001: DIM TEF(2) > 002: * > 003: EQU TEF.VAL TO TEF(1) > 004: EQU TEF.TOTAL.VAL TO SUM(TEF.VAL) > 005: * > > And here is a little test program: > > 0001: * > 0002: INCLUDE COM.DEFS TEST.FILE > 0003: 10 MAT TEF="" > 0004: FOR I=1 TO 5 > 0005: TEF.VAL<1,I>=RND(20) > 0006: PRINT "VALUE ":I:" = ":TEF.VAL<1,I>"R#2" > 0007: NEXT I > 0008: PRINT " ----" > 0009: PRINT "TOTAL = ":TEF.TOTAL.VAL"R#3" > 0010: PRINT "SUM = ":SUM(TEF.VAL)"R#3" > 0011: PRINT STR("-",78) > 0012: PRINT "RETURN to do it again or 'E'xit ": ; INPUT B,1 > 0013: IF UPCASE(B)="E" THEN STOP ELSE GO 10 > 0014: END > > When you run this, the variable "TEF.TOTAL.VAL" always > "knows" the sum of the values in TEF.VAL!! > > Also, if you try to do this in a program: > > TEF.TOTAL.VAL=0 > > It won't compile!! It knows!! > > Very cool (I think). > > Ed > > ______________________________________________________________________ > This e-mail has been scanned by MCI Managed Email Content > Service, using Skeptic(tm) technology powered by MessageLabs. > For more information on MCI's Managed Email Content Service, > visit http://www.mci.com. > ______________________________________________________________________ > ------- > u2-users mailing list > [email protected] > To unsubscribe please visit http://listserver.u2ug.org/ > > -- > No virus found in this incoming message. > Checked by AVG Free Edition. > Version: 7.5.446 / Virus Database: 268.18.26/748 - Release > Date: 4/5/2007 3:33 PM > -- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.5.446 / Virus Database: 268.18.26/748 - Release Date: 4/5/2007 3:33 PM ------- u2-users mailing list [email protected] To unsubscribe please visit http://listserver.u2ug.org/
