Historical LOG for 170 tags to SD card

Hello,

I want to write a script in BASIC to create a Historical Log for around 170 tags and save the file to the SD card as a CSV. I want it to update at an interval of one second (if the processor is fast enough) and at the end of the day create a new file. I would also like to lay the log out with the timestamp on the leftmost column and the following columns with each tag.

I have two issues I have been encountering:

Issue 1

I have been using the “HOW TO: Create a custom historical log file in BASIC” as reference and have been able to obtain a file logging for one tag that saves to the /usr directory but not to the SD card. Is there a way to create a blank file in the SD card and then append the file from the /usr location to the end of the file in the SD card?

Issue 2

Since I want to print all the tags on one line I initially used the PUT function in the following way:

OPEN fileName$ FOR BINARY APPEND AS 1

PUT 1, Time$ + STR$ tag1@ + STR$ tag2@ … + STR$ tag170@

However for 170 tags this is too long and does not fit on a line.

An idea I had was to write a for loop iterating and inserting the values of each tag with the GETIO function into an array which I can just insert into the PUT command after, but I had trouble adding these values to the array, (probably due to syntax). An array will also need to be created for the tag names to put in the title row of the file.

Any ideas and help will be much appreciated, my knowledge of BASIC is limited

I believe you would need to open and read the file in the USR then write each line over to the file on the SD card. There is not built in function to append a file to a file that I can think of.

The example here iterates though all the tags. You might be able to use that part of the scrip in your log script. https://forum.hms-networks.com/uploads/short-url/lw1zdnTFSprXHbqnzqNYA8xUsSB.pdf