Musisback Posted November 26, 2010 Share Posted November 26, 2010 I am trying to create a procedure that uses 'C: Criteria' as parameter like in the build-in procedure "ForEachObject(callback :PROCEDURE; c :CRITERIA)" The compiler does not recognise the Criteria variable type. Do I do something wrong? Or is writing such procedure impossible? Thanks, Quote Link to comment
maarten. Posted November 26, 2010 Share Posted November 26, 2010 A criteria is actually a string, so you can use (c : STRING). Quote Link to comment
Musisback Posted November 29, 2010 Author Share Posted November 29, 2010 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? Quote Link to comment
Miguel Barrera Posted November 29, 2010 Share Posted November 29, 2010 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; Quote Link to comment
Pat Stanford Posted November 29, 2010 Share Posted November 29, 2010 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); Quote Link to comment
Miguel Barrera Posted November 29, 2010 Share Posted November 29, 2010 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. Quote Link to comment
maarten. Posted November 29, 2010 Share Posted November 29, 2010 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. Quote Link to comment
Pat Stanford Posted November 29, 2010 Share Posted November 29, 2010 Miguel, You are correct. I was trying to find that thread and didn't find it before I sent the message. 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.