VBScript Statements Supported in Altium Designer

Now reading version 18.1. For the latest, read: VBScript Statements Supported in Altium Designer for version 25

Conditional Statements

The main conditional statements supported by VBScript are:

  • If...Then
  • For Next Loop
  • Exit For
  • For Each Next
  • Do Loop
  • While...WEnd
  • Select Case

Care needs to be taken to code scripts that avoid infinite loops — that is, ensuring that the conditions will eventually be met.

The If...Then Statement

The syntax is:

If Condition Then
  'code
Else If AnotherCondition Then
  'code
Else
  'code
End If

The For Loop

The For Next statement repeatedly loops through a block of code. The basic syntax is:

For counter = start to end
  ' block of code here
Next

The Exit For

The Exit For statement exits a For loop prematurely.

For counter = start to end
  if condition then Exit For
Next

The For Each Loop

The For Each loop is a variation on the For loop which is designed to iterate through a collection of objects as well as elements in an array. The basic syntax is:

For Each ObjectVar in Collection
  ' block of code here
Next

The Do Loop

The Do Loop has several loop variations.

Do while until condition
  ' code block
Loop

...and;

Do
  ' code block
Loop while until condition

...and;

Do
  ' code block
Loop

The While...WEnd Loop

The While WEnd statement repeatedly loops through a block of code. The basic syntax is:

While until condition
  ' code block
WEnd

The Select Case Statement

You can use the SELECT statement if you want to select one of many blocks of code to execute:

Select case payment
  case "Cash"
    msgbox "pay cash"
  case "MasterCard"
    msgbox "pay by Mastercard"
  case Else
    msgbox "Unknown payment method"
end select

Expressions and Operators

An expression is a valid combination of constants, variables, literal values, operators, and function results. Expressions are used to determine the value to assign to a variable, to compute the parameter of a function, or to test for a condition. Expressions can include function calls.

VBScript has a number of logical, arithmetic, Boolean and relational operators. Since these operators are grouped by the order of precedence which is different from the precedence orders used by Basic, C, etc. For example, the AND and OR operators have precedence compared to the relational one.

Arithmetic Operators

+

Addition

-

Subtraction

*

Multiplication

/

Division

\

Division with an integer result

^

Exponentiation

Mod

Modulo

Comparison Operators (Lowest Precedence)

=

Test whether equal or not.

<>

Test whether not equal or not.

<

Test whether less than or not.

>

Test whether greater than or not.

<=

Test whether less than or equal to or not.

>=

Test whether greater than or equal to or not.

Is

Compares two object reference variables.

String Operators

&

Concatenation

Logical Operators

Not

Logical NOT

And

Logical AND

Or

Logical OR

XOR

 

Eqv

 

Imp

 

&

 

If you find an issue, select the text/image and pressCtrl + Enterto send us your feedback.
참고

Altium 제품에 접근할 수 있는 레벨에 따라 사용할 수 있는 기능이 달라집니다. 다양한 레벨의 Altium Designer Software Subscription에 포함된 기능과 Altium 365 플랫폼에서 제공하는 애플리케이션을 통해 제공되는 기능을 비교해보세요.

소프트웨어에서 논의된 기능을 찾을 수 없는 경우, Altium 영업팀에 문의하여 자세한 정보를 확인해주세요.

콘텐츠