Tip: An alternative way to load an external text file
Source: Internet
Author: User
Tips | Loading the external text to be loaded is usually such a format:
A=......&b= ... is a variable name with a value.
But in plain text, how does a variable name load?
Here is a successful example.
One of the core (key) is: The whole style as a variable name!
System.usecodepage = true;
var mytxt:string= "";
var myarray:array = new Array ();
var mytxtload:loadvars = new Loadvars ();
Mytxtload.onload = function (Success:boolean) {
if (success) {
For (i in mytxtload) {mytxt+=i} Read variable names from objects
Mytxt=mytxt.substr (0,mytxt.indexof ("Onloa", 0))//Remove text section
MyArray = Mytxt.split ("\ r \ n");//Enter into the array by carriage return swap
Trace (myarray);
} else {
Trace ("err!");
}
};
Mytxtload.load ("Mytxt.txt");
In fact, I do not know what it is used, but the main is to give a kind of thinking, a bit of alternative.
Note that the above code, if there are special characters in the read text, such as "=", "&" and so on, but also to deal with the line.
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