MTRobin Posted January 26, 2021 Share Posted January 26, 2021 (edited) I am struggling to get this script to work. I was hoping someone could look over my script and see how I can fix these errors. Thank you! PROCEDURE LayerOptionToggle; VAR LayerOption:INTEGER; BEGIN LayerOption:=GetPrefint(506, 6); IF (LayerOption = 3) THEN SetPrefint(506, 6) ELSE SetPrefint(506, 3) END; RUN(LayerOptionToggle); Edited January 26, 2021 by MTRobin Quote Link to comment
Peter Vandewalle Posted January 26, 2021 Share Posted January 26, 2021 I think the “SetPrefInt(506,3)” needs to end with “;” Quote Link to comment
Pat Stanford Posted January 26, 2021 Share Posted January 26, 2021 Peter is correct. The following compiles and toggles between Show Others and Grey/Snap Others. PROCEDURE LayerOptionToggle; VAR LayerOption:INTEGER; BEGIN LayerOption:=GetPrefint(506); IF (LayerOption = 3) THEN SetPrefint(506, 6) ELSE SetPrefint(506, 3); END; RUN(LayerOptionToggle); The line before an Else does not need (indeed can not have) a semicolon at the end. Most other lines must have a semicolon at the end. Even though it is a little more typing, I would probably have written it like this: PROCEDURE LayerOptionToggle; VAR LayerOption:INTEGER; BEGIN LayerOption:=GetPrefint(506); IF (LayerOption = 3) THEN Begin SetPrefint(506, 6); End ELSE Begin SetPrefint(506, 3); End; END; RUN(LayerOptionToggle); That way the lines between the Begin/End pairs alway can have the semicolon and the only one that does not have it is the End right before the Else. Quote Link to comment
MTRobin Posted January 26, 2021 Author Share Posted January 26, 2021 Good to know. Thanks for the help! 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.