Christiaan Posted November 22, 2007 Share Posted November 22, 2007 I took a toggle guides script: IF ((GetCVis('Guides')) = 0) THENBEGIN HideClass('guides');ENDELSE ShowClass('guides');END; And tried to convert it for another Class we have (In House Info-Activity Zones): IF ((GetCVis('In House Info-Activity Zones')) = 0) THENBEGIN HideClass('in house info-activity zones');ENDELSE ShowClass('in house info-activity zones');END; But I've done something wrong because it doesn't work. Can someone help me out? Quote Link to comment
Dieter @ DWorks Posted November 22, 2007 Share Posted November 22, 2007 (edited) Why are you using Capitals in the first name of your class and no capitals in the others? It's that, Be sure you use correct strings. Edited November 22, 2007 by DWorks Quote Link to comment
Christiaan Posted November 22, 2007 Author Share Posted November 22, 2007 Why are you using Capitals in the first name of your class and no capitals in the others? I was following the format of the Guides example. It's that, Be sure you use correct strings. Changed them to caps but still doesn't work: Line #1: IF ((GetCVis('In House Info-Activity Zones')) = 0) THENBEGIN HideClass('In House Info-Activity Zones');ENDELSE ShowClass('In House Info-Activity Zones');END; | { Error: Identifier not declared. } | { Error: Expected THEN } | { Error: Did not expect this after end of statement - missing ;? } | { Error: Identifier not declared. } Quote Link to comment
Dieter @ DWorks Posted November 22, 2007 Share Posted November 22, 2007 you'll have to put a space between THEN and BEGIN, or the compiler will read it as THENBEGIN which he sees as a variable which you did not declare. It's much clearer when you also show the errors VS gives. It always gives a hint to what is wrong. Quote Link to comment
Petri Posted November 22, 2007 Share Posted November 22, 2007 In fact, BEGIN and END are redundant: IF ((GetCVis('In House Info-Activity Zones')) = 0) THEN HideClass('In House Info-Activity Zones') ELSE ShowClass('In House Info-Activity Zones'); Now, to make life easier, the class name could be a constant. Quote Link to comment
Christiaan Posted November 22, 2007 Author Share Posted November 22, 2007 Okay, thanks DWorks. Strange how the Guides toggle script works without the spaces though. Can't remember where I got the Guides script from. Quote Link to comment
Petri Posted November 22, 2007 Share Posted November 22, 2007 Line #1: IF ((GetCVis('Guides')) = 0) THENBEGIN HideClass('guides');ENDELSE ShowClass('guides');END; | { Error: Identifier not declared. } | { Error: Expected THEN } | { Error: Did not expect this after end of statement - missing ;? } | { Error: Identifier not declared. } Quote Link to comment
Petri Posted November 22, 2007 Share Posted November 22, 2007 In fact, BEGIN and END are redundant: I should have noticed this before... Why would one always want a greyed class to become visible? If visible, become invisible, otherwise & regardless, become visible? Quote Link to comment
mike m oz Posted November 22, 2007 Share Posted November 22, 2007 Why not just toggle (switch) the Class visibility state using the Navigation palette. Quick and effortless. Quote Link to comment
Christiaan Posted November 23, 2007 Author Share Posted November 23, 2007 Why not just toggle (switch) the Class visibility state using the Navigation palette. Quick and effortless. To avoid having to scroll and find it first. There are a group of view toggles that we use quite a bit so I've elected to put them in everyone's context menu: Toggle Guides Toggle Activity Zones (a class we use to show activty zones around furniture, etc.) Toggle Zoom Line Thickness Toggle Objects in Group Toggle Viewport Crop Quote Link to comment
Pat Stanford Posted November 23, 2007 Share Posted November 23, 2007 Just a few comments to pull this thread together. 1. Variable and Constant (and procedure and function) names in vectorscript are NOT case sensative. Foo, FOO and foo are all read exactly the same by the compiler. 2. Begin and End statements are used to group a block of statements into a single logical group. You don't need them unless you have more than one statement between them. 3. If you do not use variable or constants in a vectorscript, you don't have to declare it a procedure. If you followed Petri's advise and specified a constant, you would have to the whole script a procedure and use a Begin/End and a Run statement. 4. If this is the entire script, the END; at the end of the script is not needed. Every End should have a matching Begin, and vice-versa. 5. Note that there is no semi-colon after the end before the Else. It is required to be this way. It is part of how If/Then/Else statements work. 6. If you use better formatting, it is often easier to debug VS. Here is the way I would have layed out the script. Remember, white space is ignored by VS. IF ((GetCVis('In House Info-Activity Zones')) = 0) THEN BEGIN HideClass('in house info-activity zones'); END ELSE ShowClass('in house info-activity zones'); Pat Quote Link to comment
Christiaan Posted October 28, 2014 Author Share Posted October 28, 2014 IF ((GetCVis('Example-Class')) = 0) THEN BEGIN HideClass('Example-Class'); END ELSE ShowClass('Example-Class'); What's the best way to add multiple Classes to this script? Quote Link to comment
Hippocode Posted October 28, 2014 Share Posted October 28, 2014 What's the best way to add multiple Classes to this script? create an array of classnames and use the above function in a loop. Quote Link to comment
Christiaan Posted November 3, 2015 Author Share Posted November 3, 2015 Belated thanks for the advice guys (must of been on a deadline at the time). 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.