TR0120 Delphi Script Reference

更新时间:2023-05-16 03:41:07 阅读: 评论:0

DelphiScript Reference
Summary
Technical Reference
TR0120 (v1.7) July 14, 2008 This reference manual describes the DelphiScript language ud by the Scripting Engine in Altium Designer.
This reference includes the following topics:
•Exploring the DelphiScript Language
•DelphiScript Source files
•Writing DelphiScript Scripts
•Differences between DelphiScript and Object Pascal
•Using Altium Designer Run Time Library
•DelphiScript Keywords
•Expressions and Operators
•DelphiScript Functions
•Working with Script Forms and Components加纳国家队
粉底怎么用
•DelphiScript Error Codes
Exploring the DelphiScript Language
This DelphiScript reference details each of the statements, functions and extensions that are supported. The are special procedures that are ud to control and communicate directly with Altium Designer. It is assumed that you are familiar with basic programming concepts as well as the basic operation of Altium Designer.
The scripting system supports the DelphiScript language which is very similar to Borland Delphi (TM).
The key difference is that DelphiScript is a typeless or untyped scripting language which means you cannot define records or class and pass pointers as parameters to functions. You can still declare variables within scripts for readability.
This document and the DelphiScript Keyword Reference document contain reference material on interfaces, components, global routines, types, and variables that make up the DelphiScript scripting language.
Objects
An object consists of methods, and in many cas, properties, and events. Properties reprent the data contained in the object. Methods are the actions the object can perform. Events are conditions the object can react to. All objects descend from the top level object of TObject type.
谦虚的句子
Object Interfaces
An object interface consists of methods, and in many cas, properties but cannot have data fields. An interface reprents an existing object and each interface has a GUID which marks it unique. Properties reprent the data contained in the object that the interface is associated with. Methods are the actions the object (in which the interface is associated with) can perform.
Components
Components are visual objects that you can manipulate at design time from the Tool Palette panel. All components descend from the TComponent class in the Borland Delphi Visual Component Library.
Routines
Global routines are the procedures and functions from the scripting system. The routines are not part of a class, but can be called either directly or from within class methods on your scripts.
Delphi Script Reference
Types
The variable types are ud as return types and parameter types for interface methods and properties, object's methods, properties and events and for global routines. In many cas, types are documented in the Enumerated Types ctions in all API documents.
For example, the Client Enumerated Types for the DXP Object Model is detailed in the System Reference document
Altium Designer and Borland Delphi Run Time Libraries
The Scripting system also supports a subt of Borland Delphi Run Time Library (RTL) and a subt of Altium Designer RTL which is covered in the Altium Designer RTL Guide.
You can navigate to the various Altium Designer API documents via Configuring the System » Scripting in Altium
Designer » Altium Designer RTL Reference from the Knowledge Center panel.
DelphiScript Source files
A script project is organized to store script documents (script units and script forms). You can execute the script from a menu item, toolbar button or from the Run Script dialog from the Altium Designer’s system menu.
PRJSCR, PAS and DFM files
Scripts are organized into projects with a *.PRJSCR extension. Each project consists of files with a *.pas extension. Files can be either script units or script forms (each form has a script file with *.pas extension and a corresponding form with a *.dfm extension). A script form is a graphical window that hosts different controls that run on top of Altium Designer.
It is possible to attach scripts to different projects and it is highly recommended to organize scripts into different projects to manage the number of scripts and their procedures / functions.
About Example Scripts
The following examples illustrate the basic features of DelphiScript programming using simple scripts for u in Altium Designer. Example scripts can be found in the Examples folder under your Altium Designer installation.  The location and purpo of some of the example scripts are mentioned below:
•Examples\Scripts\DelphiScript Scripts\DXP sub folder - Demonstrate Client and system API
•Examples\Scripts\DelphiScript Scripts\PCB subfolder - Demonstrate PCB API
三年级征文怎么写
•Examples\Scripts\DelphiScript Scripts\Process sub folder - Demonstrate rver process
高二数学试卷
•Examples\Scripts\DelphiScript Scripts\General sub folder- Demonstrate DelphiScript keywords
•Examples\Scripts\DelphiScript Scripts\Sch subfolder - Demonstrate Schematic API
•Examples\Scripts\DelphiScript Scripts\WSM subfolder - Demonstrate Workspace Manager API
DelphiScript Reference
Writing DelphiScript Scripts
DelphiScript Naming Conventions
In general, there are no restrictions to the names you can give to procedures, functions, variables and constants as long as they adhere to the following rules:
•The name can contain the letters A to Z, a to z, the underscore character "_" and the digits 0 to 9
•The name must begin with a letter
•The name cannot be a DelphiScript keyword, directives or rerved word
•Names are ca innsitive when interpreted. You may u both upper and lower ca when naming a function, subroutine, variable or constant, however the interpreter will not distinguish between upper and lower ca characters. Names which are identical except for ca will be treated as the same name in DelphiScript.
In a DelphiScript file, the functions and procedures are declared using the Procedure Begin End or Function Begin End blocks.  Both of the statement blocks require a name to be given to the procedure or function. DelphiScript allows you to create named variables and constants to hold values ud in the current script.
Including Comments in scripts
In a script, comments are non-executable lines of code which are included for the benefit of the programmer. Comments can be included virtually anywhere in a script. Any text following // or enclod with (* *) or {} are ignored by DelphiScript.
// Comment type example
//This whole line is a comment
{} Comment type example
{This whole line is a comment}
(* *) comment type example
(*
This whole line is a comment
This whole line is a comment
This whole line is a comment
*)
Comments can also be included on the same line as executed code. For example, everything after the mi colon in the following code line is treated as a comment.
ShowMessage (‘Hello World’); //Display Message
Local and Global Variables
Since all scripts have local and global variables, it is very important to have unique variable names in your scripts within a script project. If the variables are defined outside any procedures and functions, they are global and can be accesd by any script unit in the same project.
If variables are defined inside a procedure or function, then the local variables are not accessible outside the
procedures/functions.
Delphi Script Reference
Example of Local and Global Variables in a Script
// The Us keyword is not needed.
// Variables from UnitA script are available to this Script Unit,
// as long UnitA is in the same project as this Unit Script Unit.
Const
GlobalVariableFromThisUnit='Global Variable from this unit';
Procedure TestLocal;
var
Local;
Begin
// we can access a variable from UnitA without the Us keyword
Local := 'Local Variable';
ShowMessage(Local);
End;
Procedure TestGlobal;
矿泉水瓶发豆芽
Begin
/
/ShowMessage(Local); // produces an error.
ShowMessage(GlobalVariableFromThisUnit);
ShowMessage(GlobalVariableFromUnitA);
End;
UnitA script
Const
GlobalVariableFromUnitA = 'Global Variable from Unit A';
Using Named Variables in a Script
In a script, you u named variables or constants to store values to be ud during program execution. All variables in a script are always of Variant type. Typecasting is ignored. Types in variables declaration are ignored and can be skipped, so the declarations are correct:
Var a : integer;
Var b : integer;
Var c, d;
Splitting a Line of Script
Each code statement is terminated with the mi-colon ";" character to indicate the end of the statement. DelphiScript allows you to write a statement on veral lines of code, splitting a long instruction on two or more lines. The only restriction in splitting programming statements on different lines is that a string literal may not span veral lines.
For example:
X.AddPoint( 25, 100);
X.AddPoint( 0, 75);
// is equivalent to:
X.AddPoint( 25, 100); X.AddPoint( 0, 75);
But
‘Hello World!’
is not equivalent to
‘Hello
World!’
DelphiScript Reference
DelphiScript does not put any practical limit on the length of a single line of code in a script, however, for the sake of readability and ea of debugging it is good practice to limit the length of code lines so that they can easily be read on screen or in printed form.
If a line of code is very long, you can break this line into multiple lines and this code will be treated by the DelphiScript interpreter as if it were written on a single line.
Unformatted Code Example
外星人英语
If Not (PcbApi_ChooRectangleByCorners(BoardHandle,'Choo first corner','Choo final
corner',x1,y1,x2,y2)) Then Exit;
Formatted Code Example
If Not (PcbApi_ChooRectangleByCorners(BoardHandle,
'Choo first corner',
'Choo final corner',
x1,y1,x2,y2)) Then Exit;
Ca Sensitivity
The DelphiScript language ud in writing scripts is not ca nsitive, i.e. all keywords, statements, variable names, function and procedure names can be written without regard to using capital or lower ca letters. Both upper and lower ca characters are considered equivalent. For example, the variable name myVar is equivalent to myvar and MYVAR. DelphiScript treats all of the names as the same variable.
The only exception to this is in literal strings, such as the title string of a dialog definition or the value of a string variable, the strings retain ca differences.毛尖属于什么茶
The Space Character
A space is ud to parate keywords in a script statement. However, DelphiScript ignores any additional white spaces in a statement.
For example:
X = 5
is equivalent to
X    =        5
You may u white spaces to make your script more readable.
Functions and Procedures in a Script
The DelphiScript interpreter allows two kinds of procedures: Procedures and Functions. The only diff
erence between a function and a procedure is that a function returns a value.
A script can have at least one procedure which defines the main program code. You can, however, define other procedures and functions that can be called by your code. As with Borland Delphi, procedures and functions are defined within a Begin End statement block. To invoke or call a function or procedure, include the name of the function or procedure in a statement in the same way that you would u the built-in DelphiScript functions and procedures. If the function or procedure requires parameters, then you must include the in the calling statement. Both functions and procedures can be defined to accept parameters, but only functions can be defined to return a value to the calling statement.
You may assign any name to functions and procedures that you define, as long as it conforms to the standard DelphiScript naming conventions.

本文发布于:2023-05-16 03:41:07,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/fan/82/649122.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:豆芽   毛尖   矿泉水瓶   属于
相关文章
留言与评论(共有 0 条评论)
   
验证码:
推荐文章
排行榜
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图