WMLScript Basics of Wireless Markup Language (WML) Basics 1th/2 page _WML Tutorial

Source: Internet
Author: User
Tags number strings reserved
WML script is part of the Unlimited Application protocol WAP application layer, which can be used to add client-side processing logic to WML cards and cards, and the latest version is the 1.1 version. The WML Script1.1 is specified as modified and optimized on the basis of the ECMAScript scripting language developed by the European Computer manufacturer agreement. It is better able to support high-bandwidth communications devices such as mobile phones, and using WML script in WML programming can effectively enhance the flexibility of client applications, and we can also use WML script as a tool to develop powerful WAP Web applications and unlimited Web pages. In this chapter, we will explain in detail the basis of WML Script1.1 programming, such as basic rules, variable data types, operation-given expressions, and so on. In order to describe the simplicity, later we will "WML Script1.1" referred to as "WMLScript."
Call WML script function in 4.1 WML program
After the first two chapters of the study, familiar with C language readers may realize that WML function, logic operation functions are very limited. While WMLScript provides a wealth of function functions, we can use WMLScript to enhance WML programming in WAP application development. As a result, WMLScript has become a major development tool for expanding WML programming capabilities.
The main advantages of 4.2 wmlscript and its bytecode interpreter
WMLScript has a well-defined set of bytecode and an interpreter reference structure. The WMLScript data in the wireless network transmission is transmitted in binary format, so the user can use the bandwidth communication channel, which can keep the client phone only need the minimum memory. ECMAScript modified WMLScript can be faster, smaller, and easier to compile programs in bytecode form. All of these features are wmlscript with many of the advantages and features that WML cannot have.
4.2.1 The main advantages of using WMLScript
WMLScript is designed to provide the WMLScript system with a general script processing capabilities, using wmlscript we can further complement the XML-based WML language programming capabilities, the development of bandwidth-oriented network applications and content, such as text, images, select lists, etc. We can use a simple format to write a more flexible and readable user interface. WMLScript has the advantages and functions of WML, including the following:
(1) Check the legality of user input:
(2) Expand the function of the user's browser, such as allowing programmers to develop phone calls, send short messages, store phone numbers, manage phone books or SIM cards;
(3) Generate a user-side confirmation, prompt, warning message or Action dialog box, and make it quickly displayed in the browser;
(4) The browser-side software and parameters can be extended and configured after the user's browser changes;
(5) The maximum extent to overcome the client's bandwidth communication connection restrictions, and provide a wealth of program functions;
(6) Complement WML and enable it to implement a variety of services for micro-mobile terminal devices, such as supporting the advanced user interface, increasing client intelligence, providing access to the user's browser peripherals, and browsing the data on the server and client to reduce bandwidth consumption.
4.2.2 WMLScript byte-code interpreter
Before the WMLScript bytecode interpreter is interpreted, the text-formatted program written in the WMLScript language will be first compiled into binary-formatted code. At compile time, the compiler usually first divides the WMLScript program into several editing units, each unit of the program contains a number of statement lines and WMLScript functions, then, the WMLScript compiler will follow these compilation units, one by one, the WMLScript program as input, and the corresponding byte code as output content. When the user calls the WMLScript program through the WAP phone, the compiler's encoding function is activated and executed.
4.3 wmlscript Basic Rules
WMLScript has followed the WML approach in many of the basic rules. However, because WMLScript is specified in the C language, its grammatical features are very similar to the C language. If you are familiar with C language, then learning and mastering this part of the content should be relatively easy.
4.3.1 wmlscript and URL
Like WML, WMLScript also uses the WWW and HTML access resources URL, HTTP and other specifications, and expanded the scope of the use of URLs. In WMLScript, not only the hyperlink, file path, or file name can be used as URL processing, external functions, access control information can also be treated as a URL.
For this reason, WMLScript uses a WML workaround, that is, to improve the value of the HTML named resource, and to use the form of the program segment anchor (Fragment anchor) to handle the resource location. The program segment anchor is defined according to the document URL rule and is written in the form of a well font size (#) before the program segment identifier. With the program segment anchor, the WMLSCRIPT program can specify any function within the WMLScript compilation unit, and can pass the required arguments while calling the function.
4.3.2 Lexical structure
WMLScript programming in the lexical structure is not complex, we are the following from the case sensitive, space, line, note that is reserved words to explain the relevant specific rules.
(1) Content type. WMLScript content types are mainly for file form and binary form, type structure can be specified on the server side, in the form of:
Text form: Text/vnd.wap.wmlscript;
Binary form: APPLICATION/VND.WAP.WMLSCRIPTC.
Specific methods we have introduced in the 4th chapter, no longer repeat here.
(2) Case sensitive. WMLScript1.1 is a case sensitive scripting language. The various keywords, variables, and function names designed by it must be used in a reasonable case.
(3) Spaces and line wrapping. In general, the WMLScript program value form ignores all spaces, tables conform to line breaks, and so on. However, if these special characters are expressed in code or processed as strings, WMLScript will no longer ignore them. , for example, the string "Oct 28,2001" contains spaces that are not ignored when executed, and are different from "oct28,2001", which contains no spaces.
(4) Notes. As with WML programming, annotation content can also be added to the WMLScript script program. The annotation content is not executed by the program, and annotations cannot be nested. There are two kinds of annotation methods for WMLScript:
First, line comments. Even if you are booting with a double oblique line number (//) with one line of content, this line of content is all commented. Such as:
This is a line comment, with the double slash number beginning to the end of the comment.
Secondly, block selection. This starts with the symbol "/*" and all content is commented during the end of the symbol "/*". Such as:
/* This is a block annotation, added in the middle of the content is the annotation content * *
(5) Data type and direct encoding. WMLScript allows 4 types of data to be encoded directly and nested and nested within a program. The data types that are directly encoded in 4 are: integers, floating-point numbers, strings, and Boolean values. In addition, the "invalid" value can also be directly encoded "1." Integer. This type of integer can be encoded directly when an integer is used in decimal, hexadecimal, or octal mode.
When coding, the decimal digits do not start with 0, and contain only 0~9 numeric strings; The hexadecimal data begins with the ox or ox and contains only strings of 0~9, a~f, or a~f; the octal number starts with 0 and contains only the number strings of the 0~7.
2. Floating point numbers. Floats are usually defined as numbers that contain decimal points, and can contain decimal and exponential portions. Floating point numbers have more forms, you can make decimal integers or floating-point numbers, can be fractions, can also be exponential; but a floating-point number must have at least one count.
The exponent starts with E or E, followed by an integer. The exponent is a power of 10. For example: E0 10 of the 0 power, such as: E0 when the other power 10, e-2 10 of the negative 2 power set equals 0.01. Indices can be signed, just (+) or minus signs (-), which represent positive and negative indices, respectively.
3. String. A string is the content that is defined between pairs of double quotes ("") or single quotes (' ").
Because WMLScript only allows strings to be defined using pairs of double quotes or quotes, a compilation error occurs when a single or double quotation mark is used in a program.
Given that some special characters cannot appear directly in the string, WMLScript provides a translation sequence to represent these special characters.
4. Boolean type. It is only ture and false two values that represent "truth" or "false value" in WMLScript. Boolean data can participate in different, or equal operations, the specific rules we later introduce.
5. Invalid type. Also known as an "empty type", it is a wmlscript-supported amount representing an invalid value, expressed in invalid. The two are similar to NULL in the C language.
4. Reserved words. WMLScript defines a set of reserved words that contain words that represent special meanings that cannot be defined separately or most other identifiers. The reserved words in WMLScript are as follows:
Acces HTTP agent If break IsValid continue meta header
div name div= path domain return else typeof while
Equiv URL extern use for user function var
In addition, WMLScript also reserved some reserved words for future versions, mainly:
Case finally catch import class private Const public debugger
sizeof default struct do Super enum switch export throw
Extends try
WMLScript also has some reserved words that are not used:
Delete Null in-lib void new with
7. Identifier. The wmlscript identifier can specify or name 3 elements: variables, functions, and callouts. An identifier cannot begin with a number but can begin with an underscore (-), and the identifier cannot be a wmlscript reserved word. For example, TimeOfDay, speed, quality, home_address, _myname, __, Varo, and so on are legitimate identifiers, while strings that start with a special symbol of a number or a short underline, and reserved words are all illegal flags, such as while, For, if, My~name, $sys, 123, 3piecs, take.this, etc.
Because WMLScript are strictly case-sensitive, identifiers that are identical but different in capitalization are not the same identity, for example, work and work are different identifiers.
8. Name space. WMLScript provides a more liberal namespace, and the same identifier can be used for different purposes at the same time. For example, as an identifier for a function name, it can also be used as variable names, function arguments, program annotations, and so on, and their properties or values do not interact with each other. In the following simple routine, the mytest identifier is used as the function name and as the variable name, function parameter name, function parameter name, and constant name. Obviously, this particular wmlscript provides a great convenience for us to write programs.
Current 1/2 page 12 Next read the full text
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.