delete file from specialfolder(solved)

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
vedus
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 153
Joined: Tue Feb 26, 2013 9:23 am

delete file from specialfolder(solved)

Post by vedus » Fri Aug 29, 2014 3:05 pm

i am try to delete html file from specialfolder documents is that possible for android or ios?
here is my code.

Code: Select all

Global browserID
Global theURL
global tTitles
global thedata


on preopencard
      # quit if we are not on a mobile device
      if the environment is not "mobile" then exit preopencard
  
  #current location
  wait 1 seconds
  put mobileCurrentLocation() into tLocation
  put tLocation["latitude"] into fld "Dlat" 
  put tLocation["longitude"] into fld "Dlong" 
  put fld"Dlat"& comma & fld"Dlong" into lat1
  put lat1 into lat_lng
  delete variable lat1

  if fld "lat" is empty then
    answer error "No Gps Data"
  end if
  
  #Store Location 
  put fld"lat"& comma & fld"long" into Store1
  put store1 into Store_lng
  delete variable store1
  if store_lng is empty then
    Answer "This mobile is NOT able to track GPS location"
  end if
    
  put specialFolderPath("documents") & "/navi2.html" into documentFilePath
       if there is not a file documentFilePath then
              put specialFolderPath("engine") & "/navi2.html" into engineFilePath
              put URL ("binfile:" & engineFilePath) into URL ("binfile:" & documentFilePath)
       end if
  
  put specialFolderPath("documents") & "/navi2.html" into thehtmlFile
          put URL("file:" & thehtmlFile) into theData
          
  put "var origin1 = new google.maps.LatLng(" & lat_lng & ");" into line 30 of theData
  put "var destinationA = new google.maps.LatLng(" & Store_lng & ");" into line 31 of theData
  put "zoom:17," into line 37 of theData
  
  put theData into URL ("file:" & thehtmlFile)
    put "file://" & specialFolderPath("documents") & "/navi2.html" into theURL
          replace space with "%20" in theURL
  answer theurl

end preOpenCard
Last edited by vedus on Tue Sep 02, 2014 2:24 pm, edited 1 time in total.

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: delete file from specialfolder

Post by Mark » Fri Aug 29, 2014 3:21 pm

Hi,

The command "wait 1 seconds" doesn't do anything. This will probably be more effective:

Code: Select all

on preOpencard
      # quit if we are not on a mobile device
     if the environment is not "mobile" then exit preopencard
     send "continuePreOpencard" to me in 0 millisecs
end preOpenCard

on continuePreOpenCard
  -- remainder of your script
end continuePreOpenCard
If you think you need to wait a second to update the location for instance, then use

send "continuePreOpencard" to me in 1000 millisecs

There's a good chance that you can use less than 1000 millisecs, e.g. 250 millisecs, which would probably improve user experience.

You script doesn't contain a delete file command. Use the following syntax to delete your HTML file:

Code: Select all

delete file documentFilePath
Note that you can delete files from the documents folder but not from the engine folder.

Kind regards,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

vedus
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 153
Joined: Tue Feb 26, 2013 9:23 am

Re: delete file from specialfolder(solved)

Post by vedus » Tue Sep 02, 2014 2:24 pm

the results after Mark

Code: Select all

delete URL("file:" & thehtmlFile) 

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: delete file from specialfolder(solved)

Post by Mark » Tue Sep 02, 2014 2:29 pm

Hi,

I don't understand what you want with your last message.

Earlier I wrote you can't delete a URL, but actually you can. The problem was that your original script didn't contain a delete file or delete URL command, while it contained a delete variable command.

Has your problem been solved now?

Kind regards,

Mark
Last edited by Mark on Tue Sep 02, 2014 2:33 pm, edited 1 time in total.
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

vedus
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 153
Joined: Tue Feb 26, 2013 9:23 am

Re: delete file from specialfolder(solved)

Post by vedus » Tue Sep 02, 2014 2:32 pm

Mark wrote:Hi,

I don't understand what you want with your last message.

Earlier I wrote you can't delete a URL, but actually you can.

Kind regards,

Mark
sorry mark i just post the answer after your help with the above code.. ;)

Post Reply