The use of Dynamic call types in the PB says that the Dynamic call type, let's take a reference to objects, properties, functions, and events: PowerBuilder 6.0 application development process is actually the definition and use of various objects. All objects are named and distinguished by names. In PowerScript, access object's properties, function, and events are simple. It is used as a tag as a marker. Specifically, the format of access object properties is: object name. Object property, for example, to edit box SLE_NAME Enter the content to the character string variable uchesrener's statement can be written: useeres = SLE_NAME.TEXT where SLE_NAME is the name of a single line edit box object, and Text is the Text property of the single-line edit box. The function of accessing objects in the program is: {objectName.} {Type} {calltype} {gen} functionName ({ArgumentList}) where the ingredients include ingredients can be omitted according to the situation, the meaning of each component is: ObjectName It is an object name; TYPE value is function or event to specify the access function or an event, the default value is function; CALLTYPE is used to indicate the timing of the PowerBuilder find function, effective value: Static (default): Compile time Find functions, if there is no existence, generate compilation error Dynamic: The program is looking for functions. If there is no existence, run error when generating an error when it is used to specify the function or event is executed immediately or the current block is executed, and the value is: Trigger (Default): Immediately execute the POST: After execution of the current block, execute functionname indicate that the called function or event name ArgumentList gives a function or event, for example, want to move the input focus to the single-line edit box SLE_NAME, write Observer: SLE_NAME.SETFOCUS (). Want to immediately perform the click event handler of the button CB_Name, then write the statement: cb_name .Event trigger clicked (). As seen above, Dynamic is a dynamic call for a specified function or event, that is, when you specify a dynamic call, the function and event do not have to exist when compiling. You tell the compiler: I believe me, there will be a suitable function or event when it is running. For dynamic calls, PowerBuilder is looking for functions or events when executed. This gives you bigger programming flexibility. Compare the following example (excerpt): UNDO features are available in most popular all applications, which can also be implemented using the UNDO () function in PowerBuilder. The undo () function can be used for DataWindow, EditMask, MultilineEdit, RichtextEdit, and SingLineEdit objects. If only an object is performed, simply use the following script in the UNDO menu item: Objectname.undo (), but when There are multiple objects in the window. We don't know which object to perform undo () when writing scripts. How to solve this problem? In PowerBuilder, the Undo () and other functions can only be used for visual objects, while all visual objects are inherited from the system object class GraphicObject.
So we can define an instance variable Go_Object of a GraphicObject object, etc. When you run, use the getFocus () function to determine the specific operation object. Then () function to determine the type of the current object with the Typeof, then Choose case statements refer to different types of instance variables depending on the code is as follows: graphicobject go_object DataWindow dw_object EditMask em_object MultiLineEdit mle_object RichTextEdit rte_object SingleLineEdit sle_object go_object = getfocus () choose case TypeOf (go_object) case DataWindow! dw_object = go_object dw_object.undo () case EditMask! em_object = go_object em_object.undo () case MultiLineEdit! mle_object = go_object mle_object.undo () case RichTextEdit! rte_object = go_object rte_object.undo () case SingleLineEdit! SLE_OBJECT = Go_Object SLE_OBJECT.UNDO () Case Else MessageBox ("Error", "No Can't undo!") End Choose In fact, we can simply solve this problem with the method of dynamic call functions, that is, call the undo () function on the GraphicObject object, Then add keyword Dynamic in front of the function