Something like for n=1 to z : Array(n)=Stringfield(s,n,"|") : next n ?
I have implemented such a loop for copying dropped files into a listicon gadget, a string array or a list. Then I realized how slow this will be done, when some hundred files have been dropped on the gadget. The problem is, that the string has to be scanned hundreds of times, so a StringNextField(s,@position,"|") would be needed for sch cases.
So I changed the code to just scan the string to extract al fields what takes only very few moments. The following code is not complete as the drag and drop part is missing but it is simple to adapt it to your needs.
Code: Select all
Global File.s(0)
Global FileCount
Procedure DoDroppedFiles()
CompilerIf #PB_Compiler_Unicode
#CharByte=2
CompilerElse
#CharByte=1
CompilerEndIf
Protected n,p,z
Protected s.s,t.s
If EventDropAction()=#PB_Drag_Move
FileCount=0
EndIf
s=EventDropFiles()+#LF$
z=CountString(s,#LF$)
ReDim File(FileCount+z)
n=0
p=@s
Repeat
t=""
While PeekC(p)<>#LF
t+Chr(PeekC(p))
p+#CharByte
Wend
p+#CharByte
FileCount+1
File(FileCount)=t
n+1
Until n=z
EndProcedure