Store files within livecode app?

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

Klaus
Posts: 14191
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Store files within livecode app?

Post by Klaus » Tue Mar 18, 2014 7:52 pm

Hi Mark,
Mark wrote:Hi Klaus,

I just had only a very quick look at your script, so I might be wrong, but I'm wondering if you didn't forget a "binfile:" in the last line?
I actually left that line in question untouched, because I wondered what kind of file "Numbercrunch" (no suffix!) was.
Which I explained in the line before.
Mark wrote:Also, since the app is using the text files and not some text editor, you might want to use binfile when writing the files to disk. I would assume that OP doesn't want to convert line endings, unless he says he wants to (so, do you want to convert line endings, OP?).
Kind regards,
Mark
I dared to presume that all this did happen on a Mac, so the text format would have been OK in that case. 8)


Best

Klaus

acwilson96
Posts: 22
Joined: Tue Nov 26, 2013 9:55 pm

Re: Store files within livecode app?

Post by acwilson96 » Tue Mar 18, 2014 7:55 pm

I am back to square one with this, I just cannot get it to work!
Here is code that I have:

Code: Select all

global highscoreNames, highscoreScores

on mouseUp
   put the documents folder & "/NumberCrunch" into tFolder1
   put the documents folder & "/NumberCrunch/Highscores" into tFolder2
   if there is not a folder tFolder1 then
       create folder tFolder1
   end if
   if there is not a folder tFolder2 then
      create folder tFolder2
   end if
   put the effective filename of this stack into filePath
   set the itemDel to slash
   delete last item of filePath
end mouseUp
All I need to do now is copy 3 files, two of which are .txt's and the last one is a .app file
If you can supply code which will do that I would greatly appreciate it!
And the destination for the txt's is tFolder2 and the destination for the .app is the applications folder, but if its easier, just use the desktop/documents folder.

Klaus
Posts: 14191
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Store files within livecode app?

Post by Klaus » Tue Mar 18, 2014 8:02 pm

Hi acwilson96,
acwilson96 wrote:

Code: Select all

...
   put the effective filename of this stack into filePath
   set the itemDel to slash
   delete last item of filePath
   put url("FILE:" & filePath & "/FILES/highscoreNames.txt") into url ("file:" & tFolder2 & "/highscoreNames.txt")
   put url("FILE:" & filePath & "/FILES/highscoreScores.txt") into url ("file:" & tFolder2 & "/highscoreScores.txt")
...
are you sure you have a folder namded "FILES" in the folder where your stack is? And these two text files in it?
And is that inside of the standalone APP? An app is actually a folder on the Mac.
acwilson96 wrote:

Code: Select all

...
   put url("BINFILE:" & filePath & "/FILES/NumberCrunch.app") into url (defaultfolder)
end mouseUp
Please read the comments in my script, you must supply a target filename!

But this will not work here, because an OS X APP is in fact a folder 8)

Not sure if "revCopyFolder" does the job correctly, never used it.
I always use the shell command DITTO on OS X, will look in my archieves
if I can find a script, always forget this :D

Best

Klaus

acwilson96
Posts: 22
Joined: Tue Nov 26, 2013 9:55 pm

Re: Store files within livecode app?

Post by acwilson96 » Tue Mar 18, 2014 8:06 pm

I will try to use revCopyFolder to copy the .app and I was able to get the text files copying, just they would be blank on the copy!
Just tried. Whilst in IDE mode I am able to copy the .app to the applications folder using revCopyFile but not with revCopyFolder. I can program the entire thing fine, its just when it comes to compiling it and using it as a standalone app that it stops working.

*EDIT*
I can upload a youtube video of the issue I am having if that makes it easier to understand?
The following code works on IDE mode, just not standalone.

Code: Select all

global highscoreNames, highscoreScores

on mouseUp
   put the documents folder & "/NumberCrunch" into tFolder1
   put the documents folder & "/NumberCrunch/Highscores" into tFolder2
   if there is not a folder tFolder1 then
       create folder tFolder1
   end if
   if there is not a folder tFolder2 then
      create folder tFolder2
   end if
   put the effective filename of this stack into filePath
   set the itemDel to slash
   delete last item of filePath
   --
   revCopyFile filePath & "/FILES/NumberCrunch.app",defaultfolder
   revCopyFile filePath & "/FILES/highscoreNames.txt",tFolder2
   revCopyFile filePath & "/FILES/highscoreScores.txt",tFolder2
end mouseUp

acwilson96
Posts: 22
Joined: Tue Nov 26, 2013 9:55 pm

Re: Store files within livecode app?

Post by acwilson96 » Tue Mar 18, 2014 8:59 pm

100% working, thanks all for the help!

Klaus
Posts: 14191
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Store files within livecode app?

Post by Klaus » Tue Mar 18, 2014 11:31 pm

acwilson96 wrote:100% working, thanks all for the help!
Okie Dokie, what was the problem?

acwilson96
Posts: 22
Joined: Tue Nov 26, 2013 9:55 pm

Re: Store files within livecode app?

Post by acwilson96 » Tue Mar 18, 2014 11:48 pm

I included the files in the standalone settings, can't remember off the top of my head.

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

Re: Store files within livecode app?

Post by Mark » Wed Mar 19, 2014 5:45 pm

Hi,

You'll need another button AMPM and this line:

put (label of btn "onhour" &":"& label of btn "onminutes" && the label of btn "AMPM") into theTime

Before I post a new script, I think I should ask you what does button "Next" do and what does handler "nextLine" do exactly? If they're not too long, perhaps you should also post the handlers of the button and the nextLine handler.

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

Post Reply