Jump to content

FIrst Try at External Data File


bkurzbuch

Recommended Posts

I'm trying for the first time to call out to a external data file and hit a syntax error i don't understand. It a Doctor provider list that I will need to eventually compare Longitude and latitude to pull in the 3 nearest Doctors. So the only 4 Variables I need out of the External File Are "Name", "Tel", "Long" and "Lat".

 

The Error is: Line 10 PROVIDER_DATA_FINAL is not defined.

 

P.S i know there is a proper why to post code, but using Safari I don't see the Go advanced button to put the code in a code block.

 

Thanks for the help

 

 

EDF_PROVIDER_DATA_FINAL = new ExternalDataFileEx("PROVIDER_DATA_FINAL.csv",",");

 

if (!EDF_PROVIDER_DATA_FINAL.valid) {

 

ReportError("PROVIDER_DATA_FINAL.csv not successfully loaded...");

}

 

for (var i = 1; i <= EDF_PROVIDER_DATA_FINAL.recordCount; i++) {

 

PROVIDER_DATA_FINAL[i - 1] = new PROVIDER_DATA_FINAL(

EDF_PROVIDER_DATA_FINAL.GetFieldValue(i,"LONG"),

EDF_PROVIDER_DATA_FINAL.GetFieldValue(i,"LAT"),

EDF_PROVIDER_DATA_FINAL.GetFieldValue(i,"NAME"),

EDF_PROVIDER_DATA_FINAL.GetFieldValue(i,"TEL"),

0);

}

Link to comment
Share on other sites

The problem is just as the error suggests: You haven't defined the "PROVIDER_DATA_FINAL" variable that you're referencing here (in red)

for (var i = 1; i <= EDF_PROVIDER_DATA_FINAL.recordCount; i++) {

[color="Red"]PROVIDER_DATA_FINAL[/color][i - 1] = new PROVIDER_DATA_FINAL(
EDF_PROVIDER_DATA_FINAL.GetFieldValue(i,"LONG"),
EDF_PROVIDER_DATA_FINAL.GetFieldValue(i,"LAT"),
EDF_PROVIDER_DATA_FINAL.GetFieldValue(i,"NAME"),
EDF_PROVIDER_DATA_FINAL.GetFieldValue(i,"TEL"),
0);
}

 

You can fix that by defining it:

[color="Red"]var PROVIDER_DATA_FINAL = [];[/color]

for (var i = 1; i <= EDF_PROVIDER_DATA_FINAL.recordCount; i++) {
PROVIDER_DATA_FINAL[i - 1] = new PROVIDER_DATA_FINAL(
EDF_PROVIDER_DATA_FINAL.GetFieldValue(i,"LONG"),
EDF_PROVIDER_DATA_FINAL.GetFieldValue(i,"LAT"),
EDF_PROVIDER_DATA_FINAL.GetFieldValue(i,"NAME"),
EDF_PROVIDER_DATA_FINAL.GetFieldValue(i,"TEL"),
0);
}

 

But I don't think that's going to help you very much because that entire block of code doesn't make much sense. I think what you want to do is something like this:

EDF_PROVIDER_DATA_FINAL = new ExternalDataFileEx("PROVIDER_DATA_FINAL.csv",",");
if (!EDF_PROVIDER_DATA_FINAL.valid)
   ReportError("PROVIDER_DATA_FINAL.csv not successfully loaded...");

var fields = ['LONG','LAT','NAME','TEL'];
for (var i in fields)
   FusionPro.Composition.AddVariable(fields[i], 
       EDF_PROVIDER_DATA_FINAL.GetFieldValue(FusionPro.Composition.inputRecordNumber, fields[i]));

 

There are also plenty of threads on this forum that relate to External Data that you might find helpful:

http://forums.pti.com/search.php?searchid=900608

Link to comment
Share on other sites

P.S i know there is a proper why to post code, but using Safari I don't see the Go advanced button to put the code in a code block.

The "Go Advanced" button shows only in the "Quick Reply" area when you are viewing an existing thread.

 

When you create a new thread, or click on the Reply or Quote buttons for an existing thread instead of using "Quick Reply", and you see the two buttons "Submit Reply" and "Preview Post", then you already have the Advanced toolbar, which looks like this:

 

http://forums.pti.com/attachment.php?attachmentid=1343&stc=1&d=1445295361

 

The # button (third from the right on the bottom row) is the one that does Code blocks. Select all of your code and click that button.

 

You can do all sorts of other neat stuff with that Advanced toolbar, such as embedding a picture (like above in my post).

 

The "Preview Post" is good to use as well, just to make sure your post is what you want before submitting it.

vBulletinAdvanced.jpg.ab6d7cfa1683f48a1f8b12caa61687ee.jpg

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...