1、Accounting Information,熟悉逐步熟悉PowerScript的基础语法及语句 (Are familiar with the foundation to gradually familiarwith the PowerScript syntax and statement)掌握常见的窗口控件 ( Grasp the common window control ),学习目的与要求 Learning Objectives and Requirements,3-2 编程基础与常用控件技术Programming with the Common Control Technology,教
2、学内容 (Teaching content),3-2 编程基础与常用控件技术 Programming with the Common Control Technology,2.1 对象编程基础 (Object-based programming) 2.2 PowerScript语言 (PowerScript Language ) 2.3 窗口控件 (Window Control ) 2.4 常用函数 (Common Functions ) 2.5 对象菜单 (Object Menu ),3-2.1 对象编程基础object-oriented programming-based,脚本也称为事件处
3、理程序,是指动作发生时相应执行的一段程序The script is also known as the event handler refers to the action occurs, the corresponding period of the implementation of procedures for.,指作用在对象上的动作,当事件触发时,执行脚本。 Event refers to the role of the object movements, when the event is triggered, the implementation of the script.,Ob
4、ject represents a single entity (such as windows, buttons, etc.),3-2.1 对象编程基础object-oriented programming-based,例:按钮对象,教学内容,3-2 编程基础与常用控件技术,2.1 对象编程基础 2.2 PowerScript语言 2.3 窗口控件 2.4 常用函数 2.5 对象菜单,3-2.2 PowerScript语言,注释(/):行注释和块注释,标识符,大小写,命令结束符(回车键),行继续符(&),空值(null),保留字,操作符,算术运算符、关系运算符、逻辑运算符、字符串的连接,保留
5、字供PowerBuilder内部使用,语言基础,3-2.2 PowerScript语言,数据类型、变量和常量Data types, variables and constants,(1)标准数据类型 Standard data types,3-2.2 PowerScript语言,数据类型、变量和常量,(2)变量的声明(Variables Declaration ),变量是指在程序运行过程中其值可以改变的量。(Variable refers to the program is running, the amount of its value can be changed. )变量声明的一般语法结
6、构是: 数据类型 标识符=初值 ,标识符=初值,(The general structure of variable declaration syntax is:Data type identifier = initial value , identifier = initial , . )变量未赋初值,系统会自动赋给变量默认值。如:数值型变量的默认初值是0。(Variable is not assigned the initial value, the system will be automatically assigned to the variable default value. S
7、uch as: numerical variables default initial value is 0. ),3-2.2 PowerScript语言,变量的作用域就是变量使用的范围,变量的作用,全局变量的作用域最大,它在应用程序的任何地方都可以使用。 实例变量是某个特定对象可使用的变量。 共享变量是某类特定对象可使用的变量,并不常用。 局部变量只能在某程序段或函数内部有效,可以在过程、代码、函数内部声明和使用局部变量,3-2.2 PowerScript语言,Variable scope is the scope of the variable used,The role of the v
8、ariable,The largest global variable scope, its application can be used anywhere. A particular object instance variable is a variable that can be used. Shared variable is a particular object of certain variables that can be used is not commonly used. Local variables can only be in a program segment o
9、r function within the force, in the process, the code inside the function declaration and the use of local variables,3-2.2 PowerScript语言,基本语句(Basic Statements ),3-2.2 PowerScript语言,基本语句(Common use of pronouns ),对象事件触发语句 The object event trigger statement,用法:objectname.TriggerEvent ( event , word, lo
10、ng ),关键字Trigger,3-2.2 PowerScript语言,常用代词的使用,(1)This代词 This代词代表窗口、用户对象、菜单、应用对象或控件本身。 (2)Parent代词 Parent代词可以用在窗口控件、用户定制的对象。在窗口控件中使用parent时,parent表示包含该控件的窗口。 (3)ParentWindow代词 ParentWindow代词只能在菜单脚本中使用,它代表运行时菜单所在的窗口,3-2.2 PowerScript语言,Common use of pronouns,(1) This pronoun This pronoun on behalf of th
11、e window, user object, menu, application object or the control itself. (2) Parent pronoun Parent pronoun can be used in the window controls, custom objects. The use of parent control in the window when, parent window that contains the control. (3) ParentWindow pronoun ParentWindow pronoun to use onl
12、y the script in the menu, which represents the window where the run-time menu.,教学内容,3-2 编程基础与常用控件技术,2.1 对象编程基础 2.2 PowerScript语言 2.3 窗口控件 2.4 常用函数 2.5 对象菜单,3-2.3 窗口控件,激活动作的控件:用于激活某个事件,执行一些功能性操作。如CommandButton、PictureButton。,显示数据的控件:用于输入、修改、显示数据等。如DataWindows、SingleLineEdit。,用作选择项的控件:用于从若干信息中选择信息。如Ra
13、dioButton、CheckBox。,仅作修饰的控件:用于修饰窗口,使窗口更清晰、美观。如Line、Rectangle、RoundRectangle、Oval。,从功能角度看,控件分为,3-2.3 窗口控件,Activated action control: used to activate an event, perform some functional operations. Such as CommandButton, PictureButton.,Display data control: used to enter, modify, display data. If DataWi
14、ndows, SingleLineEdit.,Select items for the control: for information from a number of select information. As RadioButton, CheckBox.,Modified only control: used to modify the window, so that the window is more clear, beautiful. Such as Line, Rectangle, RoundRectangle, Oval.,From a functional point of
15、 view, control is divided into,3-2.3 窗口控件,窗口中的控件操作,添加控件,3-2.3 窗口控件,常用控件,命令按钮CommandButton 单选钮RadioButton 复选框CheckBox 单行编辑框SingleLineEdit 多行编辑框MultiLineEdit 掩码编辑框EditMask 标签Tab 列表框ListBox 下拉列表框DropDownListBox 滚动条ScrollBar 进度条ProgressBar,3-2.3 窗口控件,控件的命名,命令按钮cb_ 单选钮rb_ 复选框cb_ 单行编辑框sle_ 多行编辑框mle_ 掩码编辑框
16、em_ 数据窗口控件dw_ 窗口控件w_,控件是构成应用程序界面的重要元素,同时也是显示和输入数据的主要方式。 对控件命名应遵循一定规范,如:,3-2.3 窗口控件,控件的操作 Control the operation of,1、选择控件(select Control ) 2、移动控件(Mobile Controls ) 3、删除控件(delete the control ) 4、改变控件大小(change the size of the control ) 5、控件格式调整(the control format adjustment ) 6、复制、粘贴控件(copy, paste cont
17、rol ),3-2.3 窗口控件,控件的焦点和Tab次序Control the focus and Tab Order,1.运行时用户选择对象。Run-time user to select the object. 2.运行时用户使用快捷键选择对象。Run-time users to use the shortcut key to selectThe object. 3.在代码中使用SetFocus() 函数设置焦点。In the code using the SetFocus () function sets the focus.,3-2.3 窗口控件,定义快捷键,对没有标题的控件,比如单行
18、编辑框、多行编辑框、列表框、下拉列表框等,定义快捷键的方法是:,3-2.3 窗口控件,定义快捷键,Control the absence of title, such as single-line edit boxes, multi-line edit boxes, list boxes, drop-down list box, etc., define shortcut keys method is:,3-2.3 窗口控件,指定控件的可访问性(Specified control accessibility),对大多数控件来说,均可通过下述两个Boolean型属性控制控件的可访问性(For m
19、ost controls, the can be accessed through the following two Boolean-type property controls the accessibility of the control),这两个属性都可以在控件属性对话框“General”标签页的“Visible”和“Enabled”复选框中设置。(These two properties can be in the control Properties dialog box, “General“ tab of the “Visible“ and “Enabled“ check bo
20、x set.),3-2.3 窗口控件,常用窗口控件命令按钮 Commonly used windows controls - a command button,3-2.3 窗口控件,命令按钮的事件,命令按钮有十几个事件,其中最常用、最重要的事件是 事件,它在被单击时触发。Incident command button, command button, there are more than a dozen incidents, one of the most common and most important event of the event, it was triggered when
21、clicked.,Clicked,3-2.3 窗口控件,常用属性:TEXT-静态文本框内显示的信息 Common attributes: TEXT-static text box displays the information,单行编辑框,静态文本框,下拉列表框,它通常用于输入一行文本、键入用户保密字等。 常用事件:modified,getfocus,losefocus It is usually used to enter the line of text, type the security word so the user. Common Event: modified, getfoc
22、us, losefocus,通常用于固定数据的选择 Selection of commonly used fixed data,(textbox),(SingleLineEdit),(DropDownListBox),教学内容,3-2 编程基础与常用控件技术,2.1 对象编程基础 2.2 PowerScript语言 2.3 窗口控件 2.4 常用函数 2.5 对象菜单,3-2.4 常用函数,Timer()函数 功能:在指定的时间 间隔内反复触发指定 窗口的定时器事件 语法: Timer(interval,wi ndowname),3-2.4 常用函数,Timer () function Fun
23、ction: at a specified timeTriggered repeatedly within a specified interval Windows timer event Syntax: Timer (interval (windowname),3-2.4 常用函数,示例(Example),示例1,示例2,示例3,下面的语句每隔3秒触发一次当前 The following statement once every 3 seconds to trigger the current 窗口的Timer事件:Timer(3) Window Timer event: Timer (3)
24、下面的语句停止当前窗口的定时 器:Timer(0) The following statement stops the current timing window Device: Timer (0)下面的语句每隔0.5秒触发一次w_Emp窗口的Timer事件: Open(w_Emp)Timer(0.5, w_Emp) The following statement is triggered once every 0.5 seconds w_Emp window Timer event: Open (w_Emp) Timer (0.5, w_Emp),3-2.4 常用函数,函数语法格式: Ret
25、urnValue = messagebox(title,text,icon,buttons,default),Messagebox( )函数,messagebox( )函数用来向用户显示信 。,3-2.4 常用函数,类型转换函数Type Conversion Functions,类型转换函数用来将一种数据类型转换为另一种数据类型。 Type conversion functions are used to convert a data type to another data type. integer(string):将字符串转换成整型。 integer (string): convert
26、a string into an integer. long(string) :将字符串转换成长整型。 long (string): convert a string to an integer to grow. real(string) :将字符串转换成实型。 real (string): string to convert into a real type. double(string) :将字符串转换成双精度型。 double (string): string to convert to dual precision type. dec(string) :将字符串转换成十进制数(deci
27、mal)。 dec (string): to convert a string into a decimal number (decimal). string(number,format) :将数值按一定格式转换成字符串。 string (number, format): the values according to a certain format, converted to a string.,教学内容,3-2 编程基础与常用控件技术,2.1 对象编程基础 2.2 PowerScript语言 2.3 窗口控件 2.4 常用函数 2.5 对象菜单,3-2.5 菜单,在Windows应用程序
28、中,菜单用于功能选择,通常还把工具栏按钮和菜单命令关联起来 In the Windows application, the menu for the function of choice, usually also toolbar buttons and menu commands associated with them为方便用户操作,使用菜单还可以有多种方法,既可以用鼠标,也可以用键盘,用键盘时可以使用热键和快捷键。 For the convenience of the user operation, use the menu can also be a variety of ways,
29、either with the mouse, you can also use the keyboard, using keyboard hot keys and shortcut keys can be used.状态条一般显示在窗口的底部,向用户提示使用程序的方法以及一些当前的系统状态。 Usually displayed in the status bar at the bottom of the window to prompt the user to use the programs methods and some of the current system state.,3-2.
30、5 菜单,创建菜单,开一个工作空间并指定当前目标,3-2.5 菜单,Create Menu,To open a work space and specify the immediate objective of,3-2.5 菜单,创建菜单,Menu画板的属性窗格有两个标签,它们就是用来设置当前被选中的菜单项的各种属性。 在“General”标签页中,“Name”为菜单项名字,“Text”为菜单项文本,“MicroHelp”为该菜单项显示在窗口底部状态条上的帮助信息。复选框“Visible”表示可见性、“Enabled”为可用性、“Checked”为选中状态。 在“Shortcut”下拉列表中可
31、以选择快捷键,这些快捷键可以根据需要与“Alt”、“Ctrl”及“Shift”键组合使用。,在“Toolbar”标签页中,可以将菜单项和工具栏上的某个图标按钮相连,这样以后单击这个按钮就相当于单击相应的菜单项。 “ToolbaritemText”栏用来输入对图标按钮的描述性文本。,3-2.5 菜单,Create Menu,Menu Painter Properties pane has two tabs, which are used to set the currently selected menu item of the various properties. In the “Gener
32、al“ tab, “Name“ for the menu items name, “Text“ for the menu item text, “MicroHelp“ for the menu item displayed in the status bar on the bottom of the window help. Check box “Visible“ said the visibility, “Enabled“ for the availability, “Checked“ is selected. In the “Shortcut“ drop-down list, choose
33、 the shortcut keys, these shortcuts may be needed with the “Alt“, “Ctrl“ and “Shift“ key combination to use.,In the “Toolbar“ tab, you can be a menu item and toolbar button on an icon on the connected, so after clicking this button is equivalent to click on the appropriate menu item. “ToolbaritemTex
34、t“ column is used to enter the description of the button on the icon of the text.,3-2.5 菜单,创建菜单,If the script pane do not appear, right-click any menu item can be in the pop-up shortcut menu, selected “Script“ item, you can open the Script pane. In order for a code of a menu item, double-click the menu item on the “clicked“ event code.,如果脚本窗格没出现,可右击任意菜单项,在弹出的快捷菜单中选“Script”项,便可打开脚本窗格。 要想为某一个菜单项编写代码,双击该菜单项,对“clicked”事件编码。,