Skip to main content
BEGINNER_X
Legend
August 1, 2013
Answered

Problem in Creating .txt report

  • August 1, 2013
  • 2 replies
  • 747 views

Hi All,

I need to create the report, if the document having fpo, $$$, TK, 000 etc...

OR,

create report "No Errors found"

My script working fine, but the problem is creating the report not as user friendly

Coding is below:

myDoc = app.activeDocument;

FPOArray = new Array

app.findTextPreferences = app.changeTextPreferences = NothingEnum.nothing;

app.findChangeTextOptions.wholeWord = true

app.findTextPreferences.findWhat = "fpo"

var myFound = myDoc.findText()

for (f = 0; f < myFound.length; f++) {

    var myFindFPOPage = myFound.parentTextFrames[0].parentPage.name

    FPOArray.push(myFindFPOPage)

}

$$Array = new Array

app.findGrepPreferences = app.changeGrepPreferences = NothingEnum.nothing;

app.findGrepPreferences.findWhat = "\\$\\$+"

var myFound = myDoc.findGrep()

for (s = 0; s < myFound.length; s++) {

    var myFind$$$Page = myFound.parentTextFrames[0].parentPage.name

    $$Array.push(myFind$$$Page)

}

var myTextFile = File("~/Desktop/abcde.txt")

myTextFile.open("w")

if(myFound.length>0)

{

    myTextFile.write("FPO: " + FPOArray + "\n\n"  + "$$ Page Number: " + $$Array + "\n\n")           //Error this line only please help

    }

else

{

    myTextFile.write("No Error")

    }

Could anyone please help for my request.

Thanks in advance

Beginner_X

This topic has been closed for replies.
Correct answer Mac_rk

u change

myTextFile.open("e") and than

if(myFound.length>0)
{
    myTextFile.write("FPO: " + FPOArray + "\n\n" )           //Error this line only please help
    }

if(myFound1.length>0)
{
    myTextFile.write(
"$$ Page Number: " + $$Array + "\n\n")           //Error this line only please help
    }

else
{
    myTextFile.write("No Error")
    }

2 replies

Mac_rkCorrect answer
Participating Frequently
August 1, 2013

u change

myTextFile.open("e") and than

if(myFound.length>0)
{
    myTextFile.write("FPO: " + FPOArray + "\n\n" )           //Error this line only please help
    }

if(myFound1.length>0)
{
    myTextFile.write(
"$$ Page Number: " + $$Array + "\n\n")           //Error this line only please help
    }

else
{
    myTextFile.write("No Error")
    }

BEGINNER_X
Legend
August 1, 2013

Hi Mac_rk,

Thank you for your help...

I think recently you entered into forum and guide lot of beginners like me.

Hope you also join with the group of forum legends.

Thanks a lot again.

Beginner

Participating Frequently
August 1, 2013

In both find u give myFound var so in second find if it not found than it override the myFound value and it not satified ur condition

try change one var to  myFound1 and change if((myFound.length>0)  || (myFound1.length>0)) and try


BEGINNER_X
Legend
August 1, 2013

Hi Mac_rk,

Thank you for your Tips,

But still I need to tuned. Suppose in my active document having only "$$" only, but do not have FPO, TK, AU etc...

But my report comes like as below:

 

FPO:

$$ Page Number: 5

TK:

AU:

But I need as below:

$$ Page Number: 5                 //required output

Is it possible. Could you help for my request.

Thanks

Beginner