2 Replies Latest reply on Nov 9, 2016 12:18 PM by Geogeorger

    Inserting a Date text into a document on several different pages

    Geogeorger Level 1

      I need to put an ordinal date phrase in several positions in a document.  I have managed to be able to get it to put the phrase on the top of the first page where I then go along and cut and paste it where I need it.  But what I would like is to run the script and have it insert the text exactly where I want it to go in the document with out manually having to do it. Here is the script I am using which I basically got to work copying and fixing it so I could get an output.  I am running extendscript on Adobe FrameMaker v12

      //  INSERTING THE VALUE OF A VARIABLE INTO A DOCUMENT THAT WAS CREATED IN SCRIPT

      var m_names = new Array("January", "February", "March",

      "April", "May", "June", "July", "August", "September",

      "October", "November", "December");

       

       

      var date = new Date();

      //alert(date)  //shows system date

       

       

      var curr_date = date.getDate();

      //alert(curr_date)  //shows the day date

      var sup = "";

      if (curr_date == 1 || curr_date == 21 || curr_date ==31)

         {

         sup = "st";

         }

      else if (curr_date == 2 || curr_date == 22)

         {

         sup = "nd";

         }

      else if (curr_date == 3 || curr_date == 23)

         {

         sup = "rd";

         }

      else

         {

         sup = "th";

         }

       

       

      var curr_month = date.getMonth();

      //alert(curr_month)  //shows the month

      var curr_year = date.getFullYear();

      //alert(sup)  //shows the suffix for the ordinal number of the day date

      var NewordinalDate="the "+curr_date + sup + " day of "+m_names[curr_month] + ", " + curr_year

      //alert(NewordinalDate)  // shows the date phrase of the ordinal day with the date.

      //here is an example of the output "the 22nd day of August, 2016 "

      var doc= app.ActiveDoc;

      var mainflow =doc.MainFlowInDoc;

      var tframe=mainflow.FirstTextFrameInFlow;mainflow.FirstTextFrameInFlow;

      var pgf = tframe.FirstPgf;

      var tLoc=new TextLoc();//Create the text location objet

      tLoc.obj=pgf;  //make it a paragraph

      tLoc.offset=25;   //insert at the start of the paragraphs

      doc.AddText(tLoc,(NewordinalDate)); //insert the variable into the document look at the in parenthasse

      //make sure paragraph marker is present on the target page or a lot of object references will be undifined.

       

      In most of my documents I need to have a current date variable and this ordinal date phrase which I have to create using the parts of the two current date fields.  The result is I don't have a current date that will update. So I thought to create a script and run it just before printing or sending the documents. Most of these date phrases come in on the last page of the document which can be 15 to 16 pages long. As I have said at the moment this Script will write the phrase of the current system date at the left hand top of the document. Where I usually have a Header in bold so I have to drop that down and assign a normal paragraph tag to it before I run the script or I get Upper case in Bold underlined date phrase.  I really need to learn how to put the add text phrase or any other phrase where ever I want the result to go. In the script above I don't seem to get anything from the  tLoc.offset=    I don't believe this is executing I don't know why there is nothing from it. I have almost zero knowledge about how to script I am just fiddling with javascript premade scripts I have pulled off the internet and got them somehow to get results in Framemaker extend script.   I am amazed at how little there is on anything one actually needs to do Why this date phrase is not a built in variable in FrameMaker leaves me a bit weary.  Why framemaker Doesn't have a built in DBF connectivity is also a mystery I guess it is program created before ODBC

      any insight or help with this would be immensely appreciated.

        • 1. Re: Inserting a Date text into a document on several different pages
          frameexpert Level 4

          It is not clear to me exactly what you are trying to do, but I would be willing to have a short web meeting with you so I can see what you are trying to accomplish. I am sure I could give you some pointers. I am on US Eastern Standard Time. Thanks. -Rick

          • 2. Re: Inserting a Date text into a document on several different pages
            Geogeorger Level 1

            Rick

            Thank you so much for answering my issue.  I am trying to put an ordinal date phrase in several places in a document.

            The phrase which I can get to come into s document if I run the above script will insert "the 9th day of November, 2016" at the very top of the document on the first page in FrameMaker v12.  I need it to place the phrase throughout the document on multiple pages inside the document, usually the last page of the document.  I don't know how to move the phrase through the pages and on to the exact location I need it.  Unfortunately the place can change if I add or subtract a paragraph on a given page in the document.

             

            I am in central time here in Dallas Texas.  But will make time whenever you are willing.

            Thanks for your consideration