Tom4 Posted September 16, 2009 Share Posted September 16, 2009 Hi, I have been going crazy trying to get an Oject name associated to a field value. I used something similar to the Select object comment to get the handle then get name for something else but I can not get "ObjectNameA" from field value 'ADNDI'. Any help would be greatly appreciated. Procedure tryScript; {$DEBUG} VAR h : HANDLE; x, ObjectNameA : STRING; BEGIN x := 'ADNDI'; ObjectNameA := 'ADN 22x28 Wall'; {Record name = various} {field name =' '. 'Order'} {field value = 'ADNDI'} {SelectObj(INSYMBOL & (N = (' '.'Order'=x)));} h := GetObject( ObjectNameA ); ObjectNameA := GetName( h ); Message ( GetSDName(h) ); END; RUN (tryScript); ThankYou Tom Quote Link to comment
Kool Aid Posted September 16, 2009 Share Posted September 16, 2009 I don't see SetName here. Be it as it may, object names are a minefield and an extremely useful part of validation and data normalisation. Also, I believe, a moving target. Whatever: for a valid result, you have to establish a unique object name, Set it and test that it has been applied with GetName. If you get "none", "None" or an empty string, keep going and generate new name candidates eg. with a integer loop. Quote Link to comment
Pat Stanford Posted September 16, 2009 Share Posted September 16, 2009 I don't quite understand what you are trying to do. Are you trying to set the object name to a value that has been entered in a field? SetName(Handle,GetRField(Handle,'Record','Field')); or are you trying to set a field to the name? SetRField(Handle,'Record','Field',GetName(Handle)); Quote Link to comment
Tom4 Posted September 16, 2009 Author Share Posted September 16, 2009 Thank you for your help. I have a symbol with a field existing in the record. I am trying to get a handle (or symbol name)for the symbol using the string that exists in it's field. The sample code I put up, I was hoping to claify what I was trying to do. I can get the handle if I use SelectObject I am trying to do it with out selecting each object then deselting it. Thanks you for your comments on this. Tom Quote Link to comment
Pat Stanford Posted September 16, 2009 Share Posted September 16, 2009 Maybe Something like: Procedure Test; Var H1:Handle; Procedure DoIt(H2:Handle); Begin Message(Date(2,2),' Symbol Def Name is: ',GetSDName(H2)); End; Begin ForEachObject(DoIt, 'Record'.'Field'='ABABA'); End; Run(Test); Obviously this has not been tested. By using ForEachObject you will be able to get all of the objects that have that field value. If you only want one, then you need to put code in DoIt to ignore all but the first (or last) time through. Quote Link to comment
Pat Stanford Posted September 16, 2009 Share Posted September 16, 2009 Maybe Something like: Procedure Test; Var H1:Handle; Procedure DoIt(H2:Handle); Begin Message(Date(2,2),' Symbol Def Name is: ',GetSDName(H2)); End; Begin ForEachObject(DoIt, 'Record'.'Field'='ABABA'); End; Run(Test); Obviously this has not been tested. By using ForEachObject you will be able to get all of the objects that have that field value. If you only want one, then you need to put code in DoIt to ignore all but the first (or last) time through. Quote Link to comment
brudgers Posted September 17, 2009 Share Posted September 17, 2009 If you only want one, then you need to put code in DoIt to ignore all but the first (or last) time through. When I saw "[font:Courier New]DoIt[/font]" rendered in the board's default typeface, for a moment I thought you were someone else. Quote Link to comment
Pat Stanford Posted September 17, 2009 Share Posted September 17, 2009 I don't remember where I picked up the DoIt procedure. Actually I do. That is the sample they use in the VS Function Reference. It just makes sense to me. ForEachObject runs once for each object with the specified criteria and does the code contained in the DoIt Procedure. Quote Link to comment
Tom4 Posted September 17, 2009 Author Share Posted September 17, 2009 Pat, When I put in valid Record, Field, & Field Data I get a Handle value in debug but it comes up with "Warning: Symbol definition handle not valid." and the message box diplays "7:46:38 AM Symbol Def Name is:". I'm sorry but I still seem to be missing something. Procedure Test; {$DEBUG} Var H1:Handle; Procedure DoIt(H2:Handle); Begin Message(Date(2,2),' Symbol Def Name is: ',GetSDName(H2)); End; Begin ForEachObject(DoIt, 'Display'.'Order'='ADNDI'); End; Run(Test); Thank You for your time and help on this, Tom Quote Link to comment
Kool Aid Posted September 17, 2009 Share Posted September 17, 2009 Obviously a non-symbol meets your criterion. How about ForEachObject(DoIt,((T=SYMBOL) & (R IN ['Display']) & ('Display'.'Order'='ADNDI')); No, probably not. There could be a much deeper problem; at least I still have no idea what you're trying to achieve (and what are the operational parameters) so I can't even assess the prospect of achieving it. "I speak of none other than the computer that is to come after me," intoned Deep Thought, his voice regaining its accustomed declamatory tones. "A computer whose merest operational parameters I am not worthy to calculate ? and yet I will design it for you." Quote Link to comment
brudgers Posted September 17, 2009 Share Posted September 17, 2009 (edited) I don't remember where I picked up the DoIt procedure. Actually I do. That is the sample they use in the VS Function Reference. It just makes sense to me. ForEachObject runs once for each object with the specified criteria and does the code contained in the DoIt Procedure. [font:Courier New]"DoIt" [/font] is a good procedure name. But the sans serif typeface makes it look like [font:Courier New]"Dolt" [/font]. I'll let you guess who it reminded me of. Edited September 17, 2009 by brudgers Quote Link to comment
Kool Aid Posted September 17, 2009 Share Posted September 17, 2009 I don't remember where I picked up the DoIt procedure. Actually I do. That is the sample they use in the VS Function Reference. It just makes sense to me. ForEachObject runs once for each object with the specified criteria and does the code contained in the DoIt Procedure. [font:Courier New]"DoIt" [/font] is a good procedure name. But the sans serif typeface makes it look like [font:Courier New]"Dolt" [/font]. I'll let you guess who it reminded me of. Yourself? Quote Link to comment
Pat Stanford Posted September 17, 2009 Share Posted September 17, 2009 I must be using a different style sheet as it comes in with serifs here. ;-) Quote Link to comment
Pat Stanford Posted September 17, 2009 Share Posted September 17, 2009 Try this: Procedure DoIt(H2:Handle); var S1:String; Begin S1:=GetSymName(H2); H1:=GetObject(S1); Message(Date(2,2),' Symbol Def Name is: ',GetSDName(H1)); End; H2 is a handle to the symbol instance. GetSymName will get the name of the symbol GetObject will get a handle to the object with the name. That should be the Symbol Definition. I new this last night and just didn't think about it. This is really the difference between the instance (placed object) of a symbol and the symbol definition. Quote Link to comment
Kool Aid Posted September 17, 2009 Share Posted September 17, 2009 Last night you had the strangest dream? Yep. This afternoon I had one, too. The dicotomy between an instance and a definition could well be the issue. Meanwhile, 'm keen to see the next exciting episode? Quote Link to comment
Tom4 Posted September 17, 2009 Author Share Posted September 17, 2009 Thank You Thank You This would have been driving me crazy but, I'm already there, so I was just frustrated. When I get all the pieces of this together I will put it up for anyone intersted. Thanks again Tom Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.