Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help with array
#1
Woefully simple question but still not quite grasping it:

How can I get the list resulting from enumerating the files of a directory into a single string (each separated by [] preferably)

enumerate directory:
Macro
Code:
Copy      Help
Dir d
foreach(d "$Desktop$\enum\*.*" FE_Dir)
,str sPath=d.FileName(1)
,out sPath
,

Also, how can I incorporate a directory enumeration into the following code (for uploading all files in a directory via ftp) instead of Open/Save dig?

Macro
Code:
Copy      Help
Ftp f.Connect(fserver uname pword); f.Disconnect
ARRAY(str) a; int i
if OpenSaveDialog(0 0 "" "" 0 "" 0 a)
,for(i 0 a.len)
,,out a[i]
,,if(!f.DirSet(remotedir)) mes- "FTP error: DirSet failed."
,,if(!f.FilePutWithProgress(a[i])) mes- "FTP error: HTML file upload failed."

Thanks!
#2
I'm sure there is a bit better way to do this...but it'll do the the trick here...

Function Function3
Code:
Copy      Help
out
Dir d
foreach(d "$Desktop$\enum\*.*" FE_Dir)
,str sPath=d.FileName(1)
,_s.format("%s%s[91][93]" _s sPath)
out _s
;remove the last []
strrev _s
_s.remove(0 2)
strrev _s
out _s
_s=""


foreach(d "$Desktop$\enum\*.*" FE_Dir)
,sPath=d.FileName(1)
,_s.format("%s%s[]" _s sPath)
;remove the last []
strrev _s
_s.remove(0 2)
strrev _s

out _s
#3
Thanks man, works for me!

S


Forum Jump:


Users browsing this thread: 1 Guest(s)