Reset all during testing
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
-
- Posts: 17
- Joined: Wed Dec 04, 2013 1:52 pm
Reset all during testing
Hello, i am new in livecodeworld. I made a small application. I want to reset all variables as if it is the first run for this program. How do i do this?
Even wenn i close the application and close livecode. The next time i start livecode and load the application it has rembered the variables from the last run.
Help would be nice
Even wenn i close the application and close livecode. The next time i start livecode and load the application it has rembered the variables from the last run.
Help would be nice
Re: Reset all during testing
Hi p.schelvis,
1. welcome to the forum!
2. You need to do it manually/via script!
Create a handler named "init_my_stack" (or whatever you name it) and execute it when the stack opens.
Something like this:
You get the picture...
Best
Klaus
1. welcome to the forum!

2. You need to do it manually/via script!
Create a handler named "init_my_stack" (or whatever you name it) and execute it when the stack opens.
Something like this:
Code: Select all
local var1,var2,var3
### or GLOBALS or custom properties or whatever you use...
on openstack
init_my_stack
end openstack
command init_my_stack
put EMPTY into var1
put EMPTY into var2
put "This is text..." into var3
### etc...
end init_my_stack
Best
Klaus
-
- VIP Livecode Opensource Backer
- Posts: 10043
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: Reset all during testing
Variables exist only in memory, and go away with everything else in memory when the app quits. This is true of all programs. Rather than variables, do you mean custom properties or field contents?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
-
- Posts: 17
- Joined: Wed Dec 04, 2013 1:52 pm
Re: Reset all during testing
Hi Richard.
I am having trouble with the principle. I am used to Visual Basic. When in VB i develope a program and i run that program the start is always the same. When, for example, i create a button in that program in flight, the next time i run that program the button will not be there.
in lc it seems to be different. For example the next script:
on mouseUp
create button "button2"
end mouseUp
Every time i run this, there will be a button2 added. When i save the program, and open it later there will be many button2's.
Is this intended?. if that is true then it's hard for me to understand why for this principle is chosen.
With best regards, Peter
I am having trouble with the principle. I am used to Visual Basic. When in VB i develope a program and i run that program the start is always the same. When, for example, i create a button in that program in flight, the next time i run that program the button will not be there.
in lc it seems to be different. For example the next script:
on mouseUp
create button "button2"
end mouseUp
Every time i run this, there will be a button2 added. When i save the program, and open it later there will be many button2's.
Is this intended?. if that is true then it's hard for me to understand why for this principle is chosen.
With best regards, Peter
Re: Reset all during testing
Hi Peter,
Sure this will work in a standalone.
But in the IDE if you save it then there can be plenty of buttons named "button 2".
it's interesting what VB is doing (if what you say is correct).
e.g. If I create a new text file and write "This is new text" then save the file and close it, I'm not surprised that when I open the file again I see "This is new text". Isn't that you would expect?
Simon
Sure this will work in a standalone.
But in the IDE if you save it then there can be plenty of buttons named "button 2".
it's interesting what VB is doing (if what you say is correct).
e.g. If I create a new text file and write "This is new text" then save the file and close it, I'm not surprised that when I open the file again I see "This is new text". Isn't that you would expect?
Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!
-
- Posts: 17
- Joined: Wed Dec 04, 2013 1:52 pm
Re: Reset all during testing
Hi Simon,
There is een switch in my head that will not switch! No doubt it's my fault. But this is my problem:
When you 'save as standalone application...', you get an executable, for example test.exe in windows. If you run test.exe (see my example above) the program test.exe create a 'button2'. When i close the program test.exe and start it again, ther will not be a 'button2'.
When you run in the IDE, LiveCode does not react the same. It doesn't restart the program from scratch like the exe does.
y.s Peter
There is een switch in my head that will not switch! No doubt it's my fault. But this is my problem:
When you 'save as standalone application...', you get an executable, for example test.exe in windows. If you run test.exe (see my example above) the program test.exe create a 'button2'. When i close the program test.exe and start it again, ther will not be a 'button2'.
When you run in the IDE, LiveCode does not react the same. It doesn't restart the program from scratch like the exe does.
y.s Peter
Re: Reset all during testing
Dag Peter,
a "standalone" cannot save itself, NEVER, on NO platform!
That is why it will always open in the state in which the stack (that turns into a standlaone) has been saved!
When you open a stack in the IDE, it opens in its last saved state (eventually with many buttons "button2"
)
Whatever, this is the way Livecode works, get used to it
Best
Klaus
a "standalone" cannot save itself, NEVER, on NO platform!
That is why it will always open in the state in which the stack (that turns into a standlaone) has been saved!
When you open a stack in the IDE, it opens in its last saved state (eventually with many buttons "button2"

Whatever, this is the way Livecode works, get used to it

Best
Klaus
-
- Posts: 17
- Joined: Wed Dec 04, 2013 1:52 pm
Re: Reset all during testing
Hello all of you,
Thank you for all of the answers. I accept that this is the way Livecode works. I now have a "on reset-to-startposition" message where i clean up.
That works fine for me.
With kind regards,
Peter
Thank you for all of the answers. I accept that this is the way Livecode works. I now have a "on reset-to-startposition" message where i clean up.
That works fine for me.
With kind regards,
Peter
-
- VIP Livecode Opensource Backer
- Posts: 10043
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: Reset all during testing
On the olden days many of us included a handler named "StripAndShip" in our mainstacks, which we'd run from the Message Box before building specifically to reset anything needed.
In the modern world LiveCode now provides a message for this: savingStandalone. This is send immediately before the building process when making a standalone, and is a good place to put any such cleanup routines.
Another message that may be worth knowing about is standaloneSaved, sent immediately after the build. This can be helpful for handling any additional tasks you may want to do on either the output standalone (such as triggering an installer-maker for a one-click build process), or even just restoring your work copy to some state you may find useful when developing.
In the modern world LiveCode now provides a message for this: savingStandalone. This is send immediately before the building process when making a standalone, and is a good place to put any such cleanup routines.
Another message that may be worth knowing about is standaloneSaved, sent immediately after the build. This can be helpful for handling any additional tasks you may want to do on either the output standalone (such as triggering an installer-maker for a one-click build process), or even just restoring your work copy to some state you may find useful when developing.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn