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";
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 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.
any insight or help with this would be immensely appreciated.