Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Pulling information from specific row using importTextData

Community Beginner ,
Dec 19, 2017 Dec 19, 2017

Hello,

I am trying to fill out fields in a form by selecting a certain row in a text file. My javascript is

if (typeof cnt == "undefined") cnt = 0;

importTextData("/C/Users/Desktop/Barcodes/filename.txt", 3)

With the above code i am able to fill out my form using information from the 3rd row in the text file. What i would like to do is fill out information based on the value of the first column. For instance, my text file looks like this

F. Name   Gender    email

Jon               M          test@testing.com

Victoria         F           sample@testing.com

Tom              M          test123@testing.com

I would like to import the data based on the value of column one. So if column one equaled "Tom" import that row.

Is this possible?

Thanks

TOPICS
Acrobat SDK and JavaScript , Windows
597
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Dec 19, 2017 Dec 19, 2017

You can use something like this:

var result = 0;

var cnt = 0;

while (result==0) {

    result = this.importTextData("/C/Users/Desktop/Barcodes/filename.txt", cnt);

    if (this.getField("Name").valueAsString=="Tom") break;

    cnt++;

}

if (result!=0) {

     app.alert("Error!");

     this.resetForm();

}

Translate
Community Expert ,
Dec 19, 2017 Dec 19, 2017

You can use a loop to import row by row, stopping when you hit the value you're after.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 19, 2017 Dec 19, 2017

Hmm... how would i implement a while loop into this.

I essentially would like to import text data if F.Name[] == "Tom" in this case. 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 19, 2017 Dec 19, 2017

You can use something like this:

var result = 0;

var cnt = 0;

while (result==0) {

    result = this.importTextData("/C/Users/Desktop/Barcodes/filename.txt", cnt);

    if (this.getField("Name").valueAsString=="Tom") break;

    cnt++;

}

if (result!=0) {

     app.alert("Error!");

     this.resetForm();

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 19, 2017 Dec 19, 2017
LATEST

Thanks it worked!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines