Page 1 of 2
Solved!How to save a new stack from another stack with custom name?
Posted: Mon Apr 09, 2018 10:14 pm
by Fasasoftware
How to save a new stack from another stack with custom name?
thanks to everybody,
Lestroso

Re: How to save a new stack from another stack with custom name?
Posted: Mon Apr 09, 2018 10:36 pm
by richmond62
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
Re: How to save a new stack from another stack with custom name?
Posted: Mon Apr 09, 2018 11:15 pm
by richmond62
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
Re: How to save a new stack from another stack with custom name?
Posted: Tue Apr 10, 2018 3:27 am
by bogs
Thank YOU Richmond, I knew I forgot something! (The parenthesis

)
Re: How to save a new stack from another stack with custom name?
Posted: Tue Apr 10, 2018 6:11 pm
by Fasasoftware
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

Re: How to save a new stack from another stack with custom name?
Posted: Tue Apr 10, 2018 6:43 pm
by Fasasoftware
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

Re: How to save a new stack from another stack with custom name?
Posted: Tue Apr 10, 2018 6:54 pm
by richmond62
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.
Re: How to save a new stack from another stack with custom name?
Posted: Tue Apr 10, 2018 6:55 pm
by SparkOut
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.
Re: How to save a new stack from another stack with custom name?
Posted: Tue Apr 10, 2018 6:59 pm
by Klaus
Of course you need to supply a pathname/folder where you have write permissions to save the stack in!
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")
...
Re: How to save a new stack from another stack with custom name?
Posted: Tue Apr 10, 2018 7:09 pm
by dunbarx
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
Re: How to save a new stack from another stack with custom name?
Posted: Tue Apr 10, 2018 7:28 pm
by Fasasoftware
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

Re: How to save a new stack from another stack with custom name?
Posted: Tue Apr 10, 2018 7:35 pm
by bogs
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

) 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.
Re: How to save a new stack from another stack with custom name?
Posted: Tue Apr 10, 2018 7:55 pm
by Klaus
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!?

Re: Solved!How to save a new stack from another stack with custom name?
Posted: Tue Apr 10, 2018 8:17 pm
by Fasasoftware
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

Re: How to save a new stack from another stack with custom name?
Posted: Tue Apr 10, 2018 8:32 pm
by Klaus
Why not take a look into the dictionary?
Code: Select all
...
ask "What is the name of your new stack?"
put it into newStack
clone this stack AS newStack
...