HTTP Object |
Top Previous Next |
HTTP Object
The HTTP object allows EFS to open a file from a URL to import data for use within the EFS script. The HTTP functionality can be used to read text files (e.g., .txt, .htm, .html, .xml, etc.)
HTTP Methods
Usage
var v = new HTTP("http://www.somepage.com/whatever.txt"); OR var v =new HTTP("http://www.somepage.com/something.asp?symbol=" + getSymbol()); //After constructing the object, do something like this: if(v.open()) { while(!v.eof()) { debugPrintln(v.readln()); } }
//Here's an example of a custom function for //loading a text file from a URL, which can //be called from preMain(). //The MyFile.txt file would need to contain 6 //numbers, each on a separate line. This example //populates a global array with the 6 numbers //from MyFile.txt.
var aArray = new Array(6);
function preMain() { loadData(); }
function loadData() { var f = new HTTP("http://www.somepage.com/MyFile.txt"); var i = 0;
f.open("rt"); if (f.open()) { for (i = 0; i < 6; ++i) { aArray[i] = f.readln(); } } f = null; //debugPrintln(aArray);
return; }
|