Page 3 of 4

Re: Problem with updating HTML files in LiveCode

Posted: Thu Dec 05, 2013 3:56 am
by Simon
Again,
"the files" used with a repeat loop.

Show me what you have tried.

Simon

Re: Problem with updating HTML files in LiveCode

Posted: Thu Dec 05, 2013 3:58 am
by Jellicle
This might be of help: you zip the folder and then copy it from the engine to the device and unzip it.

Someone's done something similar:

http://mail.runrev.com/forums/viewtopic ... 137#p69829

Gerry

Re: Problem with updating HTML files in LiveCode

Posted: Thu Dec 05, 2013 5:04 am
by TKYTKY

Code: Select all

repeat with n = 1 to 11
    put (specialFolderPath("engine") & "/Content/p"&n&".html") into filePath
    put url ("binfile:" & filePath) into destFilePath
    put destFilePath into url ("binfile:"& (specialFolderPath("Documents") & "/Contents/p"&n&".html")) 
end repeat 
this is my code for the files to be copied into the documents folder of "Contents"

Re: Problem with updating HTML files in LiveCode

Posted: Thu Dec 05, 2013 5:18 am
by Jellicle

Code: Select all

repeat with n = 1 to 11
    put (specialFolderPath("engine") & "/Content/p"&n&".html") into filePath
    put url ("binfile:" & filePath) into destFilePath
    put destFilePath into url ("binfile:"& (specialFolderPath("Documents") & "/Contents/p"&n&".html")) 
end repeat
In the first line you use "Content". In the last line you use "Contents".

Gerry

Re: Problem with updating HTML files in LiveCode

Posted: Thu Dec 05, 2013 5:33 am
by TKYTKY
Because in the engine folder the folder is named "Content" and in the Documents folder it's named as "Contents"

Re: Problem with updating HTML files in LiveCode

Posted: Thu Dec 05, 2013 6:02 am
by Simon
html files are not binary files, so just "file:"
Images are "binfiles:"

also

put the files into tLotsOfFiles
repeat with x = 1 to the number of lines in tLotsOfFiles
put line x of tLotsOfFiles into tFileName

Now can you see how to use tFileName to copy the files?

Simon

Re: Problem with updating HTML files in LiveCode

Posted: Thu Dec 05, 2013 6:12 am
by TKYTKY
I guess, I'll do it with the zip portion. Should be able to work fine for me. (: I will try it now. Thanks to all of you, Klaus, Simon and Gerry! :)

Jeremy

Re: Problem with updating HTML files in LiveCode

Posted: Thu Dec 05, 2013 6:24 am
by TKYTKY
Simon wrote:html files are not binary files, so just "file:"
Images are "binfiles:"

also

put the files into tLotsOfFiles
repeat with x = 1 to the number of lines in tLotsOfFiles
put line x of tLotsOfFiles into tFileName

Now can you see how to use tFileName to copy the files?

Simon
Not sure about your codes here but I tried doing the codes here.
I have copied the files "Content.zip" to get all my files over there but it seems that the zip file shows "0 bytes", which means it doesn't have any files in it. And also I am unclear of the unzipping of the file part. Help please? Thanks!

##Edit Got the zip file into the documents folder. But I am unable to unzip all the files using the code given from the codes below. I did not use the downloadFiles and changed the path to Content.zip. It doesn't do anything. Help?

Jeremy

Code: Select all

on downloadFiles
   libUrlDownloadToFile "URL TO ZIP", specialfolderpath ("documents") & "/imagesApp.zip"
   send unZip to me in 0 milliseconds
end downloadFiles

command unZip
   
   put specialFolderPath("documents") & "/imagesApp.zip" into TempFile
   put specialFolderPath("documents") & "/" into TargetFile -- Problem part, previous one was linked to a map in a map, because the zip is a map. 
   
   revZipOpenArchive TempFile, "read"
   put RevZipEnumerateItems(TempFile) into tList
   
   repeat for each line i in tList
      
      if i = empty then
         next repeat
      end if
      
      revZipExtractItemToFile TempFile, i, (TargetFile & i)
      
   end repeat
   
   revZipCloseArchive TempFile
   delete file TempFile
   
end unZip

Re: Problem with updating HTML files in LiveCode

Posted: Thu Dec 05, 2013 6:45 am
by Simon
Did you read the full thread?

Simon

Re: Problem with updating HTML files in LiveCode

Posted: Thu Dec 05, 2013 7:06 am
by TKYTKY
Yes I downloaded the file you used and substituted the codes I needed to unzip the folders into the documents folder. It still doesn't work.

Code: Select all

 on mouseUp
   if the environment = "development" then touchEnd 1
      
      send unZip to me in 0 milliseconds
end mouseUp

command unZip
   put specialFolderPath("documents") & "/Content.zip" into TempFile
    answer it
    put specialFolderPath("documents") & "/" into TargetFile
    answer it
    revZipOpenArchive TempFile, "read"
    answer it
   put RevZipEnumerateItems(TempFile) into tList
   answer it
   repeat for each line i in tList
      if i = empty then
         next repeat
      end if
      --HERE IS THE FOLDER CODE
      if the last char of i ="/" then 
         create folder (TargetFile & i)
         next repeat
      end if
      --END
      revZipExtractItemToFile TempFile, i, (TargetFile & i)
   end repeat
   revZipCloseArchive TempFile
   delete file TempFile
  end unZip
This is my code. I put it into a button and when I answer it, it shows that everything is empty.

##Edit : Code is edited for this post and, I don't understand what this code means " revZipExtractItemToFile TempFile, i, (TargetFile & i)"
### Edit : Again

Re: Problem with updating HTML files in LiveCode

Posted: Thu Dec 05, 2013 7:12 am
by Simon
when I answer it, it shows that everything is empty
I don't see an "answer it" anywhere in your code?

Are you trying to learn liveCode or just pass a class?

Re: Problem with updating HTML files in LiveCode

Posted: Thu Dec 05, 2013 7:18 am
by TKYTKY
Just edited it again.

And does the code "send unzip to me in 0 milliseconds" actually does the command "unZip"? :O

## Edit: As seen, I have 4 "answer it". But I only got 2 answers which are blank.

Thanks

Jeremy

Re: Problem with updating HTML files in LiveCode

Posted: Thu Dec 05, 2013 7:36 am
by TKYTKY
Oh ya and there are three folders in my Content.zip now already named "JS", "Images" and "Style" only. Is it possible to extract all three of them at once into the names they should be to the documents folder from the engine folder?

##Edit : Tried answering them one by one on top, only tList isn't answered. The rest were answered correctly.

Re: Problem with updating HTML files in LiveCode

Posted: Thu Dec 05, 2013 7:52 am
by Simon
Have you studied "it" and "result"?
Do you know when to use either?

Re: Problem with updating HTML files in LiveCode

Posted: Thu Dec 05, 2013 8:03 am
by TKYTKY
I tried "answer the result" and "answer result" and "result" but it doesn't work

I used the dictionary to find "result" but don't get what it does and except check for errors but it doesn't tell me what errors there are too.