Here I'm passing the skipfolders variable in input if the skipfolders is true then it prints all files from Parent path and skip the sub folders. otherwise it returns all files from all folders include sub folders as well. Here I wrote if-else conditions. When I execute this code in FileMaker it executes without any errors and displayed result.but the if-else conditions does't working here.
Problem :
If-else conditions doesn't working here.it prints all files from FTP include subfolders.skipfolders condition doesn't working. at this return allFiles.join('\n') + '\n'+ allFolderFiles.join('\n')+ '\n' prints directly and skipfolders condition doesn't working. Please help how to use if-else conditions properly in fileMaker groovy.
start()
def start(){
boolean skipfolders = false
def store;
def ftpClient = new FTPClient()
ftpClient.connect(server)
// println(ftpClient.replyString)
ftpClient.login(user,pass)
ftpClient.enterLocalPassiveMode()
FTPFile[] fileslist = ftpClient.listFiles("/")
FTPFile[] folderfileslist = ftpClient.listFiles("/sample")
if(skipfolders == false){
def allFiles = [];
for(int i=0; i<fileslist.length; i++){
String file_name = fileslist[i].getName()
String file_timestamp = fileslist[i].getTimestamp().getTime()
String s = '|' + file_name+ '|' + '/' +file_name+'|' +file_timestamp
allFiles << s
}
def allFolderFiles = [];
for(int i=0; i<folderfileslist.length; i++){
String folderfile_name = folderfileslist[i].getName()
String folderfile_timestamp = folderfileslist[i].getTimestamp().getTime()
String s1 = '|' +folderfile_name+ '|' + '/sample' +'|'+folderfile_name+'|' +folderfile_timestamp
allFolderFiles << s1
}
ftpClient.disconnect()
return allFiles.join('\n') + '\n'+ allFolderFiles.join('\n')+ '\n'
}
else{
def allFiles = [];
for(int i=0; i<fileslist.length; i++){
String file_name = fileslist[i].getName()
String file_timestamp = fileslist[i].getTimestamp().getTime()
String s = '|' + file_name+ '|' + '/' +file_name+'|' +file_timestamp
allFiles << s
}
ftpClient.disconnect()
return allFiles.enter code herejoin('\n')
}
}
enter code here
if anybody having idea please let me know thanks.