Announcement

Collapse
No announcement yet.

Integration problem

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Integration problem

    Hello, I would like to ask about whether EFS supports integration across scripts. Just like what we do in other languages, such as C++ or VB, we are able to use other local variables declared in other scripts within the same project (or you call the methods or functions of other objects). I am wondering whether it is possible to use variables in a different script from where these variables are declared. And if we do, it will be very helpful if you can simply describe how. Thank you very much!
    Last edited by teresali; 08-23-2010, 09:36 PM.

  • #2
    Hi,

    You can pass values from one script to another via "setGlobalValue()" & "getGlobalValue()" .

    Not an expert on global variable but try a search for "setGlobalValue()" & "getGlobalValue()" in the knowledge base and forum.




    Alternatively you can have one efs write to a text file and another read from it. Do a search for "file object" in the knowledgebase.



    Wayne

    Comment


    • #3
      Dynamic global values

      Dear all,

      I have a problem with the set/getGlobalValue(). If the variable I would like to return is an array rather than a constant, is it possible to indicate the element within the array? Currently I could only get the last item of the array from one script to another. Thank you!

      Comment


      • #4
        Teresa,

        You should be able to access anything you place into global memory. I've done quite a bit of work with these features and I've passed entire arrays of structures into global memory, then sucked them into other scripts as needed.

        I don't know how you are trying to accomplish your project, but anything you place into global memory should be instantly available to the other efs scripts.

        If you are passing an array (or structured array), then the entire array will be available.

        let me know if you need more help and I'll try to post some examples for you?
        Brad Matheny
        eSignal Solution Provider since 2000

        Comment


        • #5
          Dear Doji3333

          Thank you for your reply, and I would appreciate if you can show me a simple example about passing an array from one script to another, including the way declaring the global values, setting the values, and get the values from another script. I would like to have an array contains all the data about the trading time of one security, and pass them one by one to another script to control simultaneous trades on another security. Thank you very much!

          Comment


          • #6
            OK. Here you go.

            This is an example of a FEEDER and a READER. The FEEDER feeds data to the reader.

            PHP Code:

            var myArray = new Array();
              var 
            myObj = new Object;
              
            myObj.Item1 1;
              
            myObj.Item2 100;
              
            myObj.Item3 "LONG";
              
            myArray.push(myObj);
             
              var 
            myObj = new Object;
              
            myObj.Item1 = -1;
              
            myObj.Item2 100;
              
            myObj.Item3 "SHORT";
              
            myArray.push(myObj);

              var 
            myObj = new Object;
              
            myObj.Item1 0;
              
            myObj.Item2 0;
              
            myObj.Item3 "FLAT";
              
            myArray.push(myObj);

            /*  The above completes a simple THREE item array containing the three unique ITEMS as a structure.  Now we'll pass this info to another efs using the GLOBAL VARIABLE feature.
            */

            setGlobalValue("FeederID1"myArray); 
            At this point, you have populated and passed the entire array into global memory. Now all you have to do is GET it and READ it - like this.

            PHP Code:

            var ReaderData getGlobalValue("FeederID1");
              if (
            ReaderData != null) {  // Retrieved the array.
                
            var MALength ReaderData.length;  //  Gets the length of the array
               
                
            var 0;
                while (
            <= MALength-1) {
                  
            //  Output the array data to the FOW window
                   
            debugPrintln("["+x+"] "+ReaderData[x].Item1+" "+ReaderData[x].Item2+" "+ReaderData[x].Item3);

                   
            x++;  // increment x
                
            }

              } 
            This second example shows you how to PULL or READ the global value from memory.

            Remember, as you change the contents of the array in the first file, you need to continue to "setGlobalValue" to place the new updated array data into memory. This process is SET to update the global variable, then GET to retrieve it from memory.

            Hope this helps?
            Brad Matheny
            eSignal Solution Provider since 2000

            Comment


            • #7
              Hi Doji3333,

              This is great info. Thanks.

              I've used up a lot of time trying to do exactly what you posted.

              Wayne

              Comment


              • #8
                you are very welcome Wayne. I've learned many things about EFS over the 10+ years I've been working with it. Wish I could share all of my knowledge to help others, but it would take me about 10 years to do that. LOL

                Let me know if you need more help?
                Brad Matheny
                eSignal Solution Provider since 2000

                Comment

                Working...
                X