WMLScript is part of the WAP application layer of the wireless application protocol. It can use it to add client processing logic to WML card sets and cards. The latest version is version 1.1. WMLScript 1.1 is based on the ECMAScript scripting language formulated by the European Computer Manufacturers Association and is formulated through modification and optimization. It can better support narrow bandwidth communication devices such as mobile phones. Using WMLScript in WML programming can effectively enhance the flexibility of client applications. Moreover, we also use WMLScript as a separate tool to develop powerful WAP network applications and wireless web pages. In this chapter, we will explain in detail the basic syntax knowledge of WMLScript 1.1 programming, such as basic rules, variables and data types, operators and expressions. For the sake of narrative simplicity, we will shortly call "WMLScript 1.1" abbreviated as "WMLScript".
7.1 Simple example: Calling WMLScript functions in WML programs
After learning the first two chapters, readers who are familiar with C language may realize that the function functions, logical operation functions, etc. of WML are very limited. WMLScript provides rich function functions. In WAP application development, we can use WMLScript to enhance WML programming. Commands that call WMLScript statements and functions can be written directly in WML
7.3 Basic rules of WMLScript
WMLScript follows the practice of WML in many basic rules. However, since WMLScript is based on C language, its syntax features are very similar to those of C language. If you are familiar with C language, it should be easier to learn and master this part of the content.
7.3.1 WMLScript and URL
Like WML, WMLScript also follows the URL, HTTP and other specifications of WWW and HTML access resources, and expands the scope of URL usage. In WMLScript, not only hyperlinks, file paths and file names can be processed as URLs, but external functions, access control information, etc. can also be processed as URLs.
To this end, WMLScript adopts a workaround of WML, that is, to improve the location of HTML naming resources, and to use the form of a program segment anchor (Fragment Anchor) to handle resource positioning. The block anchor point is defined according to the document URL rules and written in the way of adding a tic toe (#) to the block identifier. Using the block anchor, the WMLScript program can locate any specified function within the WMLScript compilation unit and pass the required parameters while calling the function.
For example, when a WAP mobile phone user calls an external WMLScript function through a browser, he can first write out the URL address where the function is located, such as /; and then process the function name and parameters as the program block anchor point, such as testFunc('Test%20argument', -8), so that the URL address containing the program block anchor point is written in the end: /#testFunc('Test%20argument', -8). Note that the tic-tac mark (#) is added.
After receiving such a call, the browser will first perform an access control check. If the caller does not have access permissions, the call to the function is terminated. Otherwise, continue to execute the call operation, match the function name in the anchor point with the external function in the compiler, and terminate the execution if it is not appropriate; otherwise, further judge the format, number, type, parameter value attributes, etc. of the function parameters. If the requirements are met, the function call will be successful, otherwise the function call will be rejected.
7.1 Simple example: Calling WMLScript functions in WML programs
After learning the first two chapters, readers who are familiar with C language may realize that the function functions, logical operation functions, etc. of WML are very limited. WMLScript provides rich function functions. In WAP application development, we can use WMLScript to enhance WML programming. Commands that call WMLScript statements and functions can be written directly in WML
7.3 Basic rules of WMLScript
WMLScript follows the practice of WML in many basic rules. However, since WMLScript is based on C language, its syntax features are very similar to those of C language. If you are familiar with C language, it should be easier to learn and master this part of the content.
7.3.1 WMLScript and URL
Like WML, WMLScript also follows the URL, HTTP and other specifications of WWW and HTML access resources, and expands the scope of URL usage. In WMLScript, not only hyperlinks, file paths and file names can be processed as URLs, but external functions, access control information, etc. can also be processed as URLs.
To this end, WMLScript adopts a workaround of WML, that is, to improve the location of HTML naming resources, and to use the form of a program segment anchor (Fragment Anchor) to handle resource positioning. The block anchor point is defined according to the document URL rules and written in the way of adding a tic toe (#) to the block identifier. Using the block anchor, the WMLScript program can locate any specified function within the WMLScript compilation unit and pass the required parameters while calling the function.
For example, when a WAP mobile phone user calls an external WMLScript function through a browser, he can first write out the URL address where the function is located, such as /; and then process the function name and parameters as the program block anchor point, such as testFunc('Test%20argument', -8), so that the URL address containing the program block anchor point is written in the end: /#testFunc('Test%20argument', -8). Note that the tic-tac mark (#) is added.
After receiving such a call, the browser will first perform an access control check. If the caller does not have access permissions, the call to the function is terminated. Otherwise, continue to execute the call operation, match the function name in the anchor point with the external function in the compiler, and terminate the execution if it is not appropriate; otherwise, further judge the format, number, type, parameter value attributes, etc. of the function parameters. If the requirements are met, the function call will be successful, otherwise the function call will be rejected.