How to FTP multiple string table


#1

Hi all,

I can save multiple string table on a SD card, but how can I FTP the same string tables in a separate file? I can FTP one string table.
Currently I have 4 string tables sDataA,sDataB,sDataC, and sDataD and use blocks to send them to SD card using separate file handles for each of them.
my query is how can i ftp the same tables. should I create 4 different ftp file handles? is it possible to do in blocks or should i used script?
I currently can send one string table visa script example. see code below:

Day = GetDay();Year = GetYear();Month = GetMonth();
NumberToString(Day, sJday);NumberToString(Month, sMonth);
NumberToString(Year, sYear);
sDateAdded = sJDay + "_" + sMonth + "_" + sYear;
nCommStatus = OpenOutgoingCommunication( sFTPSERVER );
if (nCommStatus == 0) then
  //Option 1: Construct command that opens a new or existing file on the FTP server  sSendFile = "dest:/DataLog_" + sDateAdded +".csv";  
nCommStatus2 = SendCommunicationHandleCommand( sFTPSERVER , sSendFile );
  //Option 2: dynamic file name but directory must be created  //
sSendFile = "dest:/" + sMonth + "/DataLog_" + sJday + ".txt";  /
/nCommStatus2 = SendCommunicationHandleCommand( ch_FtpServer , sSendFile );
if (nCommStatus2 == 0) then//  Transmit table     
           nCommStatus3 = TransmitStrTable( nTableMax , 0, sTestTable, sFTPSERVER );    
 if (nCommStatus3 == 0) then      
    sMessage = "File sent to FTP site";     
 else      
        sMessage = "Tranmitting failed";    
  endif    
       else    sMessage = "Destination command failed";   
 endif  
      else  
       sMessage = "Opening communication failed";
endif
       CloseCommunication( sFTPSERVER );

can someone please show me the example for ftping multiple file


#2

This is difficult to read, code style recommendations:

Change the prefixes to match the date type:
sFTPSERVER -> chFTPSERVER
sTestTable -> stTestTable

Remove the code that doesn’t do anything, such as the sYear and sDateAdded - these are never used in your code.

Add spacing and fix indentation so the code blocks line up.

Also, you are assigning a value to sSendFile AFTER you sent the Send Communication Handle Command, this is probably a bug in your code.

To answer your question, you should be able to repeat the Send Communication Handle Command with a new name and call TransmitStrTable with the next table for each of your string tables. Leave the comm handle open until all four are sent.


#3

Here is the basic idea, haven’t tested this though. I removed the status checks (which are a good thing to have), to make the code more readable here:

Day = GetDay();Month = GetMonth();


NumberToString(Day, sJday);
NumberToString(Month, sMonth);


OpenOutgoingCommunication( chFTPSERVER );


//File DataLogA
sSendFile = "dest:/" + sMonth + "/DataLogA_" + sJday + ".txt";
SendCommunicationHandleCommand( sFTPSERVER , sSendFile );
TransmitStrTable( nTableMax , 0, stDataA, chFTPSERVER );    


//File DataLogB
sSendFile = "dest:/" + sMonth + "/DataLogB_" + sJday + ".txt";
SendCommunicationHandleCommand( sFTPSERVER , sSendFile );
TransmitStrTable( nTableMax , 0, stDataB, chFTPSERVER );    


CloseCommunication( chFTPSERVER );

#4

thanks a lot…I will check this one… !!