Export script from livecode file
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Export script from livecode file
I am interested in exporting the script of a stack of an external livecode file to textfile. This is so I can simply see changes in it on git which does text file processing. Livecode files are a mix of binary resources and text. I can open the file as text, but I am more specifically wanting to process the binary and extract the scripts for the mainstack and substacks and simply save them to text file. I can open external livecode files with 'go to stack' but is there a way to simply read the scripts without executing the stacks in livecode?
-
- VIP Livecode Opensource Backer
- Posts: 2718
- Joined: Sat Dec 22, 2007 5:35 pm
- Location: Genève
- Contact:
Re: Export script from livecode file
Hi steveTX,
I'm not sur I understand what you want but for this part
Best regards
Jean-Marc
I'm not sur I understand what you want but for this part
You can tryis there a way to simply read the scripts without executing the stacks in livecode?
Code: Select all
set the lockmessages to true
Jean-Marc
https://alternatic.ch
Re: Export script from livecode file
I want to build a command line application that reads the livecode file and spits out the scripts inside it to a text file. I want to do this without reading the livecode file as text.
-
- VIP Livecode Opensource Backer
- Posts: 3901
- Joined: Sat Mar 24, 2007 2:54 am
- Location: Palo Alto
Re: Export script from livecode file
Hi Stevetx,
Would you go as far as adding a new function to the stacks to output text files?
Simon
Would you go as far as adding a new function to the stacks to output text files?
Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!
Re: Export script from livecode file
No, it must be fully external. the external applications are not readily executable.
-
- VIP Livecode Opensource Backer
- Posts: 3901
- Joined: Sat Mar 24, 2007 2:54 am
- Location: Palo Alto
Re: Export script from livecode file
Suppose a custom property contained all the scripts in the stack?
Any good?
Any good?
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!
Re: Export script from livecode file
This isn't about changing the target file. This is about being able to arbitrarily extract the scripts of external livecode files and dump them to text.
Re: Export script from livecode file
Hi Steve,
as simple as:
...
put the script of stack "/Users/klaus/Documents/RRMC/cool_stack.livecode" into tStackScript
put the script of cd 1 of stack "/Users/klaus/Documents/RRMC/cool_stack.livecode" into tCardScript
put the substacks of stack "/Users/klaus/Documents/RRMC/cool_stack.livecode" into tSubstacks
put the num of btns of cd 1 of stack "/Users/klaus/Documents/RRMC/cool_stack.livecode" into tNumbOfButtonsOfCd1
etc...
etc...
### extract whatever you like, you get the picture
## Important, after you are done:
close stack "/Users/klaus/Documents/RRMC/cool_stack.livecode"
...
You can access properties of closed stack files without executing any script!
If that is what you mean.
Best
Klaus
as simple as:
...
put the script of stack "/Users/klaus/Documents/RRMC/cool_stack.livecode" into tStackScript
put the script of cd 1 of stack "/Users/klaus/Documents/RRMC/cool_stack.livecode" into tCardScript
put the substacks of stack "/Users/klaus/Documents/RRMC/cool_stack.livecode" into tSubstacks
put the num of btns of cd 1 of stack "/Users/klaus/Documents/RRMC/cool_stack.livecode" into tNumbOfButtonsOfCd1
etc...
etc...
### extract whatever you like, you get the picture
## Important, after you are done:
close stack "/Users/klaus/Documents/RRMC/cool_stack.livecode"
...
You can access properties of closed stack files without executing any script!
If that is what you mean.
Best
Klaus
Re: Export script from livecode file
Thanks Klaus, here is a working stack.
Code: Select all
global theStack, theCard, theOutfile, theData
on preOpenStack
put $1 into theStack
put $2 into theCard
set the visible of this stack to false
set the destroyStack of this stack to true
set the destroyWindow of this stack to true
end preOpenStack
on openStack
if theCard is empty then
pullStack
else
pullCard
end if
close stack theStack
open file theOutfile for write
write theData to file theOutfile
close file theOutfile
quit
end openStack
command pullCard
put the script of card theCard of stack theStack into theData
put (theCard & ".txt") into theOutfile
end pullCard
command pullStack
put the script of stack theStack into theData
put (theStack & ".txt") into theOutfile
end pullStack