Get update data when loop running

Hi everyone
i use loop ( for…next ) to list item in folder
and get page count of pdf by shell command “kMDItemNumberOfPages”
But some result ( arbitrary ) return “null”… Not the same file twice
I’v try “app.SleepCurrentThread(100)” to slow down
Work partially…( less faulty )
I hope is not the right way ( slow down my app )
Same thing when i want to get count file one by one ( it update only when its finished )

[quote=211104:@Denis Despres]Hi everyone
i use loop ( for…next ) to list item in folder
and get page count of pdf by shell command “kMDItemNumberOfPages”
But some result ( arbitrary ) return “null”… Not the same file twice
I’v try “app.SleepCurrentThread(100)” to slow down
Work partially…( less faulty )
I hope is not the right way ( slow down my app )
Same thing when i want to get count file one by one ( it update only when its finished )[/quote]

Is your shell mode zero ?

i guess not
I don’t know what is shell mode
And how set it

ok…synchro or async
0 or 1 that i need ?

dont understand how use “shell.DataAvailable”

Ok i’v created a shell class “shell1” and this is my loop

[code] Dim i As Integer
Dim pdfpath As String

for i = 0 to kountItem-1
pdfpath = Listboxfilez.Cell(i,3)
Shell1.Execute "mdls -name kMDItemNumberOfPages -raw " + pdfpath
shell1.poll
Next[/code]
And thats what i’v type in DataAvaileble

Datacollect.Append shell1.ReadAll

Seems to collect nothing
Thanks to guide me to right direction

[quote=211118:@Denis Despres]i guess not
I don’t know what is shell mode
And how set it

ok…synchro or async
0 or 1 that i need ?

dont understand how use “shell.DataAvailable”[/quote]

By default the shell is mode zero, synchronous. It should not lose data in that mode.

I believe you got mixed up in the way the shell works, mixing poll and ReadAll that are usually reserved to modes 1 and 2. In mode 0 DataAvailable simply does not fire.

Maybe time to do something much simpler :

[code]Dim i As Integer
Dim pdfpath As String

for i = 0 to kountItem-1
pdfpath = Listboxfilez.Cell(i,3)
Shell1.Execute "mdls -name kMDItemNumberOfPages -raw " + pdfpath
Datacollect.Append shell1.Result
Next[/code]

i’m not so far
My shell mode is 1 Async

Just weird that
when i place “Datacollect.Append shell1.Result” directly in my loop… it fill the array perfectly
BUT if i place same code in DataAvailable… My array contain only the last data
any idea

[quote=211145:@Denis Despres]i’m not so far
My shell mode is 1 Async

Just weird that
when i place “Datacollect.Append shell1.Result” directly in my loop… it fill the array perfectly
BUT if i place same code in DataAvailable… My array contain only the last data
any idea[/quote]

Use my code and Mode zero. It will run synchronous and you will not need your cumbersome pauses.

Dim i As Integer Dim pdfpath As String Shell1.Mode = 0 for i = 0 to kountItem-1 pdfpath = Listboxfilez.Cell(i,3) Shell1.Execute "mdls -name kMDItemNumberOfPages -raw " + pdfpath Datacollect.Append shell1.Result Next

Hi Michel
Still same problem with your code
Some data return Nul ( randomly not same file twice )
I must try ( and understand ) Asynchro mode
thanks

It’s worst in mode 1
If i “Break” inside my loop
i can see each data Append in my array
BUT with no break…
The array contain only the last data

ok problem fixed
Your code + data control + ( re-do until all data IsNumeric )
Thanks