5 Replies Latest reply on Aug 30, 2008 8:16 AM by (Dave_Saunders)

    Read Mathtype EPS File

    hm_arul Level 1
      Hi scripters

      I am trying to read Mathtype EPS file to get the information (%%Baseline:). Here is the script I have started. But I struck in matching the string.

      find string
      %%Baseline: 10 (this value "10" will vary so we can have this [0-9][0-9][0-9])

      var myFile = File.openDialog ("Open Index File");
      myFile.open ('r', undefined, undefined);

      please guide me how to get %%Baseline: value?

      I am using ID CS2 and Jscript

      thanks in advance

      regards
      a r u l
        • 1. Re: Read Mathtype EPS File
          Loic.Aigon Adobe Community Professional
          It seems that you take a break before you reached the point.

          var myFile = File.openDialog ("Open Index File");
          myFile.open ('r', undefined, undefined);
          var str = myFile.read();

          Now troubles are begining...
          Looking for the string "%%Baseline:" shouldn't be difficult too much with the indexOf method.
          if(str.indexOf("%%Baseline:")!=-1) //%% may oblidge you to think a bit about it.
          {
          var baselineIndex = str.indexOf("%%Baseline:");
          var baselinecharlength = 12;
          var x = baselineIndex + baselinecharlength;
          var y = //how to know right now ?
          var myValue = str.substr(x,y);
          }
          You see the problem ? x may be easy to determine but what about y ?
          It's x+2 if your value is about 2 digits but x+15 if your value is [0-9][0-9][0-9].

          I guess it could imply a bit of grp in this case but with no certitudes. Good luck arul.
          Loic
          • 2. Re: Read Mathtype EPS File
            hm_arul Level 1
            Hi Loic,

            Thanks a lot for u r message, I wil try

            thanks again

            regards
            a r u l
            • 3. Re: Read Mathtype EPS File
              Loic.Aigon Adobe Community Professional
              what do you mean by [0-9][0-9][0-9] ? Number can be 3 digits whatever the value they have or a string litteraly made of [0-9][0-9][0-9] ?

              Please give us a bunch a values Baseline: can have so we can try thinking about a logic.

              Regards,Loic
              • 4. Re: Read Mathtype EPS File
                Level 1
                Here's the code I use to read the baseline from a MathType ESP file (eqn):

                    eqn.open("r");
                
                    var myBaseline = 0;
                    while (eqn.read(2) != "%%" ) {
                      eqn.readln();
                    }
                    eqn.readln();
                    while (eqn.read(2) == "%%") {
                      var nextLine = eqn.readln();
                      if (nextLine.split(":")[0] == "Baseline") {
                        myBaseline = Number(nextLine.split(": ")[1]);
                        break;
                      }
                    }
                    eqn.close();
                The value represents points up from the bottom of the graphic's bounding box.

                Dave
                • 5. Re: Read Mathtype EPS File
                  Level 1
                  I suspect that my code reflects (a) my lack of understanding at the time of how to read a binary file and (b) my complete mystification (again, at the time) with how to use grep.

                  Dave