Page 1 of 1

Run vs Edit modes.

Posted: Sat Feb 12, 2011 10:02 am
by luishp
I'm very new developing in LiveCode (just a few days)
Althougt i'm very happy about the learning curve i can't figure out the answer for a very simple question.
In any other IDE when i stop running for testing an application, everything returns to it's original place/values.
In LiveCode any change made at run-time persists at design-time and don't know how to return to the original state.
For instance if i have a button with this script:

Code: Select all

on mouseup
  set the backgroundcolor of me to "Red"
end mouseup
and i try it in run mode clicking the button, the background will become red even when i return to design mode.
Any help would be very appreciated.

Re: Run vs Edit modes.

Posted: Sat Feb 12, 2011 11:09 am
by BvG
There is no going back. So you need to undo changes by yourself, if you need that. for example:

Code: Select all

on mouseup
  if the backgroundcolor of me is "red" then
    set the backgroundcolor of me to "" --let higher level color setting show trough
  else
    set the backgroundcolor of me to "Red"
  end if
end mouseup

Re: Run vs Edit modes.

Posted: Sat Feb 12, 2011 11:27 am
by jmburnod
Hi Luis,

Welcome.
don't know how to return to the original state
Very useful for buttons :
you can also have some icons for each state
The icon = the short id of an image you have in your stack
Look at "icons & border" of the object inspector.

For others you can return to the original state at preopencard

Code: Select all

on preopencard
   put "myGrc" into tGrc
   -- directly in script
   set the backgroundcolor of grc tGrc to blue
   -- by the custompropertie of the object
   set the backgroundcolor of grc tGrc to the myColor of grc tGrc
end preopencard
Someone will you explane better (my english is under construction).

I hope this help

All the best

Jean-Marc

Re: Run vs Edit modes.

Posted: Sat Feb 12, 2011 1:40 pm
by Klaus
Hi Luis,

yet, Livecode is different and one has to get used to this!
On the other hand, the name of the beast is LIVECode 8)


Best

Klaus

Re: Run vs Edit modes.

Posted: Sat Feb 12, 2011 2:54 pm
by jharris
I am also new to LiveCode... I had the same question. I have been clearing everything in preopencard as stated above, that seems to work well. After working with .Net and RealBasic for so long LiveCode is hard to get used to.
After a couple of weeks though I must say that I am really enjoying using it. (I just wanted to post. I don't know enough at this time to really help anyone.)

Re: Run vs Edit modes.

Posted: Sat Feb 12, 2011 3:04 pm
by doc
Hello Luis,
I usually add a button or other control such as a label positioned out of the way somewhere and add the handlers needed to reset the various things. That gives me the ability to easily reset at any time during development and I've also found that it gives me a head start on organizing the code that I will want to use during a "preopenstack" initialization process anyway.

While I'm at it, in addition to the above, I usually add a handler and whatever else is necessary to reset and populate my test data, rather than reopening files numerous times, or playing the cut/copy/paste game, over and over.

Makes for a smooth process overall.

Best regards,
-Doc-

Re: Run vs Edit modes.

Posted: Sat Feb 12, 2011 6:54 pm
by luishp
Thank you very much for all your quick answers.
I'm trying to get used to this different way of programming.
It's very interesting and seems very powerfull too, but for now i still missing a "reset" button in the IDE main menu.
Anyway i've had a very nice feeling with you, the LiveCode community.
I hope to learn and contribute as much as possible.
Regards from Spain.

Re: Run vs Edit modes.

Posted: Sat Feb 12, 2011 8:59 pm
by mwieder
Luis- In the File menu of the IDE there's a menuItem for "Revert to Saved..." which will reload the stack from disk. This will, of course, lose any changes since the last time you saved to disk, but it may act as a "Reset" button for you if you really need it. Mostly, though, I think that as you get used to working in LiveCode you won't miss that functionality at all.

(although I do sometimes wish I could undo some stupid things I've done in stacks)

Re: Run vs Edit modes.

Posted: Sat Feb 12, 2011 9:03 pm
by mwieder
Doc- I do something similar, but usually try to refactor the code so that it's called by both the button and the setup script:

Code: Select all

--in mouse button
on mouseUp
  setupStuff
end mouseUp

--in card script
on preOpenStack
  setupStuff
end preOpenStack

on setupStuff
  -- do the heavy lifting here
  -- reset things to an initial state
end setupStuff