I have been having problems for the past month with my update button of a certain browser. I have successfully been able to view my browser which is a html file, but when I tried to update within the app, it doesn't do anything with it. I am not sure if my coding has any problems but to no avail, I have not been able to make the update work. This is my coding.
on touchEnd pId
mobGUIUntouch the long id of me
# LC5 : new visual effect syntax
#lock screen for visual effect
#go card "yourCard"
#go prev card
#go next card
#wait for 0 millisecs with messages
#unlock screen with visual effect "push left very fast"
end touchEnd
on touchRelease pId
mobGUIUntouch the long id of me
end touchRelease
on touchStart pId
mobGUITouch the long id of me
end touchStart
on mouseUp
if the environment = "development" then touchEnd 1
local tURL, tFile
get url "http://intimes.eu.pn/docupdate.php"
put it into field"fieldA"
replace"[" with "" in field "fieldA"
replace "]" with "" in field"fieldA"
set itemdelimiter to ","
put item 1 of field "fieldA" into Pvalue
put item 2 of field"fieldA" into Cvalue
get char 2 of Pvalue
put it into U1
get char 3 of Cvalue
put it into U2
put "intimes.eu.pn/doc.php?p=", U2 into updateURL
replace "," with "" updateURL
put "Starting.." into field "fldUpdate"
put "p", U2, ".html" into tFile
replace "," with "" tFile
put updateURL into tURL
put "Updating.." into field "fldUpdate"
libURLDownloadToFile tURL , ("Content/" & tFile), "Done"
answer tfile
wait 3 seconds
answer tURL
put "Done!" into field "fldUpdate"
answer "Update Complete!"
end mouseUp
on mouseRelease
if the environment = "development" then touchRelease 1
end mouseRelease
on mouseDown
if the environment = "development" then touchStart 1
end mouseDown
This is my final year project and it's going to be due soon. Please help me! Thanks!
Your code confused me and is somewhat inefficient e.g. what is U1 for? Why are you putting text into fields and not variables?
I've re-written it the way I would do it (but I've left in the things that confuse me . This works in the IDE - not tried it on mobile.
Not sure why you were downloading the file - it's text so why not just grab it and write it to a new file in your target directory on the device? BTW you must create your directories in the Documents folder - you'll see I've set the correct path for that in the writehtmlfile handler.
on writehtmlfile fileTowrite,dataTowrite
set the defaultFolder to (specialFolderPath("Documents") &"/Content")
put dataTowrite into URL (("file:"&fileTowrite&".html"))
end writehtmlfile
on mouseUp
local tURL, tFile
get url "http://intimes.eu.pn/docupdate.php"
put it into field 1
replace"[" with "" in field 1
replace "]" with "" in field 1
set itemdelimiter to ","
put item 1 of field 1 into Pvalue
put item 2 of field 1 into Cvalue
get char 2 of Pvalue
put it into U1
get char 3 of Cvalue
put it into U2
put "p" & U2 into tFile
replace "," with "" in tFile
put "http://intimes.eu.pn/doc.php?p=" & U2 into updateURL
put url updateURL into theHtml
writehtmlfile tFile,theHtml
end mouseUp
Good luck!
Gerry
14" MacBook Pro
Former LiveCode developer.
Now recovering.
I changed the codes and it still doesn't update the html file. Also, it changes the label of my navigation bar to the url of "http://intimes.eu.pn/docupdate.php".
You are trying to replace a file that is bundled in the app? Why didn't you say before? That is NOT possible - Apple does not allow apps to be modified while they are running. But if your copy all those files to the Documents folder the first time your app runs then my solution will work. The Documents folder is created outside the app bundle.
Gerry
14" MacBook Pro
Former LiveCode developer.
Now recovering.
How do I copy these files to the documents folder first? I really need to update the html files when needed. only those that are for e.g "p7.html","p1.html", which means only the number would be changing only. Thank you so much for helping me.
TKYTKY wrote:How do I copy these files to the documents folder first? I really need to update the html files when needed. only those that are for e.g "p7.html","p1.html", which means only the number would be changing only. Thank you so much for helping me.
It's very late here. I'll post an example script in the morning.
Gerry
14" MacBook Pro
Former LiveCode developer.
Now recovering.
TKYTKY wrote:How do I copy these files to the documents folder first? I really need to update the html files when needed. only those that are for e.g "p7.html","p1.html", which means only the number would be changing only. Thank you so much for helping me.
For each file do this the FIRST time your app opens on the device:
on openstack
if there is not a file (specialFolderPath("Documents") & "/Contents/index.html") then -- no files installed yet, so copy them from the engine
-- html files
put (specialFolderPath("engine") & "/Content/p1.html") into filePath
put url ("binfile:" & filePath) into destFilePath
put destFilePath into url ("binfile:"& (specialFolderPath("Documents") & "/Content/p1.html"))
put (specialFolderPath("engine") & "/Content/p2.html") into filePath
put url ("binfile:" & filePath) into destFilePath
put destFilePath into url ("binfile:"& (specialFolderPath("Documents") & "/Content/p2.html"))
-- image files
put (specialFolderPath("engine") & "Content/images/image1.jpg") into filePath
put url ("binfile:" & filePath) into destFilePath
put destFilePath into url ("binfile:"& (specialFolderPath("Documents") & "Content/images/image1.jpg"))
end if
end openstack
Do that for each file. This is a brute force method - you could also use a repeat loop for the p*.html files.
Good luck.
Gerry
14" MacBook Pro
Former LiveCode developer.
Now recovering.
Hmm, I dun get it. Do I need to get the app on my phone to test it? Or it should work fine on the simulator? I can't get it replaced after putting that script on the card.
TKYTKY wrote:Hmm, I dun get it. Do I need to get the app on my phone to test it? Or it should work fine on the simulator? I can't get it replaced after putting that script on the card.
That will work on the simulator too. It'll copy the files to the Documents folder on the simulator. if you reset the simulator of course they will be deleted and next time to install the app on the simulator it'll create the files and folders again, using the original files.
Gerry
14" MacBook Pro
Former LiveCode developer.
Now recovering.