HTTP Object

ICE Data Services -

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.)

 

Warning: It is highly recommended that you do not use the HTTP object within the main() function where it has the potential of being called on every new trade. Instead, use the HTTP object either in the preMain() function or in custom user functions that are only called when needed.

 

Methods

 

.open();

.readln();

.eof();

 

Examples:

 

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;

}