James Russell Posted May 10, 2010 Share Posted May 10, 2010 (edited) Hey guys, Starting Vectorscripting and have made this so far: Procedure Test; VAR WSH :Handle; Begin WSH:=CreateWS(Concat('Test - ',Date(2,1)),10,5); SetWSCellFormula(WSH,1,0,1,0,'=DATABASE(R IN ('JAMES'))'); End; Run(Test); All going well I'm aiming to make this script make a worksheet, date it, and then change row 1 to a database lookup searching for objects with the record James. Error messages: Line #9: SetWSCellFormula(WSH,1,0,1,0,'=DATABASE(R IN ('JAMES'))'); | { Error: Identifier not declared. } | { Error: Expected ) } | { Error: Did not expect this after end of statement - missing ;? } Help please? Pretty sure it'd be simple but just not quite there! Cheers, James Edited May 11, 2010 by James Russell Quote Link to comment
Miguel Barrera Posted May 10, 2010 Share Posted May 10, 2010 Strings are delimeted by single quotes. In your formula '=DATABASE(R IN ('JAMES'))' the compiler reads it as '=DATABASE(R IN (' then JAMES which interprets as a variable and then '))' the formula should be written as '=DATABASE(R IN (''JAMES''))' where the double single quotes denotes a single quote character. Quote Link to comment
Vectorworks, Inc Employee klinzey Posted May 10, 2010 Vectorworks, Inc Employee Share Posted May 10, 2010 Two things. You neent to use [] rather than () and you need to escape the single quotes. SetWSCellFormula(WSH,1,0,1,0,'=DATABASE(R IN [''JAMES''])'); Quote Link to comment
Pat Stanford Posted May 10, 2010 Share Posted May 10, 2010 Or my favorite way of doing this: 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. using multiple quotes 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. Quote Link to comment
James Russell Posted May 10, 2010 Author Share Posted May 10, 2010 (edited) Thanks everyone for your help, obvious newbie mistake. Cheers, J Edited May 11, 2010 by James Russell 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.