Cloning substacks with the clone of the mainstack

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

Post Reply
Sjatplat
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 75
Joined: Wed Jun 22, 2011 1:53 pm

Cloning substacks with the clone of the mainstack

Post by Sjatplat » Thu Apr 10, 2014 10:14 pm

I´ve made a launcher/splash that autoupdates my mainstack. Everything works fine but I discovered that the substacks are not cloned.

What I have done is that I have made a development-group with stuff I use when I develope my mainstack. Such as a color palette and buttons. And also a button that sends the latest version to my server and removes the development group and other settings. This is a very fast solution. But I clone my stack and rename it before I send it to my server and the clone command does not clone the substacks.

I guess the reason for this is that livecode doesn´t like stacks with duplicate names. This is no problem with my mainstack as My "development"-stack uses another name and I change it after cloning it. but what about the substacks....I need to keep their name...

Is there a way to do this?

this is the code I use to clone my mainstack and send it to my ftp

Code: Select all

clone this stack
   set the cDefaultfolder of it to empty
   set the destroystack of it to true
   set the cVersion of it to tVersion
   delete group "devgroup" of it
   set the name of stack "copy of *stackname*" to "update"
   set the filename of stack "update" to "/Users/*username*/Dropbox/*stackname*/Build/update.lc"
   save stack "Update"
   put "/Users/*username*/Dropbox/******/Build/update.lc" into tFileToUpload
   put  "ftp://****server****/update.lc" into tDestination
   libURLftpUploadFile tFileToUpload, tDestination, "uploadComplete"
   close stack "update"

Sjatplat
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 75
Joined: Wed Jun 22, 2011 1:53 pm

Re: Cloning substacks with the clone of the mainstack

Post by Sjatplat » Thu Apr 10, 2014 11:20 pm

I solved it.

I just gave the substacks of my main stack a temporary name before I cloned them and then set the name of the cloned substacks to the correct name and set their Mainstack property to my cloned stack. After saving and sending my cloned stack to my server, I close it and rename the original substacks to their original name.

Code: Select all

set the name of  stack "myAsk" to "tmyAsk"
   set the name of stack "myAnswer" to "tmyAnswer"
   clone this stack
   set the cDefaultfolder of it to empty
   set the destroystack of it to true
   set the cVersion of it to tVersion
   delete group "devgroup" of it
   set the name of stack "copy of w*****" to "update"
   clone stack "tmyAsk"
   set the mainstack of it to "update"
   set the name of stack "copy of tmyAsk" to "myAsk"
   clone stack "tmyAnswer"
   set the mainstack of it to "update"
   set the name of stack "copy of tmyAnswer" to "myAnswer"
   close stack "myAnswer"
   close stack "myAsk"
   set the filename of stack "update" to "/Users/****username***/Dropbox/W*****/Build/update.lc"
   save stack "Update"
   put "/Users/*usrname*/Dropbox/*folder*/Build/update.lc" into tFileToUpload
   put  "ftp://***ftpaddress**/update.lc" into tDestination
   libURLftpUploadFile tFileToUpload, tDestination, "uploadComplete"
   close stack "update"
   set the name of stack "tmyAnswer" to "myAnswer"
   set the name of stack "tmyAsk" to "myAsk"

Post Reply