On the topic of super simple file read examples, here is my code (heavily stolen from OptoMary) for reading a CSV file.
The kicker here is that I am using this code on SoftPac... Because it runs on the same PC as my Dropbox, it can see the C: drive data as its local file storage.
In this example I am using another service (http://ifttt.com) to write the csv text file, this code just reads it and puts it into a string table.
// check the dropbox for any files that may have come in from IFTTT.
// define 'file_dropbox' as the following in your strategy tree..... Or do it inline.... Your call...
setCommunicationHandleValue("file:r,C:\Dropbox\Ben\IFTTT\Data\csv.txt", file_dropbox) ;
ifttt_status = OpenOutgoingCommunication(file_dropbox);
if (ifttt_status == 0) then
//pull the contents of the file into a table.
ifttt_status = ReceiveStrTable(4, 0, csv_data_table, file_dropbox);
// Ok, we got the file contents, delete the file so IFTTT can make the same file next time.
ifttt_status = SendCommunicationHandleCommand(file_dropbox, "delete");
ifttt_status = CloseCommunication(file_dropbox);
I have this code in a chart that runs every 15 minutes.
I found that if you don't delete the file, a new file will be written with a different file number, so to keep things clean, I delete the file after I get the data.
Note that I have told the IFTTT recipe to call the file it creates 'csv.txt', that's where that name comes from.
I also told IFTTT to put a ',' between the data.