没有找到合适的产品?
联系客服协助选型:023-68661681
提供3000多款全球软件/控件产品
针对软件研发的各个阶段提供专业培训与技术咨询
根据客户需求提供定制化的软件开发服务
全球知名设计软件,显著提升设计质量
打造以经营为中心,实现生产过程透明化管理
帮助企业合理产能分配,提高资源利用率
快速打造数字化生产线,实现全流程追溯
生产过程精准追溯,满足企业合规要求
以六西格玛为理论基础,实现产品质量全数字化管理
通过大屏电子看板,实现车间透明化管理
对设备进行全生命周期管理,提高设备综合利用率
实现设备数据的实时采集与监控
利用数字化技术提升油气勘探的效率和成功率
钻井计划优化、实时监控和风险评估
提供业务洞察与决策支持实现数据驱动决策
翻译|使用教程|编辑:杨鹏连|2021-01-28 10:31:19.293|阅读 336 次
概述:本教程将向您展示如何通过嵌入JavaScript引擎,启用UltraEdit / UEStudio中的脚本。
# 界面/图表报表/文档/IDE等千款热门软控件火热销售中 >>
相关链接:
UltraEdit是一款功能强大基于磁盘的文本编辑器、程序员的编辑器和十六进制编辑器。可以用于编辑HTML、PHP、javascript、Perl、C/C++、Python以及其他任何的编码/编程语言。
UltraEdit产品的UltraEdit subscription版本授权原价¥800元,现在优惠¥653元,点击查看授权方式和其他版本优惠>>>
通过嵌入JavaScript引擎,可以启用UltraEdit / UEStudio中的脚本。这使用户可以在使用UltraEdit / UEStudio应用程序对象命令与编辑器或在编辑器中打开的文档(文档对象命令)交互时享受JavaScript语言的强大功能和灵活性。
脚本引擎支持JavaScript 1.7的核心功能。有关JavaScript 1.7的更多信息,请参见相关的Mozilla网站。
使用集成脚本引擎
步骤1:建立指令码
使用UltraEdit / UEStudio创建(JavaScript)脚本。如上所述,您可以使用JavaScript 1.7以及UltraEdit / UEStudio应用程序对象命令和文档对象命令。
帮助中有大量有关可用命令的信息,但是下面有一些示例脚本。
步骤2:添加脚本
创建(并保存)脚本后,您需要将其添加到“脚本:脚本”对话框中。
完成后,可以单击确定。
步骤3:执行脚本
要执行脚本,请转到“脚本”菜单。您将在“脚本”菜单的底部看到脚本名称。单击脚本名称以执行它。如果已定义它们,也可以使用热键/和弦。
// Hello World Example Script
function hello() {
UltraEdit.activeDocument.write("Hello World!")
}
hello();
示例脚本-检索字符串用户输入
脚本支持使您可以提示用户输入String或Integer数据,在变量中捕获该数据,然后相应地使用该变量。用于检索数据的方法是“ UltraEdit.getValue”和“ UltraEdit.getString”。
提示输入字符串
要提示输入字符串,请使用“ UltraEdit.getString”命令。提示输入和将输入捕获为变量的示例如下:
var str = UltraEdit.getString("Please Enter a String:",1);
捕获输入:
为了捕获数据,而不是立即将其写入文档,必须在getString方法中使用“ 1 ”参数。
写入输入:
如果要立即将用户输入写入文件,请使用“ 0 ”作为参数值。
样本捕获字符串输入脚本
下面的示例提示用户输入字符串,并将其捕获到变量“ str”中。然后它将在活动文档中写入“您输入了用户输入(str) ”。根据输入的是“ UltraEdit”还是“ UEStudio”,它将写入不同的响应。
如果愿意,您可以复制以下脚本并对其进行扩展。
function strInput() {
//Get user input
var str = UltraEdit.getString("Please Enter a String:",1);
//Output what was entered
UltraEdit.activeDocument.write("You Entered " + str + "\r\n");
//Conditional responses
if (str == "UltraEdit") {
UltraEdit.activeDocument.write(str + " has an integrated scripting engine.\r\n");
UltraEdit.activeDocument.write(str + " is a very powerful editor.\r\n");
UltraEdit.activeDocument.write("\r\n");
} else if (str == "UEStudio") {
UltraEdit.activeDocument.write(str + " also has integrated scripting\r\n");
UltraEdit.activeDocument.write(str + " includes all the functionality of UltraEdit and more.\r\n");
UltraEdit.activeDocument.write("\r\n");
} else {
UltraEdit.activeDocument.write("Sorry, there is no defined output for " + str + "\r\n");
UltraEdit.activeDocument.write("\r\n");
}
} //end strInput
strInput();
注意:用于写入活动文档的命令是“ UltraEdit.activeDocument.write”
输入“数据”,“ UltraEdit ”和“ UEStudio ”后的结果如下:
示例脚本-检索整数用户输入
脚本支持使您可以提示用户输入String或Integer数据,在变量中捕获该数据,然后相应地使用该变量。用于检索数据的方法是“ UltraEdit.getValue”和“ UltraEdit.getString”。提示输入整数
要提示输入整数,请使用“ UltraEdit.getValue”命令。提示输入整数输入并将输入捕获为变量的示例如下:
var num = UltraEdit.getValue("Please enter an integer",1);
捕获输入:
为了捕获数据,而不是立即将其写入文档,必须在getValue方法中使用“ 1 ”参数。
写入输入:
如果要立即将用户输入写入文件,请使用“ 0 ”作为参数值。
样本捕获整数输入脚本
下面的示例提示用户输入一个整数值,并将其捕获到变量“ num”中。它将在活动文档中写入“您输入了用户输入(str) ”。然后它将进入一个循环,在该循环中将写入“ i”行数,并为每行编号。
如果愿意,您可以复制以下脚本并对其进行扩展。
function intInput() {
//Get user input
var num = UltraEdit.getValue("How Many Lines:",1);
//Output what was entered
UltraEdit.activeDocument.write("You Entered " + num + "\r\n\r\n");
//Loop
var i = 1;
while (i <= num) {
UltraEdit.activeDocument.write(i + " \r\n");
i = ++i;
}
} //end strInput
intInput();
注意:用于写入活动文档的命令是“ UltraEdit.activeDocument.write”
示例脚本-枚举所有打开的文件
使用文档对象命令,您可以访问/引用编辑器中当前打开的文件。如果要对所有打开的文件执行操作/运行脚本,则需要检索打开的文件数,然后循环浏览每个文件。
例如,如果您需要找出在编辑器中打开了多少文件,则可以使用以下命令:
var num_of_docs = UltraEdit.document.length;
如果需要基于打开的文件引用特定文件,则可以使用UltraEdit.document [x]进行引用。其中x是文档编号。
示例通过所有打开的文件枚举
下面的脚本将枚举每个打开的文件,并将简单的标头写入每个文件。
如果愿意,您可以复制以下脚本并对其进行扩展。
// Hello welcome to the UltraEdit scripting environment. Normally you would
// put a header comment at the top of a javascript file to be used in UltraEdit
// in order to indicate the version of the UltraEdit scripting API like so:
// Version = 1.00
// However, this is currently not necessary since the API will default to 1.00.
// ----------------------------------------------------------------------------
// header.js
// This script creates a header for all open documents
// ----------------------------------------------------------------------------
// UltraEdit is our application object. All UltraEdit operations will use this
// object.
// Get the num of open documents.
var num_of_docs = UltraEdit.document.length;
var dashes = "// ------------------------------------------------------------";
dashes += "----------------\r\n";
// Enumerate through all open documents and add the header.
var index;
for (index = 0; index < num_of_docs; index++) {
UltraEdit.document[index].top();
UltraEdit.document[index].write(dashes);
UltraEdit.document[index].write("// Script Name: \r\n");
UltraEdit.document[index].write("// Creation Date: \r\n");
UltraEdit.document[index].write("// Last Modified: \r\n");
UltraEdit.document[index].write("// Copyright (c)20XX\r\n");
UltraEdit.document[index].write("// Purpose: \r\n");
UltraEdit.document[index].write(dashes);
} //end for loop
运行上述脚本后,每个打开的文件现在都具有以下标头:
想要购买UltraEdit 正版授权,或了解更多产品信息请点击
本站文章除注明转载外,均为本站原创或翻译。欢迎任何形式的转载,但请务必注明出处、不得修改原文相关链接,如果存在内容上的异议请邮件反馈至chenjj@ke049m.cn
文章转载自:



注意: Cogent DataHub 软件 v11 包含一些新功能,您的目标操作系统可能不支持这些功能。
本教程主要为大家介绍如何使用DevExpress WinForms数据网格控件进行数据排序的基础知识,欢迎下载最新版组件体验!
在使用Parasoft C/C++test执行BugDetective数据流分析时,可能会遇到用户自定义的资源API,那在这种情况下,若要判断是否存在资源问题,如资源泄露等,则需要手动配置测试配置。
大型SaaS系统的自动化测试常常受制于界面变化快、结构复杂、加载机制多变等因素。从元素识别到脚本管理,SmartBear TestComplete帮助Salesforce建了可靠的自动化测试体系。
服务电话
重庆/ 023-68661681
华东/ 13452821722
华南/ 18100878085
华北/ 17347785263
客户支持
技术支持咨询服务
服务热线:400-700-1020
邮箱:sales@ke049m.cn
关注我们
地址 : 重庆市九龙坡区火炬大道69号6幢
半岛外围网上直营