VBScript with JScript who is afraid who (3)

Source: Internet
Author: User
Tags abs comparison contains expression regular expression
Turn from: chinabyte
We selected eight different test routines (all the code used in the test is already available in the download zip file later in this article). If the language itself does not have a method or function, write a dedicated method.

1. String Flip: This test is done not only because it is a very representative operation, but because VBScript provides a built-in StrReverse () function and JScript does not have an equivalent function or method. This provides us with a very good mixed language programming test case. The string that was flipped in this test is "string reversal".

2. Search for another string in a string: VBScript and JScript themselves provide a way to implement the task. We use the InStr () function of VBScript and the IndexOf () method of JScript in the string "This is a sentence written for the sake of writing a sentence." Finds the starting position of the string "Ke" in the

3. Regular expression pattern matching: Although VBScript has recently joined regular expression support, this is still a good comparison test case. JScript provides a variety of string object methods that accept patterns that allow us to handle more flexibly, while VBScript is not so flexible and must be done within the bounds defined by the RegExp object. The test page contains a function that accepts the string "Regular Expression pattern Match" and the Regular expression "/(eg) |y|t{2,}/" and returns the total number of matches.

4. Displacement operations: JScript has bit operators and VBScript does not, this is a good comparison test case. The following actions will be performed on the page where this test will be performed: < < 5 and -14 > > 2.

5. Simple mathematical Calculations: The following calculations are performed: 18976.6754 + (-908.6) + 1475.211.

6. Complex mathematical calculations: The test page contains a function that calculates the distance (miles) between them based on the coordinates of the two points. The calculated expression for VBScript is:
Distance = Round (SQR ((69.1 * (LATA-LATB)) ^2) +
((69.1 * (Abs (Lnga)-abs (LNGB)) * Cos (latb/57.3)) ^2)), 1).




7. Array initialization: Both VBScript and JScript engines will create a temporary copy of the entire array as long as there is access to arrays of elements, which is also a good test case. In addition, the JScript array is also an object with many methods and properties, while the array in VBScript is just an array. This test initializes an array of 100,000 elements through a for loop, and each element is given the value of the loop counter.

8. ADO Recordset Traversal: The database used for this test is the Access2000 "Northwind" database, where the program uses the ADO Connection object to execute the SELECT * FROM Orders command to obtain an ADO recordset. The program uses two nested loops: the outer loop loops through the records, and the internal loops through all the fields of each record. This test case is good because JScript needs to instantiate a enumeration object to traverse the collection of objects, and VBScript only needs a for each ... The next loop can accomplish the same task.
Turn from: Dynamic Network production guide www.knowsky.com

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.