FTP: Creating a systematic directory with SyncFile function

Discussions about syncing data via Bluetooth, Dropbox, FTP, and using CSWeb
Post Reply
MarcOlivier
Posts: 13
Joined: November 20th, 2016, 5:54 am

FTP: Creating a systematic directory with SyncFile function

Post by MarcOlivier »

Hi everyone!
I'm facing a challenge in writing a code to create directory with SynvFile function
I would like in the directory it have been a folder named using the Date and time when the synchronization is made.
I think this was possible with de PNC file (%DateTime) so I wrote a similar code as bellow:

function SyncENQ1AvecQG()
if syncconnect(FTP,URLServer,Username,Pass) then
syncfile(PUT, "../App_Gouv/Gouvernance_MIC.csdb",
"/%Data_serveurENQ1%/%DateTime%/Gouvernance_MIC.csdb");

Buuut It doesn't work :(
I juste have a directory as : Data_serveurENQ1 ==> DateTime
instead of Data_serveurENQ1 ==> 060320191233 (for example)

What is wrong in my code ?
MarcOlivier
Posts: 13
Joined: November 20th, 2016, 5:54 am

Re: FTP: Creating a systematic directory with SyncFile function

Post by MarcOlivier »

Hello Everyone

We (my colleague and I) have found a way to overcome the matter.

We have first create variables to get systematically date and hour in string format using edit() and sysdate() function. After we created an alphanum variable which is the concatenation of date and time making sure that /%; %/ symbols are at their rigth places. Then we use this alphanum from the concatenation as the to_path argument in the syncfile() function.

Maybe there exist a better way to do.
Opned to any other suggestions
Thanks
aaronw
Posts: 564
Joined: June 9th, 2016, 9:38 am
Location: Washington, DC

Re: FTP: Creating a systematic directory with SyncFile function

Post by aaronw »

Here's an example with sysdate and systime:
if syncfile(PUT, "/icon.png", edit("99999999", sysdate("YYYYDDMM")) + edit("9999", systime("HHMM")) + "/icon.png") then
However, if I just need a unique folder name, I prefer timestamp. If necessary I can always convert back to datetime:
if syncfile(PUT, "/icon.png", maketext("%d", timestamp()) + "/icon.png") then
MarcOlivier
Posts: 13
Joined: November 20th, 2016, 5:54 am

Re: FTP: Creating a systematic directory with SyncFile function

Post by MarcOlivier »

Thank very much Aaronw for the input
I will try right now
Post Reply