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.NAMES2 equal to 'it works'. (VAR.NAMES2) = '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 VARS1 SETTING II THEN VALSII = 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)II 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?
Try this for size 0001: EQUATE PART.NO LIT 'REC1' 0002: REC1 = '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.NAMES2 equal to 'it works'. (VAR.NAMES2) = '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 VARS1 SETTING II THEN VALSII = 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)II 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?
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. ARRAY1,-1 = PARTNO ARRAY1,-1 = LOTNO ARRAY1,-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 ARRAY1 to find the field name and does what it likes to ARRAY2,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.NAMES2 equal to 'it works'. (VAR.NAMES2) = '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 VARS1 SETTING II THEN VALSII = 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)II 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/
[U2] [UV] ACOS problem (floating point numbers)
We have some code that is calculating distances between points, using SIN(), COS() and ACOS(). Occasionally we get the error: Argument domain error in arc-cosine, zero returned This seems to be occurring when two floating point numbers are added together and the result is exactly 1 (or at least seems to be exactly 1), I assume internally the number is slightly over 1. Here's some example code: PRECISION 14 FROM.LAT = -31.29583 FROM.LONG = 119.65194 DEST.LAT = -31.29583 DEST.LONG = 119.65194 VAR1 = SIN(FROM.LAT) * SIN(DEST.LAT) VAR2 = (DEST.LONG - FROM.LONG) VAR3 = COS(FROM.LAT) * COS(DEST.LAT) * COS(VAR2) VAR4 = VAR1 + VAR3 CRT VAR1 = :VAR1 CRT VAR2 = :VAR2 CRT VAR3 = :VAR3 CRT VAR4 = :VAR4 TEMP1 = ACOS(VAR4) TEMP2 = ACOS(VAR4:) VAR4 is displayed as 1, but when TEMP1 is assigned we get the above error message. When TEMP2 is assigned we get no error (i.e. the temporary variable passed to the second ACOS function was a string not a number). Maybe concatenating an empty string during the ACOS() call is the fix for this but it's not really ideal. Anyone have any comments on this? And what happens on your machine? BTW our widezero config setting is 3dc0 AdrianW DISCLAIMER: Disclaimer. This e-mail is private and confidential. If you are not the intended recipient, please advise us by return e-mail immediately, and delete the e-mail and any attachments without using or disclosing the contents in any way. The views expressed in this e-mail are those of the author, and do not represent those of this company unless this is clearly indicated. You should scan this e-mail and any attachments for viruses. This company accepts no liability for any direct or indirect damage or loss resulting from the use of any attachments to this e-mail. --- u2-users mailing list u2-users@listserver.u2ug.org To unsubscribe please visit http://listserver.u2ug.org/
Re: [U2] [UV] Select returning mv'd list
Does UniVerse have QSELECT? I see it is mentioned in the Guide to RetrieVe Manual. Creating Select Lists Select lists are created using the RetrieVe commands SELECT, SSELECT, and SEARCH (or ESEARCH), as well as the non-RetrieVe commands NSELECT, QSELECT, and FORM.LIST). QSELECT FILE.A 'key' (1 That's how we used to have to do it in the olden days. Bruce M Neylon Health Care Management Group Kevin King [EMAIL PROTECTED] Sent by: [EMAIL PROTECTED] 04/12/2005 07:02 PM Please respond to u2-users To: u2-users@listserver.u2ug.org cc: Subject:[U2] [UV] Select returning mv'd list Universe 9.6, I want to select a record from a file and return a mv'd list of information in attribute 1, each attribute as a separate list element. On Unidata, I can: SELECT FILE.A 'key' F1 ...and it'll return all the values in F1 as individual items in the active select list. On Universe, this does not work. So I tried: SELECT FILE.A 'key' SAVING UNIQUE F1 ...and I get all the items, but they come in one attribute, mv'd, not split out on each line like Unidata would. I've also tried QSELECT, but apparently the option to QSELECT a single attribute from a file is not supported here here. How do you select a record from a file and return a mv'd list from an attribute in that record? -Kevin HYPERLINK mailto:[EMAIL PROTECTED][EMAIL PROTECTED] http://www.PrecisOnline.com -- 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/ --- u2-users mailing list u2-users@listserver.u2ug.org To unsubscribe please visit http://listserver.u2ug.org/
RE: [U2] [UV] Select returning mv'd list
Try QSELECT file key SAVING fieldno -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Kevin King Sent: 13 April 2005 13:46 To: u2-users@listserver.u2ug.org Subject: RE: [U2] [UV] Select returning mv'd list Tried that. No dice. What I got was the key to the record and extraneous multivalue information (pointers). -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Andrew Lakeland Sent: Tuesday, April 12, 2005 11:31 PM To: u2-users@listserver.u2ug.org Subject: RE: [U2] [UV] Select returning mv'd list Try exploding the attribute SELECT FILE.A 'Key' BY.EXP F1 SAVING F1 RE ANDY -Original Message- From: Kevin King [mailto:[EMAIL PROTECTED] Sent: 13 April 2005 01:02 To: u2-users@listserver.u2ug.org Subject: [U2] [UV] Select returning mv'd list Universe 9.6, I want to select a record from a file and return a mv'd list of information in attribute 1, each attribute as a separate list element. On Unidata, I can: SELECT FILE.A 'key' F1 ...and it'll return all the values in F1 as individual items in the active select list. On Universe, this does not work. So I tried: SELECT FILE.A 'key' SAVING UNIQUE F1 ...and I get all the items, but they come in one attribute, mv'd, not split out on each line like Unidata would. I've also tried QSELECT, but apparently the option to QSELECT a single attribute from a file is not supported here here. How do you select a record from a file and return a mv'd list from an attribute in that record? -Kevin HYPERLINK mailto:[EMAIL PROTECTED][EMAIL PROTECTED] http://www.PrecisOnline.com -- 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/ --- 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/ The information contained in this email is strictly confidential and for the use of the addressee only, unless otherwise indicated. If you are not the intended recipient, please do not read, copy, use or disclose to others this message or any attachment. Please also notify the sender by replying to this email or by telephone +44 (0)20 7896 0011 and then delete the email and any copies of it. Opinions, conclusions (etc.) that do not relate to the official business of this company shall be understood as neither given nor endorsed by it. IG Markets Limited and IG Index Plc are authorised and regulated by the Financial Services Authority and, in Australia, by the Australian Securities and Investments Commission. --- u2-users mailing list u2-users@listserver.u2ug.org To unsubscribe please visit http://listserver.u2ug.org/
[U2] [UV] Version Control
Brian, This intrigued. ... version stamp your source code in a way that can be saved into the object code Where do you put it, what do you put there? What platform(s) have you done this on? I know we dig into the unix-level directories for their date ... (PRC checks that the object is newer than the source or it won't deliver (either/both)... and we have script/proc/macros/programs whatever that can search and display those dates from unix) ... but I'm interested in where you went with this. I think it's a good idea. Susan --- u2-users mailing list u2-users@listserver.u2ug.org To unsubscribe please visit http://listserver.u2ug.org/
Re: [U2] Extending U2 with gci/CALLC -- Factory Floor Automation -Serial
Hi Ed, We use intercall.h mostly for webbased data queries. We have perl CGI pages (Linux/Apache) that first parse and validate user input. If the input is acceptable, an intercall app is executed. The intercall app then opens a connection to a limited copy our production UV server and executes a cataloged subroutine. The data is returned to the intercall program which then returns it to the CGI script which formats it for output as html. Althought this process might sound a little convoluted, it is extremely fast. I've also used this technique to run reports that are printed to a .pdf by the rsync'ed UV back end and then 'pushed out' to the web server for viewing in a webbrowser's Acrobat plug-in. It's pretty neat to be in say, an airport terminal that has wireless access and go to your web site with your PocketPC, run a report and view it as a pdf while waiting to board your plane. Brian Grayson Ed Clark wrote: As a curiosity, how many people have used universe gci or the unidata equivalent with CALLC/CallBasic to extend the capabilities of U2? When I see comments like the one below (suggesting that only newer versions of U2 let you use sockets) I always wonder about the experiences and success stories people have had. (though yes, it did always seem a little daunting creating a whole new universe--very much god-stuff) -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of [EMAIL PROTECTED] Sent: Monday, April 11, 2005 3:12 PM To: u2-users@listserver.u2ug.org Subject: RE: [U2] Factory Floor Automation - Serial Connectivity ? Replying to my own messaging... Kind of like talking to myself... With newer UV versions you shouldn't need the C socket program but be able to talk to the device server directly. --- 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/