I need to use a customized heading to the data files uploaded to a FTP server, but somehow I cannot make the program work. I try to do it by first write the two header lines (variable names and units) I want to use to a local file on the datalogger (CR1000). When the time comes when data should be uploaded, I first check whether the file already exists on the FTP server (a new file every day is created) and, if not, the header file is copied to the FTP server with the new file name, then the data from the data table should be appended to that file. Somehow data is not appended, but instead the old content of the file (i.e. the header lines) is overwritten with the new lines, so only the new rows from the data table remain. Am I trying to do something impossible here, or just using the wrong method or coding? Here are the significant lines from the program I have tested:
Newfilename = DestPath + "SWE-ASA-NYB-FOR-F02_" + TStamp + ".dat" 'add file path and a fixed suffix for date
TableList=""
TableFileExist = FTPClient(ServerIP,User,Password,TableList,Newfilename,-7) ' List the file of the FTP ()
TableList = Left (TableList,20)
If TableList <> "SWE-ASA-NYB-FOR-F02_" Then
TableHeaderWrite = FTPClient(ServerIP,User,Password,"USR:Header_Asa",Newfilename,9)
EndIf
Send the file to the FTP ()SentOK = FTPClient(ServerIP,User,Password,"SWE_ASA_NYB_FOR_F02",Newfilename,2,0,SaveFTPInterval,hr,-1009)