Announcement

Collapse
No announcement yet.

Tab-delimited Output

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Tab-delimited Output

    I would like to write to a text file in a tab-delimited format, but I don't know how to insert tabs into the output string. Is this possible?
    pa-kay

  • #2
    use "\t" in your string

    f.writeln("myVar = " + myVar + "\tmyOtherVar = " + myOtherVar);

    check the File I/O section of the EFS Help file

    Comment


    • #3
      That's great Gavishti, thank you. I thought it was \t, but I didn't put it between quotes. Also, I didn't see this in the File I/O section.

      Now I am trying to get a grip on using formatted output. For example, if 'myVar' is two place decimal and 'myOtherVar' is a one place percentage, and both are in the same string.

      Any help would be appreciated. It's simple stuff, I know, but I'm a simple minded novice (and getting a bit tired).
      pa-kay

      Comment


      • #4
        Here is a sample line that is being sent to a file that shows how to tab delimit and fixing the number of decimal points.

        sLine = sTotalTrades.toFixed(0)+"\t"+sType+"\t"+sAction+"\ t"+sDate()+"\t"+sTime()+"\t"+sEntry.toFixed(2)+"\t "+nPOS.toFixed(0)+"\t"+" ";

        Slightly different tab delimination than what Gavishi posted, but either are correct. By placing the .toFixed() on the end of a variable it, the expression is a string.

        Comment


        • #5
          Great example Steve.

          pa-kay,

          You may also want to check out formatPriceNumber(). It comes in handy to make sure that you get the correct display for prices. It knows the difference between stocks, futures, bonds, etc.

          Comment


          • #6
            Steve,
            The '.toFixed()' thing works great. Now if I can only get something like that to format a percentage number. By the way, under what topic would I find these functions in a guide somewhere?
            pa-kay

            Comment


            • #7
              fWLRatio = Math.round(100 * (iWCnt / (iWCnt + iLCnt))) + "%";
              fWLRatioTtl = Math.round(100 * (iWCntTtl / (iWCntTtl + iLCntTtl))) + "%";

              Comment


              • #8
                here is a link to Chris Kryza's help file which he keeps up to date for eSignal http://share.esignal.com/groupconten...le&groupid=114 I would download and install. I often keep mine open in another window while coding.

                Regarding formatting %, what kind of formatting do you want? (update - looks like Gavishti answered that one! )
                Last edited by Guest; 02-26-2004, 04:23 PM.

                Comment


                • #9
                  Gavishti,
                  Yes, I could've have figured that one out, but jeeeez louizzz, isn't there an easier way to format the output? I have a Java reference book that gives a partial example of Formatted Character Output that looks like this:

                  DecimalFormat df = new DecimalFormat ( "#0.00;#0.00CR" );
                  System.out.println( df.format( -1.267) );

                  1.26CR // the output


                  Then in a table is states the '%' symbol can be used in a format string to multiply by 100 and show as a percentage. However, there is no example, and I can't seem to make this work in an eSignal script.

                  I was hoping to find something like this to streamline my script writing, but maybe I should just move on. Thanks for your help.
                  pa-kay

                  Comment


                  • #10
                    Hello pa-kay,

                    FYI, EFS is based on JavaScript 1.5, not Java. They are two different languages. Here's a couple links to some core JavaScript 1.5 reference material.

                    Core JavaScript Guide 1.5
                    Core JavaScript Reference 1.5
                    Jason K.
                    Project Manager
                    eSignal - an Interactive Data company

                    EFS KnowledgeBase
                    JavaScript for EFS Video Series
                    EFS Beginner Tutorial Series
                    EFS Glossary
                    Custom EFS Development Policy

                    New User Orientation

                    Comment


                    • #11
                      Okay, thank you. That explains everything. I'll shelve this book when writing EFS studies and try to learn JavaScript 1.5 instead. That should save me some headaches.
                      pa-kay

                      Comment


                      • #12
                        pa-kay,

                        I have no idea what level you are at. Your questions seem to indicate that you do not have decades of experience as a programmer. Maybe I'm wrong about that. There are tons of things you can do if you want to start writing your own DLLs.

                        I was just trying to give you a quick answer to your question using the JavaScript extension called eSignal Formula Script (efs). If you find that offensive, my apologies.

                        Comment


                        • #13
                          Gavishti,
                          Your post was not at all offensive. On the contrary, your suggestions helped me alot. I was just expressing my surprise (and ignorance) about the script language. I will be more careful about wording my posts in the future. Sorry it came across like that.
                          pa-kay

                          Comment

                          Working...
                          X