Problem with updating HTML files in LiveCode

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Problem with updating HTML files in LiveCode

Post by Simon » Thu Dec 05, 2013 3:56 am

Again,
"the files" used with a repeat loop.

Show me what you have tried.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

Jellicle
Posts: 453
Joined: Thu Feb 24, 2011 11:07 am

Re: Problem with updating HTML files in LiveCode

Post by Jellicle » Thu Dec 05, 2013 3:58 am

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
14" MacBook Pro
Former LiveCode developer.
Now recovering.

TKYTKY
Posts: 46
Joined: Thu Jul 11, 2013 9:25 am

Re: Problem with updating HTML files in LiveCode

Post by TKYTKY » Thu Dec 05, 2013 5:04 am

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"

Jellicle
Posts: 453
Joined: Thu Feb 24, 2011 11:07 am

Re: Problem with updating HTML files in LiveCode

Post by Jellicle » Thu Dec 05, 2013 5:18 am

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
14" MacBook Pro
Former LiveCode developer.
Now recovering.

TKYTKY
Posts: 46
Joined: Thu Jul 11, 2013 9:25 am

Re: Problem with updating HTML files in LiveCode

Post by TKYTKY » Thu Dec 05, 2013 5:33 am

Because in the engine folder the folder is named "Content" and in the Documents folder it's named as "Contents"

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Problem with updating HTML files in LiveCode

Post by Simon » Thu Dec 05, 2013 6:02 am

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
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

TKYTKY
Posts: 46
Joined: Thu Jul 11, 2013 9:25 am

Re: Problem with updating HTML files in LiveCode

Post by TKYTKY » Thu Dec 05, 2013 6:12 am

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

TKYTKY
Posts: 46
Joined: Thu Jul 11, 2013 9:25 am

Re: Problem with updating HTML files in LiveCode

Post by TKYTKY » Thu Dec 05, 2013 6:24 am

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
Last edited by TKYTKY on Thu Dec 05, 2013 6:55 am, edited 1 time in total.

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Problem with updating HTML files in LiveCode

Post by Simon » Thu Dec 05, 2013 6:45 am

Did you read the full thread?

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

TKYTKY
Posts: 46
Joined: Thu Jul 11, 2013 9:25 am

Re: Problem with updating HTML files in LiveCode

Post by TKYTKY » Thu Dec 05, 2013 7:06 am

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
Last edited by TKYTKY on Thu Dec 05, 2013 7:17 am, edited 2 times in total.

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Problem with updating HTML files in LiveCode

Post by Simon » Thu Dec 05, 2013 7:12 am

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?
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

TKYTKY
Posts: 46
Joined: Thu Jul 11, 2013 9:25 am

Re: Problem with updating HTML files in LiveCode

Post by TKYTKY » Thu Dec 05, 2013 7:18 am

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

TKYTKY
Posts: 46
Joined: Thu Jul 11, 2013 9:25 am

Re: Problem with updating HTML files in LiveCode

Post by TKYTKY » Thu Dec 05, 2013 7:36 am

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.

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Problem with updating HTML files in LiveCode

Post by Simon » Thu Dec 05, 2013 7:52 am

Have you studied "it" and "result"?
Do you know when to use either?
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

TKYTKY
Posts: 46
Joined: Thu Jul 11, 2013 9:25 am

Re: Problem with updating HTML files in LiveCode

Post by TKYTKY » Thu Dec 05, 2013 8:03 am

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.

Post Reply