Jump to content
Developer Wiki and Function Reference Links ×

Help with Object name from Field value


Tom4

Recommended Posts

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

Link to comment

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.

Link to comment

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

Link to comment

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.

Link to comment

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.

Link to comment

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

Link to comment

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."

Link to comment
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 by brudgers
Link to comment
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?

Link to comment

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.

Link to comment

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...