Announcement

Collapse
No announcement yet.

help w/ Tab, delimited string

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

  • help w/ Tab, delimited string

    Hi all,

    I am trying to extract info from a returned delimited string ( namely, the avg fill price) from my broker's API. The postion tab for the fill price is the 11th space. Because of my limited knoweledge in this area, I don't know to extract that exact field.
    I have enclosed the outcome of my code in a debug window.

    My code so far:

    var y = new String (d.call("tb_GetOrderDetailsString",TBTkt));
    debugprinted "y"

    var vLimit = y.split("");
    var aLimit = vLimit.length;
    for(i=0; i<aLimit; i++);
    nLimit = i;

    debugged, vLimit and nLimit .

    What comes next in code to get only the 11th tabular space, in this case the fill price of 1242.75???

    Thanks for any help on this in advance!!
    angelo
    Attached Files
    ang.

  • #2
    hi angatgg,

    To get this to work with tabs, split the string with "\t"

    This is a simple efs you can run in eSignal. Something similar in nature will work in C#, C++, VB, etc...

    PHP Code:
    var nString "0    1    2    3    4    5    6    7    8    9    10    11    12    13";
    nString nString.split("\t");
    debugPrintln (nString[11]); 

    Comment


    • #3
      Hi Steve,

      Thanks for your help!! I couldn't remember the string literal that is required to seperate "tabs". However, after reviewing your code ,(which i find syntaxally correct), I can't get the #@#@#
      number to work!!!!!. I posted code and output for you to see that the string comes back "undefined". Any help is appreciated greatly!!!! It's one of those mind boggles thats driving me crazy!!

      Thanks again!!!!
      angelo
      Attached Files
      ang.

      Comment


      • #4
        I believe the EFS editor in eSignal changes tabs to spaces...you should verify with your code (if you delete the white space between the various parameters in nString, does it remove it as spaces or tabs?).

        If spaces you can try to edit it with another editor (I happen to know Steve uses a different editor, and therefore will not see this problem).

        Garth
        Garth

        Comment


        • #5
          Hi Garth,

          I went ahead and copied the three lines from my php bloc and pasted into the efs editor and was able to reproduce what angelo saw. This probably would have driven me nuts as well, thanks for the good catch!

          I went ahead and attached the efs to preserve the formatting below.
          Attached Files

          Comment


          • #6
            Steve,

            Glad I could help.

            Garth
            Garth

            Comment


            • #7
              Hey Steve, and Garth,

              Thanks to you both for adding to this post!
              I went and loaded the script file in my chart (as a seperate price study), and it produces the value correctly. However; when placed in my program, I still get the undefined value! I removed the spaces from the string, ie: String= "12345678..etc" and it still
              returns undefined, when using xxx.split("\t").

              By using the split operator -- xxx.split("\t"); it seems it does not parse out the tabs from the string. However; when I seperated the string with a comma, "1,2,3,4... or "1, 2, 3, 4... and split with a comma seperator xxx.split(","); it works, and I get the results that I'm looking for. xxx[11].

              Now this throws me... why does the script ,when placed as a non price study ,work correctly, but doesn't work in a price study?

              Since the info I'm extrapolating, is a single, TAB, Chr$(9), delimited string,(refer to my first post ),.. the only way to get this to work it seems, is to place commas in the string, by doing this.. xxx.split(""); which poduces commas in the string, and then split the commas out, to get the results.

              Still, would like to know the why this is not working correctly.

              Any thoughts..????

              Thanks again for your help.
              angelo
              Attached Files
              ang.

              Comment


              • #8
                angelo,

                You are welcome. It works because the file has tabs between the values. Did you try what Garth said for each efs?

                ...you should verify with your code (if you delete the white space between the various parameters in nString, does it remove it as spaces or tabs?). ...btw, you can also use the arrow keys to verify

                I suspect you will see spaces between the string that does not work, tabs between the string that does.

                Regardless, if you are trying to split a line in a file, this will work provided that line in the file is separated with tabs.

                Comment


                • #9
                  angelo,

                  Please try and run this efs. I added a test to determine if the string has tabs ...

                  PHP Code:
                  var nString "0    1    2    3    4    5    6    7    8    9    10    11    12    13";
                  if(
                  nString.indexOf("\t")<0){
                      
                  debugPrintln ("there are NO tabs, test = "+nString.indexOf("\t"));
                  }else{
                      
                  debugPrintln ("YES, there are tabs, test = "+nString.indexOf("\t"));
                  }
                  nString nString.split("\t");
                  debugPrintln (nString[11]); 
                  Also, when you copied the efs into your code, did you copy it from my attached file? In my eSignal editor, when the line was copied from the file which had the tabs, it retained the tab spaces (using the tab key in the eSignal editor to insert tabs will not work, it only adds white spaces).

                  here is the actual file:
                  Attached Files

                  Comment


                  • #10
                    Steve,

                    Great detective work with the script you supplied!!! As you suspected, there are no tabs in my string, as per your test.

                    And yes, I copied your original file, into my formula, and it works correctly, your string does have tabs!.

                    Where would we "newbees" be without you guys??..... I follow and learn a lot from you and other fellow senior helpers. Your help is always top notch!!

                    Ok, so now lets talk about "Tabs". Forgive my ignorance on this one. Aren't the "tabs" the "spaces" between each string , as in 1 2 3 4 etc.??? As you noted, the arrow key in your string actually "tabbed" correctly to the next number. However, when I use my "tab" button on my keyboard , the arrow button doesn't tab to the next number, which indicates a no tab space.. Am I mising something here, or does "tab" in strings have anything to do with the the tab button on your keyboard???

                    Garth mentioned something about tabs in e signal editor that might not work....
                    How can I create a " tab" in strings , that will work in my program?

                    Again, thanks to all who helped on this discussion!!

                    angelo....
                    ang.

                    Comment


                    • #11
                      angelo,

                      Computers use internal "codes" to represent different characters. A tab has a different internal representation than a space does. The issue in this case is that the eSignal internal editor coverts a tab to the equivalent number of spaces.

                      You are not restricted to the internal efs editor when creating (or editing) efs code. In fact, back when efs was first being created we were using the standard windows text editor (or other text editors). If you use textedit, or similar editor, it will accept tabs. Just avoid word processors/document creation tools or other applications that embed metadata into their documents.

                      In theory you could also embed the hex (think internal representation) equivalent into the string. A tab is a hex 9 so a string similar to this:

                      nString = “1” + 0x09 + “2” + 0x09 + “3”

                      Might work, even with the eSignal editor. Sorry I don’t have time to test and play with to get the exact form correct.

                      Garth
                      Garth

                      Comment


                      • #12
                        I was thinking about this on my drive into work.

                        An easier way (again sorry i can't test) should be to use the "C" type constructs for this. In this case \t would represent a tab in a string variable:

                        var nString = "1 \t 2 \t 3 \t 4 \t";

                        I am pretty sure this would work with javascript, and think it should work with EFS (which is uses Javascript as it's core).

                        Garth
                        Garth

                        Comment


                        • #13
                          angelo,

                          As Garth indicated, I use Scite, an alternate editor. If being able to insert tabs is important to you, you can install and have a second editor that you can use. You can still take advantage of the syntax checking feature native to the eSignal editor by copying code into it. Check this link which discusses alternate editors and has a link to the Scite editor.

                          Comment


                          • #14
                            Hi Steve,

                            just trying out the scITE editor, is Javascript the language to chose for keyword highlights, or should I see the choice for efs.

                            I have used the properties from your fileshare.

                            Thanks for bringing this to my/our attention.

                            Paul.
                            Last edited by pmurraymc; 11-04-2006, 04:58 AM.

                            Comment


                            • #15
                              Hi Paul,

                              You are most welcome, I have been using it for years and like it very much.

                              The Properties file I have uploaded to fileshare has all the keywords in it. The easiest way to get them installed correctly is to open up the User Options File from the Options Menu, then take the SciTEUser.properties file from the fileshare, open that and paste the contents of that right over the User properties file you had previously opened from the menu, then save the modified file.

                              The reason you go through this is that the User Properties file is saved in a different location than the Scite text Editor. This Technique has worked for me and is included in the instructions text file l I have there as well.

                              As to your question on file type, I have been in the process of upgrading and was trying to get the efs and efsLib file types to show up in the Language Menu, but that requires I create a properties file and success with that has been elusive. That is why I have all of the keywords are in the User Properties file. If you install the properties the way I described, all of the keywords should highlight correctly, at least they were when I saved them in fileshare, making the Selection of the JavaScript file type unecessary.

                              With the upgrade, I am having some problems getting the hanging indents working correctly for conditionals and other blocks, something I had working well in my previous version. So I am still working through that. That may be why the properties that you downloaded are not working. If you want, I just uploaded another copy to the fileshare. This is working well on my end, except for the hanging indents, so you may want to give that a shot. Also, try the Scite Help on the help menu. That will take you to the Help file instructions I am trying to work through and give them a shot. When I finish tweaking, I will upload that copy to the fileshare.

                              Comment

                              Working...
                              X