import tool for Scripter Studio
凡是脚本中使用的类,控件,方法,函数都要先行注册以后,脚本才能识别这些对象。
本人使用的是scripter studio pro 1.2,发现官方只提供了DELPHI本身所提供的控件的脚本支持文件。那么脚本中需要使用第三方的控件怎么办?幸好TMS提供了方便的专用工具:import tool for Scripter Studio,在TMS的官方网站提供下载。
The import tool for Scripter Studio parses Delphi source code files (.Pas) and generate a new .pas import file that register all (with some restrictions) classes, procedures, functions, variables and constants present in the parsed file.
根据DELPHI原文件生成一个新的目标文件,目标文件里面注册了原文件的类,方法。
import tool for Scripter Studio的使用方法:
- Open import tool
- Select menu option “File | New project” (Ctrl + N). Import tool will open project options dialog
- In project options dialog, select the Delphi version you are using (marked as “Import files must be compatible with”), and click the button “reset directories to match Delphi version selected above”. Close project dialog.
- Select tab “Delphi files to parse”, and choose the files to be parsed. Use “Pick file” button to add a single file or “Pick dir” button to add a full directory. Always use “Add” button to add the selected file/directory to the list. You can add to the list as many files/directories you want.
- Select menu option “Project | Parse Delphi files “ (Ctrl+F9) to parse files. This might take some minutes.
- After files are parsed, the tab “Import files to generated” is automatically displayed with a list of parsed files. Select menu option “Project | Generate import files” (F9) to generate import files.
扩展名为SPU文件的说明:
After parsing a .PAS file, import tool creates a SPU file with all information found in the parsed file. The SPU file is created in order to avoid a reparse of the file, which might be slow. Once a file is parsed and the SPU file is generated, import tool only needs the SPU file to generate the import file. Thus, SPU files are generated from a .pas file parse, but import files are generated directly from SPU files.
spu文件是经过解析而生成的文件,避免重复解析原代码文件。
To generate a import file, import tool parses a file, then parses the units used by that file, and so on, until the top-most files, like Windows, System and SysUtils. Thus, in order to have the import file generated correctly, import tool needs to find all .PAS files used by the parsed unit, and the files used by those files, and so on. If import tool does not find the PAS file, it can use the SPU file that corresponds to the PAS file.
已经解析过的,可以直接使用SPU文件来生成目标文件。
常见问题:
Q: Does import tool import *everything* declared in a unit?
A: No. Import tool does not support some types, like pointers, interfaces, class of, and so on. In the restrictions tab, after choosing a unit, you can see items marked as “not supported”.
不支持一些类型,像指针,接口,类的类。
Q: After parsing files I receive the message “Some files were not parsed”. What to do?
A: Import tool cannot parse 100% of Delphi source code files. If there are some files not parsed, you should check at what line and column the error occurred (in the “Import files to generate” tab), and try to change source code to be correctly parsed. Otherwise the file will not be imported.
不能百分百地解析DELPHI原代码文件。
Q: When compiling generated import file I receive the error “Incompatible types: Variant and XXXXX”. What do do?
A: Some generated files may raise compile errors. First, check if you informed search path correctly in project options, so that import tool can find ALL Pas files and/or SPU files needed. If it does not work, then restrict the item that raises the error in the Restrictions tab, so that the next time you generate the import file the item will be not included in the pas files and not raise the compile error.
Q: I added DBTables library, but cannot use TDatabase.Open method, TTable.FieldByName, or even TQuery.Create. What happened?
A: Import tool imports only the methods and properties declared in the unit. It cannot import something that is declared in ancestor. For example, in this case, Open and FieldByName methods are declared in DB unit (TCustomConnection.Open and TDatase.FieldByName), and Create method is declared in Classes (TComponent.Create). Thus, to use those methods you also need to add libraries DB and Classes.
Q: Where import-all file is generated?
A: It is generated in output directory defined in project options. Its name is ap_ImportPROJECTNAME, where PROJECTNAME is the name of your project file (without .sip extension)
本文来自博客园,作者:{咏南中间件},转载请注明原文链接:https://www.cnblogs.com/hnxxcxg/archive/2010/05/17/2940945.html