RE: [U2] [UV] reference a variable indirectly?
> If you use a dynamic array for VAR.NAMES, you will run into problems, since > the compiler converts LOTNO<3> to VAR.NAMES<2><3>, which is not valid > syntax. I agree with your point about using dimensioned arrays, as a matter of good practice when used with included equate tables ... but the dynamic array extraction syntax does work: LOTNO<1,3> (equivalent to ~ VAR.NAMES<2><1,3>) is valid syntax for extraction, though not for assignment, and works under UV. Insert function syntax works for assignment. sub shortDemo Equates: equ E.GOSUB lit 'if E.LOTNO<1,3> then gosub', E.LOTNO to VarNames<2> Main: VarNames = 'A1':@AM:'B1':@AM:'C1' E.LOTNO = insert(E.LOTNO,1,3;'B3') E.GOSUB WorkOnGoodLotNoRecord: return WorkOnGoodLotNoRecord: crt VarNames return EndOfProgram: end Stuart. ** 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 u2-users@listserver.u2ug.org To unsubscribe please visit http://listserver.u2ug.org/
RE: [U2] [UV] reference a variable indirectly?
Tom Oops, sorry scrub my reply. You're right, of course. My precompiler sorts it out. :-( Brian -- Internal Virus Database is out-of-date. Checked by AVG Anti-Virus. Version: 7.0.308 / Virus Database: 266.9.0 - Release Date: 31/03/2005 --- u2-users mailing list u2-users@listserver.u2ug.org To unsubscribe please visit http://listserver.u2ug.org/
RE: [U2] [UV] reference a variable indirectly?
Tom, EQU LOTNO LIT "VAR.NAMES<2>" LOTNO<1,2> = MySecondMV (not LOTNOT<2>) Works on UniVerse. :-) Brian > -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of > [EMAIL PROTECTED] > Sent: 13 April 2005 13:53 > To: u2-users@listserver.u2ug.org > Subject: RE: [U2] [UV] reference a variable indirectly? > > Stewart Mitchell wrote on Wed, 13 Apr 2005 10:21:10 +1000 > > > Try > > > > EQU LOTNO LIT "VAR.NAMES<2>" > > > > -Original Message- > > From: [EMAIL PROTECTED] > > On Behalf Of Barry Brevik > > Sent: Tuesday, April 12, 2005 6:59 PM > > > > ...I want to be able to store variable names in a file (for > example), > > and then assign values to those variables as the program encounters > > them. > > Barry - I would recommend that, if you do this, you use a > dimensioned array for VAR.NAMES, e.g.: > > DIM VAR.NAMES(100) > EQU PARTNO LIT "VAR.NAMES(1)" > EQU LOTNO LIT "VAR.NAMES(2)" > EQU PARTNAME LIT "VAR.NAMES(3)" > &c. > > This way, if any of your variables are multi-valued, you can > reference them normally, e.g. LOTNO<3>. In UniData, EQU is a > comiler directive - the substitution is made during > compilation and the symbolic names are made available to the debugger. > > If you use a dynamic array for VAR.NAMES, you will run into > problems, since the compiler converts LOTNO<3> to > VAR.NAMES<2><3>, which is not valid syntax. > > --Tom Pellitieri -- Internal Virus Database is out-of-date. Checked by AVG Anti-Virus. Version: 7.0.308 / Virus Database: 266.9.0 - Release Date: 31/03/2005 --- u2-users mailing list u2-users@listserver.u2ug.org To unsubscribe please visit http://listserver.u2ug.org/
RE: [U2] [UV] reference a variable indirectly?
Stewart Mitchell wrote on Wed, 13 Apr 2005 10:21:10 +1000 > Try > > EQU LOTNO LIT "VAR.NAMES<2>" > > -Original Message- > From: [EMAIL PROTECTED] > On Behalf Of Barry Brevik > Sent: Tuesday, April 12, 2005 6:59 PM > > ...I want to be able to store variable names in a file (for > example), and then assign values to those variables as the > program encounters them. Barry - I would recommend that, if you do this, you use a dimensioned array for VAR.NAMES, e.g.: DIM VAR.NAMES(100) EQU PARTNO LIT "VAR.NAMES(1)" EQU LOTNO LIT "VAR.NAMES(2)" EQU PARTNAME LIT "VAR.NAMES(3)" &c. This way, if any of your variables are multi-valued, you can reference them normally, e.g. LOTNO<3>. In UniData, EQU is a comiler directive - the substitution is made during compilation and the symbolic names are made available to the debugger. If you use a dynamic array for VAR.NAMES, you will run into problems, since the compiler converts LOTNO<3> to VAR.NAMES<2><3>, which is not valid syntax. --Tom Pellitieri Century Equipment Toledo, Ohio --- u2-users mailing list u2-users@listserver.u2ug.org To unsubscribe please visit http://listserver.u2ug.org/
RE: [U2] [UV] reference a variable indirectly?
Yes you can: You get a pr-program to read the file with your actual programs source code open The pre-program inserts the values as values in an array into the source of the actual program i.e. ARRAY<1,-1> = "PARTNO" ARRAY<1,-1> = "LOTNO" ARRAY<1,-1> = "PARTNAME" When all have been inserted it writes the actual program away with a new name Compiles it Executes it The actual program reads the file Does a locate on the ARRAY<1> to find the field name and does what it likes to ARRAY<2,X> (allocates values etc) after that Sounds like fun doesn't it Bob -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Mats Carlid Sent: 13 April 2005 08:36 To: u2-users@listserver.u2ug.org Subject: Re: [U2] [UV] reference a variable indirectly? Barry Brevik wrote: >UV 9.6.1.3 on Windows. > >For the longest time this has been bugging me, but right now I could really >use this capability. > >Does anyone know if it is possible to reference a variable indirectly? IOW, >I want to be able to store variable names in a file (for example), and then >assign values to those variables as the program encounters them. > >For example, something like this: > >PARTNO = ''; LOTNO = ''; PARTNAME = '' >VAR.NAMES = 'PARTNO':@FM:'LOTNO':@FM:'PARTNAME' >* >* Next, a magic command that makes the variable >* refered to by VAR.NAMES<2> equal to 'it works'. >(VAR.NAMES<2>) = 'it works'; * I know this does not work, just example. >PRINT LOTNO >* >* Variable LOTNO is now eq 'it works'. > >Possible?? > >Barry > > No there is no way to do that. You'd need an 'eval' function/statement. But You can do something similar with a subroutine and a function. Subroutine SET( variable name, value ) Function VAL( variable name ) They need to share a common ( or a file ) where variable-value pairs are stored. A straight forward implementation would be to search for the variable name in an mv-string and use the index to look up the value from another mv string. If you know the number of entries you can use arrays. Even if you don't you can still use arrays by running imformation style allowing them to be redimensioned. Then Your program would look like: DEFFUN VAL( var ) CALLING "VAL" CALL SET( 'LOTNO', 'it works' ) PRINT VAL( 'LOTNO' ) Naive untested implementation. If heavily used you'd need to hash e.g. as MOD( SEQ(VAR[1,1])*LEN(VAR), N )+1 where N is the number of hash points and the dimension of VARS and VALS. SUBROUTINE SET( VAR, VAL) COMMON /..SET/ VARS, VALS LOCATE VAR IN VARS<1> SETTING II THEN VALS = VAL END ELSE VARS<-1> = VAR VALS<-1> = VAL END RETURN END FUNCTION VAL( VAR ) !! Hashed version COMMON /..SET/ VARS(N), VALS(N) HASH = MOD( SEQ(VAR[1,1])*LEN(VAR), N )+1 RES = "" LOCATE VAR IN VARS(HASH)<1> SETTING II THEN RES = VALS(HASH) END RETURN (RES) END -- mats --- u2-users mailing list u2-users@listserver.u2ug.org To unsubscribe please visit http://listserver.u2ug.org/ __ This email has been scanned by the MessageLabs Email Security System. For more information please visit http://www.messagelabs.com/email __ __ This email has been scanned by the MessageLabs Email Security System. For more information please visit http://www.messagelabs.com/email __ --- u2-users mailing list u2-users@listserver.u2ug.org To unsubscribe please visit http://listserver.u2ug.org/
RE: [U2] [UV] reference a variable indirectly?
Try this for size 0001: EQUATE PART.NO LIT 'REC<1>' 0002: REC<1> = 'IT WORKS' 0003: PRINT PART.NO 0004:END Regards, Tim Franklin -Original Message- From: Mats Carlid [mailto:[EMAIL PROTECTED] Sent: 13 April 2005 09:36 To: u2-users@listserver.u2ug.org Subject: Re: [U2] [UV] reference a variable indirectly? Barry Brevik wrote: >UV 9.6.1.3 on Windows. > >For the longest time this has been bugging me, but right now I could really >use this capability. > >Does anyone know if it is possible to reference a variable indirectly? IOW, >I want to be able to store variable names in a file (for example), and then >assign values to those variables as the program encounters them. > >For example, something like this: > >PARTNO = ''; LOTNO = ''; PARTNAME = '' >VAR.NAMES = 'PARTNO':@FM:'LOTNO':@FM:'PARTNAME' >* >* Next, a magic command that makes the variable >* refered to by VAR.NAMES<2> equal to 'it works'. >(VAR.NAMES<2>) = 'it works'; * I know this does not work, just example. >PRINT LOTNO >* >* Variable LOTNO is now eq 'it works'. > >Possible?? > >Barry > > No there is no way to do that. You'd need an 'eval' function/statement. But You can do something similar with a subroutine and a function. Subroutine SET( variable name, value ) Function VAL( variable name ) They need to share a common ( or a file ) where variable-value pairs are stored. A straight forward implementation would be to search for the variable name in an mv-string and use the index to look up the value from another mv string. If you know the number of entries you can use arrays. Even if you don't you can still use arrays by running imformation style allowing them to be redimensioned. Then Your program would look like: DEFFUN VAL( var ) CALLING "VAL" CALL SET( 'LOTNO', 'it works' ) PRINT VAL( 'LOTNO' ) Naive untested implementation. If heavily used you'd need to hash e.g. as MOD( SEQ(VAR[1,1])*LEN(VAR), N )+1 where N is the number of hash points and the dimension of VARS and VALS. SUBROUTINE SET( VAR, VAL) COMMON /..SET/ VARS, VALS LOCATE VAR IN VARS<1> SETTING II THEN VALS = VAL END ELSE VARS<-1> = VAR VALS<-1> = VAL END RETURN END FUNCTION VAL( VAR ) !! Hashed version COMMON /..SET/ VARS(N), VALS(N) HASH = MOD( SEQ(VAR[1,1])*LEN(VAR), N )+1 RES = "" LOCATE VAR IN VARS(HASH)<1> SETTING II THEN RES = VALS(HASH) END RETURN (RES) END -- mats --- u2-users mailing list u2-users@listserver.u2ug.org To unsubscribe please visit http://listserver.u2ug.org/ --- u2-users mailing list u2-users@listserver.u2ug.org To unsubscribe please visit http://listserver.u2ug.org/
Re: [U2] [UV] reference a variable indirectly?
Barry Brevik wrote: UV 9.6.1.3 on Windows. For the longest time this has been bugging me, but right now I could really use this capability. Does anyone know if it is possible to reference a variable indirectly? IOW, I want to be able to store variable names in a file (for example), and then assign values to those variables as the program encounters them. For example, something like this: PARTNO = ''; LOTNO = ''; PARTNAME = '' VAR.NAMES = 'PARTNO':@FM:'LOTNO':@FM:'PARTNAME' * * Next, a magic command that makes the variable * refered to by VAR.NAMES<2> equal to 'it works'. (VAR.NAMES<2>) = 'it works'; * I know this does not work, just example. PRINT LOTNO * * Variable LOTNO is now eq 'it works'. Possible?? Barry No there is no way to do that. You'd need an 'eval' function/statement. But You can do something similar with a subroutine and a function. Subroutine SET( variable name, value ) Function VAL( variable name ) They need to share a common ( or a file ) where variable-value pairs are stored. A straight forward implementation would be to search for the variable name in an mv-string and use the index to look up the value from another mv string. If you know the number of entries you can use arrays. Even if you don't you can still use arrays by running imformation style allowing them to be redimensioned. Then Your program would look like: DEFFUN VAL( var ) CALLING "VAL" CALL SET( 'LOTNO', 'it works' ) PRINT VAL( 'LOTNO' ) Naive untested implementation. If heavily used you'd need to hash e.g. as MOD( SEQ(VAR[1,1])*LEN(VAR), N )+1 where N is the number of hash points and the dimension of VARS and VALS. SUBROUTINE SET( VAR, VAL) COMMON /..SET/ VARS, VALS LOCATE VAR IN VARS<1> SETTING II THEN VALS = VAL END ELSE VARS<-1> = VAR VALS<-1> = VAL END RETURN END FUNCTION VAL( VAR ) !! Hashed version COMMON /..SET/ VARS(N), VALS(N) HASH = MOD( SEQ(VAR[1,1])*LEN(VAR), N )+1 RES = "" LOCATE VAR IN VARS(HASH)<1> SETTING II THEN RES = VALS(HASH) END RETURN (RES) END -- mats --- u2-users mailing list u2-users@listserver.u2ug.org To unsubscribe please visit http://listserver.u2ug.org/
RE: [U2] [UV] reference a variable indirectly?
Barry, Try EQU LOTNO LIT "VAR.NAMES<2>" Rgds, Stewart -Original Message- From: Anthony Dzikiewicz [mailto:[EMAIL PROTECTED] Sent: Wednesday, 13 April 2005 9:07 To: u2-users@listserver.u2ug.org Subject: RE: [U2] [UV] reference a variable indirectly? You could probably use the EQUATE statement ? -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Barry Brevik Sent: Tuesday, April 12, 2005 6:59 PM To: U2-users (E-mail) Subject: [U2] [UV] reference a variable indirectly? UV 9.6.1.3 on Windows. For the longest time this has been bugging me, but right now I could really use this capability. Does anyone know if it is possible to reference a variable indirectly? IOW, I want to be able to store variable names in a file (for example), and then assign values to those variables as the program encounters them. For example, something like this: PARTNO = ''; LOTNO = ''; PARTNAME = '' VAR.NAMES = 'PARTNO':@FM:'LOTNO':@FM:'PARTNAME' * * Next, a magic command that makes the variable * refered to by VAR.NAMES<2> equal to 'it works'. (VAR.NAMES<2>) = 'it works'; * I know this does not work, just example. PRINT LOTNO * * Variable LOTNO is now eq 'it works'. Possible?? Barry --- u2-users mailing list u2-users@listserver.u2ug.org To unsubscribe please visit http://listserver.u2ug.org/ -- No virus found in this incoming message. Checked by AVG Anti-Virus. Version: 7.0.308 / Virus Database: 266.9.6 - Release Date: 4/11/2005 -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.308 / Virus Database: 266.9.6 - Release Date: 4/11/2005 --- u2-users mailing list u2-users@listserver.u2ug.org To unsubscribe please visit http://listserver.u2ug.org/ ** This email and any attachments are confidential. They may contain legally privileged information or copyright material. You should not read, copy, use or disclose them without authorisation. If you are not an intended recipient, please contact us at once by return email and then delete the original message and all copies. We do not accept liability in connection with computer virus, data corruption, delay, interruption, unauthorised access or unauthorised amendment. ** --- u2-users mailing list u2-users@listserver.u2ug.org To unsubscribe please visit http://listserver.u2ug.org/
Re: [U2] [UV] reference a variable indirectly?
Goo'day, Barry At 15:58 12/04/05 -0700, you wrote: UV 9.6.1.3 on Windows. For the longest time this has been bugging me, but right now I could really use this capability. Does anyone know if it is possible to reference a variable indirectly? IOW, I want to be able to store variable names in a file (for example), and then assign values to those variables as the program encounters them. For example, something like this: PARTNO = ''; LOTNO = ''; PARTNAME = '' VAR.NAMES = 'PARTNO':@FM:'LOTNO':@FM:'PARTNAME' * * Next, a magic command that makes the variable * refered to by VAR.NAMES<2> equal to 'it works'. (VAR.NAMES<2>) = 'it works'; * I know this does not work, just example. PRINT LOTNO * * Variable LOTNO is now eq 'it works'. Possible?? Isn't this a bit (whatever the word I'm looking for is)??? If you already have a variable of PART.NO "set" (so you can "set" it in VAR.NAMES) why the blazes would you want to go through a two-step process to find out what PART.NO is again later in the program? Seems a tad Oirish t'me.. unless I don't understand your problem Barry --- u2-users mailing list u2-users@listserver.u2ug.org To unsubscribe please visit http://listserver.u2ug.org/ -- No virus found in this incoming message. Checked by AVG Anti-Virus. Version: 7.0.308 / Virus Database: 266.9.6 - Release Date: 11/04/05 -- No virus found in this incoming message. Checked by AVG Anti-Virus. Version: 7.0.308 / Virus Database: 266.9.6 - Release Date: 11/04/05 Regards, Bruce Nichol Talon Computer Services ALBURYNSW 2640 Australia http://www.taloncs.com.au Tel: +61 (0)411149636 Fax: +61 (0)260232119 If it ain't broke, fix it till it is! -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.308 / Virus Database: 266.9.7 - Release Date: 12/04/05 -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.308 / Virus Database: 266.9.7 - Release Date: 12/04/05 --- u2-users mailing list u2-users@listserver.u2ug.org To unsubscribe please visit http://listserver.u2ug.org/
RE: [U2] [UV] reference a variable indirectly?
You could probably use the EQUATE statement ? -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Barry Brevik Sent: Tuesday, April 12, 2005 6:59 PM To: U2-users (E-mail) Subject: [U2] [UV] reference a variable indirectly? UV 9.6.1.3 on Windows. For the longest time this has been bugging me, but right now I could really use this capability. Does anyone know if it is possible to reference a variable indirectly? IOW, I want to be able to store variable names in a file (for example), and then assign values to those variables as the program encounters them. For example, something like this: PARTNO = ''; LOTNO = ''; PARTNAME = '' VAR.NAMES = 'PARTNO':@FM:'LOTNO':@FM:'PARTNAME' * * Next, a magic command that makes the variable * refered to by VAR.NAMES<2> equal to 'it works'. (VAR.NAMES<2>) = 'it works'; * I know this does not work, just example. PRINT LOTNO * * Variable LOTNO is now eq 'it works'. Possible?? Barry --- u2-users mailing list u2-users@listserver.u2ug.org To unsubscribe please visit http://listserver.u2ug.org/ -- No virus found in this incoming message. Checked by AVG Anti-Virus. Version: 7.0.308 / Virus Database: 266.9.6 - Release Date: 4/11/2005 -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.308 / Virus Database: 266.9.6 - Release Date: 4/11/2005 --- u2-users mailing list u2-users@listserver.u2ug.org To unsubscribe please visit http://listserver.u2ug.org/
RE: [U2] [UV] reference a variable indirectly?
It seems something like this would be possible using a function. The function would take a variable name, read that value from a file, and then return the value that was read which, as a function, could then be assigned to a variable, as in: LOT.NO = GETVALUE('LOT.NO') ...just a thought. -Kevin [EMAIL PROTECTED] http://www.PrecisOnline.com -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Barry Brevik Sent: Tuesday, April 12, 2005 3:59 PM To: U2-users (E-mail) Subject: [U2] [UV] reference a variable indirectly? UV 9.6.1.3 on Windows. For the longest time this has been bugging me, but right now I could really use this capability. Does anyone know if it is possible to reference a variable indirectly? IOW, I want to be able to store variable names in a file (for example), and then assign values to those variables as the program encounters them. For example, something like this: PARTNO = ''; LOTNO = ''; PARTNAME = '' VAR.NAMES = 'PARTNO':@FM:'LOTNO':@FM:'PARTNAME' * * Next, a magic command that makes the variable * refered to by VAR.NAMES<2> equal to 'it works'. (VAR.NAMES<2>) = 'it works'; * I know this does not work, just example. PRINT LOTNO * * Variable LOTNO is now eq 'it works'. Possible?? Barry --- u2-users mailing list u2-users@listserver.u2ug.org To unsubscribe please visit http://listserver.u2ug.org/ -- No virus found in this incoming message. Checked by AVG Anti-Virus. Version: 7.0.308 / Virus Database: 266.9.6 - Release Date: 4/11/2005 -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.308 / Virus Database: 266.9.6 - Release Date: 4/11/2005 --- u2-users mailing list u2-users@listserver.u2ug.org To unsubscribe please visit http://listserver.u2ug.org/