Jump to content
Developer Wiki and Function Reference Links ×

Using Criteria


Recommended Posts

Hi Again,

If I select the "Criteria" button in the VS Editor window I get a dialogue like the Custom Selection dialogue in the program interface. Choosing (for instance) Type is Polyline yields a script result.

((T=POLYINE))

In the VS Language guide appendix there is a table of Object Types which idenitifies "polylines" as having

a TYPE as being 21, and a CRITERIA as being POLYLINE

Questions

1/How does one use the form

((T=WHATEVER)) in practice in a script?

eg; as one might use the program command "Custom Selection>select only objects whose>type is polyline"

(or am I completely off the CRITERIA beam here?)

and; why two sets of brackets?

2/ If a "polyline" has a TYPE identified as "21"

why not

((T=21)) instead of ((T=POLYLINE)) ?

cheers,

N.

Link to comment

Some v-script functions take criteria as a parameter:

PROCEDURE PickPoly;

PROCEDURE Pick(H : HANDLE);

BEGIN

SetSelect(H);

END;

BEGIN

ForEachObject(Pick, T=POLYLINE);

END;

Run(PickPoly);

T=21 will also work. Count() is an example of another ready-made that takes criteria,as is SelectObj():

PROCEDURE PickPoly;

BEGIN

SelectObj(T=21);

END;

Run(PickPoly);

Object types can be used in logical expressions:

PROCEDURE PickPoly;

VAR

h:HANDLE;

BEGIN

h:=FActLayer;

WHILE h <> Nil Do Begin

IF (GetType(h)=21) Then setselect(h);

h:=NextObj(h);

End;

END;

Run(PickPoly);

In this case 21 must be used because GetType is a function that returns an integer, not a string.

I've never used the criteria button and don't know why it inserts two sets of parenthesis.In fact I don't know how to describe exactly how and why parenthesis are used in a way that covers all the instances in which they are required.

Here's an example of something that exits the script with a double click:

Procedure TakeOff;

VAR

x1,y1,x2,y2:REAL;

dist,tote:REAL;

BEGIN

dist:=1;

WHILE dist>0 DO BEGIN

GetLine(x1,y1,x2,y2);

dist:=Distance(x1,y1,x2,y2);

tote:=dist+tote;

END;

MESSAGE('Total Length = ',tote/12,' ft');

END;

Run(TakeOff);

You seem to be blessed with one of the main prerequisites in teaching yourself v-script from scratch: boneheaded determination. That's what got me thru.

Link to comment

Thanks for your reply,

I'm still working through your examples.

Ive used one to get my polyThing script to go a bit further, the rest of the examples I've used in various ways to find new error messages I hadn't seen before :-)

quote:

You seem to be blessed with one of the main prerequisites in teaching yourself v-script from scratch: boneheaded determination.

well, that seems a bit nicer than the

"You stubborn little s**t"

that my wife uses when I don't do what she wants me to ;-D

cheers

Link to comment

I believe the double parens are there in case two, or more, search criteria are selected.

eg. SelectObj((T=21) & (LS=2) & (FF=0));

Read this as "Select all objects that are Type=21 (polygon) AND Line Style=2 (solid foreground color) AND Foreground Fill=0 (None)."

One set of parens is all that is needed, but duplicates don't hurt the compiler. The programmers didn't write code that would adjust for the special case of one selection criteria using one set of parens. It's been like this for a very long time, and it is confusing for new programmers.

HTH,

Raymond

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