Newbie Question / remove file

Thanks for your answer. As soon as I get home I’ll upload the code.

If you want the photo to be deleted on back button press then you need to include the deletion code in the back button event. You posted…

local result, reason = os.remove( system.pathForFile( "Picture1.jpg", destDir ) )

but that will only ever delete Picture1.jpg

@wellison.maceio @adrianm
I’ll be uploading the full code on Friday when I get home.

hi,
I’ve read and reread the composer and scope topics a few times now. I don’t see anything vague, it’s seems very clear what happens and when, however, when I move buttons or text inside or outside the create/show functions, they don’t always operate the same. it’s crazy I have been struggling with this for over a week. I don’t see how the below can possibly work in any programming language…  the code below:

if (myDataTable[row.index] ~= nil) then

    local rowText = display.newText(row, myDataTable[row.index], 70, rowTitle.y, nill, 14 )

    rowText:setFillColor(0)

    sceneGroup:insert(rowText)

    count = count + 2

    print(" count = " … tostring(count))

end

yields this in the monitor/log window:

13:12:01.966   count = 2

13:12:01.976   count = 2

13:12:01.987   count = 2

13:12:01.998   count = 2

13:12:02.010   count = 2

13:12:02.030   count = 2

13:12:02.030   count = 2

13:12:02.045   count = 2

13:12:02.056   count = 2

13:12:02.078   count = 2

13:12:02.088   count = 2

13:12:02.098   count = 2

13:12:02.119   count = 2

thanks in advance for some clarity in this…  daveC

I meant to say, I don’t see how that code can’t work, increment the var count, no matter what programming language is used…

What happened here guys?
I’m confused.

Let me step in for a second. @dodi_games, it appears that @davidjcantera has posted an unrelated question/topic to your thread instead of posting to a new thread, or perhaps he was intending on replying to a different thread and accidentally posted in your thread. In Forum “lingo” this is called “Hijacking a thread” and is against the rules because it does cause confusion.  @davidjcantera, it would be helpful if you posted your question either in a new thread or if you were replying to a different thread, restate  your post there. I know you want answers and people are not going to be looking in this thread to talk about scope/tableview questions.

@dodi_games, back you the issue at hand. When you capture a new photo, we have to give it a unique name, which is why your photo number is increasing.  

If I were you, I would implement LFS and get a listing of all the files in the directory and then you can use os.remove() to remove them once you know their names. The first example in the LFS docs “Traverse a Directory” basically is the code you need. The example only prints out the file name, but you could do an 

os.remove( file )

where the print is. Now as a safety, there may be files there you don’t want to delete, so you might want to use a string.* API to try and match a pattern like Picture*.jpg. There are many different way’s to use different string.* API’s to match the string.

Rob