Copy link to clipboard
Copied
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
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();
}
Copy link to clipboard
Copied
You can use a loop to import row by row, stopping when you hit the value you're after.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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();
}
Copy link to clipboard
Copied
Thanks it worked!
Find more inspiration, events, and resources on the new Adobe Community
Explore Now