Jump to content
Developer Wiki and Function Reference Links ×

Criteria as parameter of a user made procedure. Is it possible?


Musisback

Recommended Posts

Alright,Thanks.

The problem a get now is that there are quote marks in the criteria:

PON='obj type' so I have trouble assigning the good value to the string.

I could make it work using concat('PON=',chr(39),'obj type',chr(39) .... ) but it is not a very practical way...

Is there an easy way to assign quote marks to a string?

Link to comment

I could make it work using concat('PON=',chr(39),'obj type',chr(39) .... )

Why do you need to assign extra quote marks to a string since by definition a string requires only one set of quote marks?

If you define criteria as a string variable:

 
VAR
 totPio: LONGINT;
 criteria: STRING;
BEGIN
criteria:= 'obj type';
totPio:= Count(PON=criteria);
END;

Link to comment

Miguel,

At least in the past, the PON=Variable_Name construct did not work and you had to put the entire criteria into the variable and just use Count(Variable_Name).

Musisback,

Here is a part of a thread from the Vectorscript maillist that talks about different ways to make the criteria strings.

Or another way to write this is:

DBCrit := Concat('=Database(((L= ', chr(39), Lname ,chr(39), ' )&

(T=Symbol) ))');

The chr(39) converts to an actual in line quote mark before and after

the Lname.

The original code worked fine on layers without spaces in the layer

name, but failed if there were spaces.

Charles method is correct and certainly works, but my eyes cross on

trying to tell the difference between double and triple quotes. It is

hard to miss the chr() in the middle of the concat.

Also, Charles, is there any reason that the criteria generator always

(in my opinion) adds an extra set of parens around any criteria you

create? (((L='Sheet Layer-1') & (T=SYMBOL))) is the code created by

the VS Editor criteria generator. I don't think the outermost parens

are needed.

Regards,

Pat

Patrick Stanford

Vectortasks Training Seminars for VectorWorks

The PodCAD podcast - The podcast for the VectorWorks community

vwseminar@coviana.com

On Oct 2, 2006, at 9:21 PM, Charles Chandler wrote:

You just needed triple quotes in your

function concat() {

[native code]

}

statement, so that once evaluated, there would still be a single

quote in the string.

Also, enclose each piece of the criteria in its own parentheses,

and then enclose all of them in one more set.

Cheers!

Procedure WSSymLayer;

Var

WS : Handle;

WSimage : Handle;

LName,DBCrit : STRING;

Begin;

WS := CreateWS('test',2,2);

LName := GetLName(ActLayer);

DBCrit := Concat('=DATABASE(((L=''', Lname, ''' )&(T=SYMBOL)))');

SetWSCellFormula(WS,1,1,1,1,LName);

SetWSCellFormula(WS,2,0,2,0,DBCrit);

SetWSCellFormula(WS,2,1,2,1,'=S');

SetWSCellFormula(WS,2,2,2,2,'=1');

WSimage := CreateWSimage(ws,0,0);

ShowWS(WSImage, true);

SetWSColumnOperators(WS,2,0,0,0,1,1,1) ;

RecalculateWS( WS ) ;

ReDrawAll;

End;

Run(WSSymLayer);

Link to comment

Pat

Sorry to disagree because I use this method in all the scripts and it has always worked for me.

I believe if you go back some months ago, we already had this discussion and I found out that it does not work with variables that are 5 characters or less in length. I usually use more descriptive variable names which are more than 5 characters, so I never get that bug.

I know that you want to keep it simple and use single character variables in your scripts such as A,B,C but just for clarity I prefer using the longer names.

Link to comment

Thanks for the tip Miguel, didn't knew that!

Not completely on topic, but maybe useful non the less:

A criteria can not be a DynArray of Char but must be a String. That means that it's limited in length. I noticed this some weeks ago in one of my scripts where in some options i had a quite long criteria, i had to rebuild it to make it work.

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