Solved!How to save a new stack from another stack with custom name?

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

Fasasoftware
Posts: 203
Joined: Mon Oct 31, 2011 9:36 pm
Location: Italy
Contact:

Solved!How to save a new stack from another stack with custom name?

Post by Fasasoftware » Mon Apr 09, 2018 10:14 pm

How to save a new stack from another stack with custom name? :(
thanks to everybody,

Lestroso :oops:
Last edited by Fasasoftware on Tue Apr 10, 2018 9:09 pm, edited 3 times in total.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9359
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: How to save a new stack from another stack with custom name?

Post by richmond62 » Mon Apr 09, 2018 10:36 pm

Code: Select all

on mouseUp
   ask "What is the name of your new stack?"
   put it into IMENA
   create stack IMENA
   save stack IMENA
end mouseUp
stacker.png

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9359
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: How to save a new stack from another stack with custom name?

Post by richmond62 » Mon Apr 09, 2018 11:15 pm

Improved code:

Code: Select all

on mouseUp
   ask "What is the name of your new stack?"
   put it into IMENA
   create stack IMENA
   save stack IMENA as (IMENA & ".livecode")
end mouseUp
Thanks, bogs 8)
Stacker.livecode.zip
(1017 Bytes) Downloaded 182 times

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: How to save a new stack from another stack with custom name?

Post by bogs » Tue Apr 10, 2018 3:27 am

Thank YOU Richmond, I knew I forgot something! (The parenthesis :oops: )
Image

Fasasoftware
Posts: 203
Joined: Mon Oct 31, 2011 9:36 pm
Location: Italy
Contact:

Re: How to save a new stack from another stack with custom name?

Post by Fasasoftware » Tue Apr 10, 2018 6:11 pm

hi richmond62 and bogs,

your code for me works for a half....

it create the name and the stack itself...but your software don't save the new stack either in a directory where there's the first stack in this case stacker ....and no everywhere...

i need to save a new custom stack in a directory...not only in memory...but i think is Livecode fault.....

best regards...thank in any way..

Lestroso :oops:

Fasasoftware
Posts: 203
Joined: Mon Oct 31, 2011 9:36 pm
Location: Italy
Contact:

Re: How to save a new stack from another stack with custom name?

Post by Fasasoftware » Tue Apr 10, 2018 6:43 pm

Dear friends,

i have tryed also to compile the richmond62 file example in to an app...for mac os x... but nothing works...the new stack appears , but the new stack is not saved on the disk....

Do i have done something wrong??
is it a mac os x issue??Only??a bug?? i have used 8.1.9 and 9.00 livecode community! for mac os x

Thank a lot again...best regards,

Lestroso :(

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9359
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: How to save a new stack from another stack with custom name?

Post by richmond62 » Tue Apr 10, 2018 6:54 pm

i have tryed also to compile the richmond62 file example in to an app
That may be because you are not permitted to make new, savable stacks in a standalone.

SparkOut
Posts: 2852
Joined: Sun Sep 23, 2007 4:58 pm

Re: How to save a new stack from another stack with custom name?

Post by SparkOut » Tue Apr 10, 2018 6:55 pm

Is this in the IDE?
Probably you are trying to write the file in the default folder which is (relative to the LC engine) in a write-protected loxation.
Try setting the default folder to a writeable location before the save.

Klaus
Posts: 13824
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: How to save a new stack from another stack with custom name?

Post by Klaus » Tue Apr 10, 2018 6:59 pm

Of course you need to supply a pathname/folder where you have write permissions to save the stack in! 8)
You can only use this (NO pathname):

Code: Select all

...
save stack IMENA as (IMENA & ".livecode")
...
if you really KNOW what the current defaultfolder is and that you have write permission there!

In a standalone this will be probably the users "Applications" folder and we are NOT allowed to write there, unless the user is logged in as ADMIN!

And, as I mentioned in another thread, if something like this happens, check THE RESULT!

If in doubt, use -> specialfolderpath("documents")

Code: Select all

...
save stack IMENA as (specialfolderpath("documents") & "/" & IMENA & ".livecode")
...

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9648
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: How to save a new stack from another stack with custom name?

Post by dunbarx » Tue Apr 10, 2018 7:09 pm

Try this experiment. There are just a few missing pieces.

Code: Select all

on mouseUp
   ask "What is the name of your new stack?"
   put it into newStack
   create stack newStack
   
   answer folder "Select Folder" -- SELECT DESTINATION FOLDER  FOR TESTING
 
   save stack newStack as (it & "/" & newStack & ".livecode")
end mouseUp
Craig Newman

Fasasoftware
Posts: 203
Joined: Mon Oct 31, 2011 9:36 pm
Location: Italy
Contact:

Re: How to save a new stack from another stack with custom name?

Post by Fasasoftware » Tue Apr 10, 2018 7:28 pm

Dear Craig!!!! Thanks a lot MIllions!!!

THIS WORKS VERY FINE!!!!! either in Livecode IDE...either in a standalone app ...i tryed only for now in a mac os x platform!!! i hope will work also on windows10....i will change only the directory i think...

Thank a lot in every way to everybody for the support!!

Best regards,
Lestroso :D :D :D :D

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: How to save a new stack from another stack with custom name?

Post by bogs » Tue Apr 10, 2018 7:35 pm

Fasasoftware wrote:
Tue Apr 10, 2018 6:11 pm
it create the name and the stack itself...but your software don't save the new stack either in a directory where there's the first stack in this case stacker ....and no everywhere...

i need to save a new custom stack in a directory...
Heya Lestroso, I'm sorry, I didn't bother putting in that you needed to specify a path with that example, based on how many programs I'd seen that you've authored, I assumed (theres that word again :roll: ) that you understood the default folder, and how to specify paths and such.

Everyone above this post has laid it out for you, on a Mac, unlike windows or linux, you won't be able to write into an .app folder (I think I have that correctly). On all Os's, you have to have write permissions to save. For instance, I dev on Linux, the code I wrote uses the default (for the IDE) folder, which turns out to be the 'home' folder, on the other two Os's I believe it is equivalent to the 'Documents' folder.

You should be able to modify the path for saving the file using the specialFolderPath function. Alternately, you can build a path (relative, if your going to move this to different machines) to save the file anywhere you have write permissions.

I think in most cases, specialFolderPath("Documents" & "/whateverFolderYouMake") is the generic fall too.
Image

Klaus
Posts: 13824
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: How to save a new stack from another stack with custom name?

Post by Klaus » Tue Apr 10, 2018 7:55 pm

richmond62 wrote:
Tue Apr 10, 2018 6:54 pm
i have tryed also to compile the richmond62 file example in to an app
That may be because you are not permitted to make new, savable stacks in a standalone.
Come on, Richmond, you can't be serious!? :shock:

Fasasoftware
Posts: 203
Joined: Mon Oct 31, 2011 9:36 pm
Location: Italy
Contact:

Re: Solved!How to save a new stack from another stack with custom name?

Post by Fasasoftware » Tue Apr 10, 2018 8:17 pm

Hi, i have a little other problem.....
Can i clone a stack and rename it with a name i want with a modify of your script?

Code: Select all

on mouseUp
   ask "What is the name of your new stack?"
   put it into newStack
   clone this stack --newStack
  put newstack into  title of the stack
   
     answer folder "Select Folder" -- SELECT DESTINATION FOLDER  FOR TESTING
   
    save stack newStack as (it & "/" & newStack & ".livecode")
end mouseUp
but this last don't work...can you help me??
best regards,
Lestroso :oops:

Klaus
Posts: 13824
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: How to save a new stack from another stack with custom name?

Post by Klaus » Tue Apr 10, 2018 8:32 pm

Why not take a look into the dictionary? 8)

Code: Select all

...
ask "What is the name of your new stack?"
put it into newStack
clone this stack AS newStack
...

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”