Beanshell翻译11

本文档详细介绍了BeanShell的使用方法,包括如何定义变量、设置命令提示、使用内置命令等。同时还提供了如何自定义命令及命令的概述,解释器的不同模式等内容。

1.Undefined Variables 没有定义的变量
You can test to see if a variable is defined using the special value void. For example:
你可以看一下,当一个变量用特殊的值void来进行定义的时候,例如:
if ( foobar == void )
// undefined 没有定义
You can return a variable to the undefined state using the unset() command:
你可以使用unset()命令,返回一个没有定义状态的变量。
a == void; // true
a=5;
unset("a"); // note the quotes 注意这个引用
a == void; // true
Setting the Command Prompt 设置命令提示
Users may set the command line prompt string for use in interactive mode
by setting the value of the variable bsh.prompt or
by defining the scrīpted method (or command) getBshPrompt().
用户可以通过设置命令行prompt字符串,
设置变量bsh.prompt的值或者是通过定义脚本函数getBshPrompt()
来在交互模式下使用。
If the command or method getBshPrompt() is defined
it will be called to get a string to display as the user prompt.
For example, one could define the following method
to place the current working directory into their command prompt:
如果命令或者函数getBshPrompt()被定义,它将被调用,取得一个用于提示用户的字符串。
例如,一个人可以定义下面的函数,将当前的工作路径进入它的命令提示。
getBshPrompt() { return bsh.cwd + " % "; }
The default getBshPrompt() command returns the value of the variable bsh.prompt
if it is defined or the string "bsh % " if not.
If the getBshPrompt() method or command does not exist, throws an exception,
or does not return a String, a default prompt of "bsh % " will be used.
默认的getBshPrompt()命令返回变量bsh.prompt的值,条件是如果它被定义了或者
字符串"bsh % "没有定义。
如果getBshPrompt()函数或者命令不存在,抛出一个异常,
或者没有返回一个字符串,一个默认的"bsh % "的提示将被使用。
BeanShell Commands Beanshell命令
BeanShell commands appear to the user as pre.defined methods such as print(), load(), or save().
BeanShell Commands can be implemented as scrīpted methods or compiled Java classes
which are dynamically loaded on demand from the classpath.
We'll talk about adding your own commands in the next section "Adding BeanShell Commands".
Beanshell命令对用户来说就是一些提前定义的函数例如print(),load(),或者save().
Beanshell命令可以使用脚本函数或者编译好的Java类来实现,其中
Java类是可以按要求从类路径中动态加载的。
我们将在下一章"Adding BeanShell Commands"中谈谈添加你自己的命令。
Tip: 提示:
You can easily override any BeanShell command simply
by defining the method yourself in your scrīpt. For example:
通过在脚本中定义你自己的函数,你可以很容易的重写Beanshell命令。例如:
print( arg ) {
System.out.println( "You printed: " + arg );
}
If you define the method in the global scope it will apply everywhere.
If you define it local to a scrīpted object it will only apply in that object context.
如果你定义函数在全局的作用域中,它将在任何地方应用。
如果你在一个脚本对象中定义它为本地的,它将只能在对象环境中应用。
2.Commands Overview 命令的总的看法
This is a high level overview of the BeanShell command set.
You can find full documentation for all BeanShell commands
in the "BeanShell Commands Documentation" section of this manual.
See also the "BshDoc" section
which covers javadoc style documentation of BeanShell scrīpt files.
这里是Beanshell的命令设置的高度概括。
你可以找到关于Beanshell命令的完整文档,在"Beanshell Commands Documentation"章节中。
也可以"BshDoc"章节,这个章节讲解了Beanshell脚本文件的javadoc样式的文档。
3.Interpreter Modes 解释器模式
The following commands affect general modes of operation of the interpreter.
下面的命令影响解释器操作的常用模式。
exit() Exit the interpreter. (Also Control.D).
退出解释器
show()
Turn on "show" mode
which prints the result of every evaluation that is not of void type.
show() 打开"show"模式,这个模式是用来打印每个计算的结果的。
setAccessibility()
Turn on access to private and protected members of Java classes.
setAccessibility() 打开Java类的私有和受保护变量的存取。
server()
Launch the remote access mode,
allowing remote access to the interpreter from a web browser or telnet client.
server() 打开远程存取模式,允许从一个web浏览器或者是远程登录客户端,对解释器进行远程存取。
debug()
Turns on debug mode. Note: this is very verbose, unstructured output and is primarily of
interest to developers.
debug() 打开调试模式。注意:这里是非常详细的,非结构化的输出,并且最初对开发者来说是很有趣的。
setStrictJava()
Turn on "strict Java" mode
which enforces Java compatibility by dissallowing loose types and undeclared variables.
setStrictJava() 打开"strict Java"模式,
这个模式,这个模式可以强迫Java不接受松散类型和未定义的变量。
Output 输出
The following commands are used for output:
下面的命令是用来做输出的:
print(), error() Print output to standard out or standard error.
print(), error()打印输出到标准输出或者标准错误。
print() always goes to the console,
whereas System.out may or may not be captured by a GUI console or servlet.
print()也可以去控制台,
然而System.out可以被一个GUI控制台或者servlet捕捉,也可以不这样。
frame() Display the AWT or Swing component in a Frame
frame()在一个Frame中显示AWT或者Swing组件
4.Source and Evaluation 源和计算表达式
The following commands are used for evaluation or to run external scrīpts or applications:
下面的命令是用来计算表达式或者运行第三方的脚本或者应用程序:
eval() Evaluate a string as if it were typed in the current scope.
eval() 计算一个字符串,当它定义在当前的作用域中。
source(), sourceRelative()
Read an external scrīpt file into the interpreter and evaluate it in the current scope
读取一个第三方的脚本文件进入解释器并且在当前的作用域中计算它。
run(), bg()
Run an external file in a subordinate interpreter or
in a background thread in a subordinate interpreter.
在一个从属的解释器中,运行一个第三方的文件。
exec()
Run a native executable in the host OS
在主机OS中,运行一个本地的可以执行的脚本。
Utilities 有效性
The following commands are useful utilities:
下面的命令是很有效的:
javap() Print the methods and fields of an object, similar to the output of javap
javap() 打印一个对象的方法和属性,和javap的输出类似。
which()
Like the Unix 'which' command for executables.
Map the classpath and determine the location of the specified class.
就像Unix中的'which'命令一样。
绘制类路径,并且决定特殊类的位置。
load(), save()
load a serializable object from a file or save one to a file.
Special handling is provided for certain objects.
从一个文件中,加载一个序列化的对象,或者将它存到文件中。
特殊处理是提供确定的对象。
object() Create an "empty" object context to hold variables; analogous to a Map.
创建一个空对象环境,用来保存变量;类似于一个Map.
5.Variables and Scope 变量和作用域
The following commands affect the current scope: 下面的命令影响当前的作用域:
clear() Clear all variables, methods and imports from the current scope.
clear() 清理所有的变量,方法和从当前作用域中导入的东西。
unset() Remove a variable from the current scope. (Return it to the "undefined" state).
unset() 从一个当前的作用域中移除一个变量。(将它返回个"undefined"状态)。
setNameSpace()
Set the current namespace to a specified scope.
Effectively bind the current scope to a new parent scope.
设置当前名字空间为一个特殊的作用域。
有效的将当前的作用域绑定到一个新的父亲作用域上面。
6.Classpath 类路径
The following commands manipulate or access the classpath:
下面的命令巧妙的操作来存取类路径:
addClassPath(), setClassPath(), getClassPath() Modify the BeanShell classpath.
修改Beanshell类路径。
reloadClasses() Reload a class or group of classes.
重新加载一个类或者一群类。
getClass()
Load a class explicitly taking into account the BeanShell classpath.
从Beanshell类路径下面明确的加载一个类。
getResource() Get a resource from the classpath.
从类路径中取得一个源。
代码下载地址: https://pan.quark.cn/s/bcac7912890d 在本文中,我们将详细研究如何将Windows 10操作系统调整为类似苹果的主题风格,并分析这一过程可能涉及的关键技术要素。Windows 10用户有时期望通过改变系统界面来获得与苹果Mac OS相近的体验,这通常涉及到图标、窗口布局、任务栏等方面的调整。"windows10美化变仿苹果主题"是一个此类解决方案,它致力于提供一种简便高效的方法,让用户能够在不降低系统性能的情况下,使Windows 10的外观更接近苹果的操作系统。 我们需要熟悉这个美化工具的关键部分——"安装程序Dock.exe"。Dock是苹果Mac OS中的一个显著功能,它是一个可定制的快捷方式条,用于迅速访问常用的应用程序和文件。在Windows 10中,实现仿苹果主题通常包括一个类似的功能,模拟Mac的Dock效果,使用户能够便捷地启动和切换应用程序。这个Dock程序很可能包含了模仿Mac样式的任务栏和启动器的界面组件。 在描述中提及的"一键启动,完美仿苹果",表明这个美化工具应该是用户友好的,只需执行一个简单的步骤,就能完成整个系统的转换。这样的设计对于那些不熟悉复杂系统设置调整的用户来说非常便利。同时,"支持:windows7/windows10"显示这个工具不仅适用于Windows 10,还适用于较早版本的Windows 7,拓宽了它的适用范围。 值得关注的是,该工具被强调为"不会占用很多资源",在个人电脑测试中,仅消耗3%的内存资源。这在一定程度上确保了系统性能不会因为美化而受到明显影响。在进行系统美化时,保证软件的轻量化和资源使用效率是至关重要的,因为过多的后台进程可能会减慢系统运行速度。 在达...
源码链接: https://pan.quark.cn/s/a4b39357ea24 ### MG996R舵机控制详细说明 #### 一、MG996R舵机概述 MG996R舵机是一种在机器人、无人机、模型飞机等多个领域得到普遍应用的伺服电机。该舵机能够依据输入的脉冲宽度调制(PWM)信号进行精准的角度定位。由于具备操作简便、运行高效、成本较低等优势,这种舵机在各种机电控制系统中被频繁采用。 #### 二、MG996R舵机的工作机制 MG996R舵机内部配备了一个精密的反馈系统,确保其输出的角度具有高度的精确性。其主要运作过程如下: 1. **控制信号调节**:控制信号由接收机的通道传输至信号调制芯片,该信号通常表现为周期性变化的PWM信号。信号调制芯片会提取出这一信号中的直流偏置电压。 2. **基准信号的产生**:舵机内部设有基准电路,用于生成一个周期为20ms、宽度为1.5ms的基准信号。 3. **电压对比**:所获取的直流偏置电压与电位器的电压进行对比,从而得出电压差。 4. **电机驱动**:电压差的正负决定了电机的旋转方向。电机通过一系列的齿轮减速装置驱动电位器旋转,使电压差趋近于零,此时电机停止转动。 #### 三、舵机控制信号详述 舵机的控制信号通常采用PWM信号,通过调节信号的占空比来控制舵机的位置。一般情况下,对舵机的控制要求如下: - **周期**:通常设置为20ms。 - **脉冲宽度**:依据所需控制的角度而变动,通常范围为1ms至2ms之间。 - **最小脉冲宽度**:1ms对应舵机的最左侧位置。 - **最大脉冲宽度**:2ms对应舵机的最右侧位置。 - **中间位置**:1.5ms对应的脉冲宽度代表舵机的中心位置。 #### 四...
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值