for line in fh11:lines() do while true do if downloadSongWorking == 0 then print(line) downloadSongWorking = 1 g\_downloadpathline = "http://www..." g\_new\_folder\_pathline = g\_new\_folder\_path g\_txtallline = row.id .. "/" .. line print("DOWNLine" .. g\_downloadpathline ) print("newfolderline" .. g\_new\_folder\_pathline ) print("g\_txtallline" .. g\_txtallline ) network.download( g\_downloadpathline, "GET", networkListener4, g\_txtallline, g\_new\_folder\_pathline) tryCount4 = tryCount4 + 1 print(tryCount4) break end end end
The code is working when the while true loop doesn’t exist. I want to put the while true loop there to make the network.download command to start and work one by one. The downloadSongWorking bit is being cleared in the network listener function. But when I check with the debugger, and I put a breakpoint in network listener function, I see that the program can’t arrive at the listener function never.
I guess I’m having issues with why you have that while loop there. Your creating an infinite loop inside the for loop that you skip some times… Are you trying to download the songs one after the other? Where do you ever set downloadSongWorking to 0 to even get into the if statement?
I guess I’m having issues with why you have that while loop there. Your creating an infinite loop inside the for loop that you skip some times… Are you trying to download the songs one after the other? Where do you ever set downloadSongWorking to 0 to even get into the if statement?
If you want to download one after another, why don’t you make a queue table with the params for each network.download call?
That way, you can create a recursive function that is called everytime a download completes and what it does is start the next network.download data that is inside your queue table.
Because your while(true) is probably blocking all the rest of the app and that way, you will not block the app because it only runs after each download has been completed (or canceled if you want that too).
If you want to download one after another, why don’t you make a queue table with the params for each network.download call?
That way, you can create a recursive function that is called everytime a download completes and what it does is start the next network.download data that is inside your queue table.
Because your while(true) is probably blocking all the rest of the app and that way, you will not block the app because it only runs after each download has been completed (or canceled if you want that too).