Jump to content
Developer Wiki and Function Reference Links ×

AngleVar/Ang2Vec NOT working

Recommended Posts

This works great in MC 6&7, but does not in VW8.5.2. Needless to say, I really need it to work!

Procedure WhatBroke;


dist, ang :Real;

B :Vector;



dist := 2.7; { length }

ang := 33; { angle }

B := Ang2Vec(#ang, dist);



When compiled, I get:

Line #10: B := Ang2Vec(#ang, dist);


{ Error: Expected , }


{ Error: Expected ) }


{ Error: Did not expect this after end of statement - missing ;? }

However, if I remove the "AngleVar" statement it compiles and runs,

but it does not run correctly.

Any suggestions?

Link to comment

After further playing with the code, I found that if the pound sign (#) is removed from the Ang2Vec command, it WILL work in VW8.5.2. However, it will NOT work in MC7 or earlier. Thank you gentlemen for such a minor change with major consequences, without OBVIOUS documentation.

Link to comment
  • 3 years later...

Hi Dave,

AngleVar & NoAngleVar are essentially compiler directives. They indicate to the VS compiler the format that angle data will be encountered in subsequent code, until changed.

The short answer is - if you never use angle bearings for angle data (i.e., N, SE, WNW, etc.), use AngleVar. One caveat to keep in mind, if you use AngleVar at the beginning of your main program, it's effect will not carry forward at runtime into user defined procedures. Use AngleVar at the beginning of any procedure that uses angle data.

After reading the page you cited, I too am confused. I remember the definitions of AngleVar and NoAngleVar as being the other way around. The online manual (and all the HTML manuals I've downloaded all the way back to VW8.0) states that


... AngleVar will cause VectorScript to treat language symbols which can be interpreted as direction angles (e.g. N,S,NW,SE) as angles, rather than as variables.

Here's the definition of AngleVar I remember (and still abide by today). I cite the MiniCad+ 2.0 MiniPascal Language Manual (ppg. Macro 3L.139?140) ?


? if the user calls procedure AngleVar, this notifies the computer that variables will be used for angle values. Conversely, the procedure NoAngleVar informs the computer that no variables will be used for angle values and that any letters encountered should be treated as bearings. ?

I use AngleVar in most of my VS programs and it works consistently as described by the older definition. If this is still confusing, write back. I'll be glad to work through any issues with you.



Link to comment

Hullo R, thanks for the advice, I threw away my MiniPascal book a long time ago! And, yes, just a little more help would be appreciated:-

In the script below I get an error 'expected a new factor here' where I have an angle of 45.


PROCEDURE ThatNeverGetsCalled:




BEGIN {Testing}






It seems to have activated AngleVar although I never called the subprocedure that contains it. Why is that?

It works OK if I change it to 'Rotate(#45);' Does that mean all numeric angles have to be preceded by'#' when using AngleVar?

All this is undocumented as far as I can see. The only reference to '#' I can find is under 'Distance-angle mode'.


PS: Do you know why ths board is largely ignored in favour of the mailing list?

Link to comment


I can explain it, but it will take some time to write it up.

Although I am a latecomer to both the List and the Board (I wish I knew about them sooner), I believe the list was around long before the board and the list users like the email format. There is good help in both places, but if you want to learn all you can, stay tuned to both.

I'll get back to your questions later today.


Link to comment


If my last post is to be considered true, my days are longer than they used to be. Sorry for the delay. A clear explanation is difficult to put concisely in words, at least for me.

The effects of AngleVar and NoAngleVar carry forward through a script in a top down manner, regardless of procedure boundaries. They control the compiler, not the execution of a script, by telling the compiler what format of angle data to expect after an AngleVar/NoAngleVar was encountered, and they remain in effect until the next NoAngleVar/AngleVar statement is encountered. If you switch modes, you'll need to put AngleVar/NoAngleVar into each procedure that has angle values, to direct the compiler correctly. Think of the commands as reading Angle-Variables-Only (AngleVar) and No-Angle-Variables-If-It-Can-Be-Seen-As-A-Compass-Point (NoAngleVar).

"#" seems to have two effects. It can indicate that angle data is present OR that literal angular data is present. Some commands can be used in orthogonal and polar modes. The "#" indicates polar. MOVE is such a command. Normally, MOVE is used for X & Y pen displacements, but the following example shows it in the polar form.

MyAngle := 40;

Angle data is present: Move(1, #MyAngle ); { move pen 1 unit at 40? - works in both modes }

Literal angle data is present: Move(1, #NE); { move pen 1 unit to the NE or 45? - works in NoAngleVar only }

Use AngleVar and NoAngleVar to clear up any confusion that may result from variables that start with the letters (N, S, E or W). NoAngleVar is the default.

When NoAngleVar is in effect, VS will try to interpret the expression "#AngleData" as a literal (not a variable), and "AngleData" as a variable. Eight compass points are recognized. When a variable that starts with (E, NE, N, NW, W, SW, S, SE) is preceded by "#", it will be seen as (0, 45, 90, 135,180, 225, 270, 315) degrees respectively, even if it was not intended to be a literal (this is an advertised compiler feature). So, the variable ?#NeverOnTuesday? will be seen as #NE and 45? will be used, not "NeverOnTuesday?s" stored value. The name ?OnlyOnTuesday? can be used as a variable when NoAngleVar is in effect since the compiler can?t force ?OnlyOnTuesday? to a compass point, but ?#OnlyOnTuesday? may generate a compiler error with some commands since it cannot be interpreted, or misinterpreted as it were, as a literal.

On the other hand, AngleVar tells the compiler to act like most compilers do and treat variable names as, well, ? variables. The use of "#" in this mode is used to indicate that polar data is being specified, as shown in the example above.

In earlier versions of the program "#" was accepted wherever angle data was required. Now, there are some exceptions. When in doubt, put it in, and if the compiler kicks an error, take it out. Not very scientific, but compiling is quick and the compiler knows what it likes.



Scripting since MC+2.0

[ 07-30-2004, 03:06 AM: Message edited by: MullinRJ ]

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.

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