Jump to content

The VectorScript Advisor: What do I do with a VectorScript, anyway?


Recommended Posts

A good article, Robert!

Those who intend (or fear being compelled) to do even slightly complex scripts would be well advised to adopt a structured way of programming from the outset.

This includes also standardisation of common variable, constant and subroutine names.

With this approach, one can easily redeploy functions and procedures, ie. copy and paste them (or even establish 7 or 8 large libraries used via $INCLUDE).

Like this:

PROCEDURE My_Script_Name_123;

{ declarations }

CONST

VAR

PROCEDURE abc;

BEGIN

{ code }

END;

PROCEDURE bcd;

BEGIN

{ code }

END;

BEGIN ( main }

{ code }

abc; { call to subroutine }

{code }

bcd; { call to subroutine }

{ code }

END;

RUN(My_Script_Name_123);

VS is based on Pascal, so textbooks on Pascal can be useful. The good doctor Wirth developed Pascal to encourage structured programming. http://en.wikipedia.org/wiki/Pascal_(programming_language)

Link to comment

This seems like a good place to post a valuable bit of advice I got from a programmer friend when I was starting. It's a good idea to give your variables,constants and procedures clearly descriptive names.

When I started I had the false notion that shorter names would somehow be more efficient, possibly because it means less typing. A few extra keystrokes are pretty insignificant to writing and running the script, but can make it far easier to understand and maintain.

Example: I'm currently re-working something I wrote years ago. I'm looking at things like 'wrknit' and scratching my head. What is that? What does it do? Two more keystrokes and I would've had 'WorkUnit' and that section would read like a book.

Another comment for beginners: It may not be obvious what the characters { } do in Petri's example above (and elsewhere). These make the words enclosed by them invisible to the vectorscript compiler. Without them all kinds of errors would be generated. Some of us use them to add 'comments' into the script to help make it clear what the different lines and sections are supposed to be doing.

They are also used to "comment out" sections or lines of code that seem to be behaving badly, or producing un-intended behavior. Then you can see what happens if that stuff is gone. It's one of the basic tools of de-bugging and script development, along with "messaging out".

And what is messaging out? In re-working my script I may want to verify that WorkUnit is carrying the data it should after it goes thru some math in the script. If I place Message(WorkUnit) at the appropriate spot or spots, a message will appear on screen displaying that value. After I'm satisfied I delete that bit.

Later

Charles Croft

  • Like 2
Link to comment
  • 6 years later...
  • Vectorworks, Inc Employee

It would still apply, yes, Python was added as another language supported for scripting rather than a replacement for Vectorscript.

I have not heard of plans to remove the original language at all. However as far as which language to start with from scratch, most likely the newer language would make the most sense.

Link to comment
  • 1 year later...

Now that Marionette is going to be introduced so that it is easier for the non-programmers to create scripts does this still apply?

The reason I am asking is that Vectorscript is fully controlled by Vectorworks while Python probably is not so it seems that if functions are dropped by the community in Python the chance for compatibility issues in the future is bigger than with Vectorscript.

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