Jump to content
Developer Wiki and Function Reference Links ×

Vectorscript Errors


MTRobin

Recommended Posts

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);

 

 

image.thumb.png.ecd5ff0c2fec475722b11d624f73dcab.png

Edited by MTRobin
Link to comment

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.

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