Page 1 of 1

Rev 2.6 Not LiveCode

Posted: Mon Aug 01, 2011 12:47 am
by gray.nomad
Hello Gurus,
I am by NO MEANS a programmer, but just would like some help with Rev 2.6, which is probably not dissimilar to Live Code.
I bought this Rev 2.6 some 5-6 years ago and was far to busy with my normal work. Now, that I have retired, I'd like to get
a bit deeper into it.
I want to develop a small application, in which a label (CalcField) needs to change backgroundColor according to the value it contains.
The value is determined by multiplication of 2 other fields .

I have not found out how to change the backgroundColor according to the changing value as per CalcField.
I would appreciate if one of you gurus could help me out.

Below is the working snippet bound to the calculation button.

on mouseUp
--multiply fld "injury * fld "Occur" and put result into fld CalcField
put fld "Injury" * fld "Occur" into tResult
put tResult into fld "CalcField"
--change backgroundColor of fld CalcField according to content.
--between 1-10, red; between 11-19 yellow; between 20-25 green.
end mouseUp

Thank you for your help.
Frank

Re: Rev 2.6 Not LiveCode

Posted: Mon Aug 01, 2011 1:07 am
by splash21
Hi, Frank. I'm assuming the language basics haven't changed from 2.6, so the following should work after you put tResult into CalcField;

Code: Select all

   if tResult >= 1 and tResult <= 10 then
      set the backColor of fld "CalcField" to red
   else if tResult >= 11 and tResult <= 19 then
      set the backColor of fld "CalcField" to yellow
   else if tResult >= 20 and tResult <= 25 then
      set the backColor of fld "CalcField" to green
   else
      set the backColor of fld "CalcField" to white
   end if

J

(P.S. if CalcField is a label, make sure it's opaque property is true!)

Re: Rev 2.6 Not LiveCode

Posted: Mon Aug 01, 2011 1:09 am
by shaosean

Code: Select all

on mouseUp 
  --multiply fld "injury * fld "Occur" and put result into fld CalcField
  put fld "Injury" * fld "Occur" into tResult
  put tResult into fld "CalcField"
  --change backgroundColor of fld CalcField according to content.
  --between 1-10, red; between 11-19 yellow; between 20-25 green.
  local tColor = "white"
  if (tResult <= 10) then
    put "red" into tColor
  else if (tResult < 20) then
    put "yellow" into tColor
  else if (tResult <= 25) then
    put "green" into tColor
  end if
  set the backgroundColor of field "CalcField" to tColor
end mouseUp

Re: Rev 2.6 Not LiveCode

Posted: Mon Aug 01, 2011 5:23 am
by BarrySumpter
Whats the equilivant word for

Code: Select all

Select Case x
    case 1
      'do something
    case 2
      'do nothing
end select?

Re: Rev 2.6 Not LiveCode

Posted: Mon Aug 01, 2011 5:32 am
by dglass
Are you looking for 'switch'?

Code: Select all

 
switch the platform
  case "MacOS"
    put specialfolderpath("preferences") into tPreferenceLocation
    break
  case "Win32"
    put specialfolderpath("0x001a") into tPreferenceLocation
    break
end switch 

Re: Rev 2.6 Not LiveCode

Posted: Mon Aug 01, 2011 5:48 am
by BarrySumpter
Switch!

Where was that hiding all this time and why does it look so strange?
Man! I'm gettin old.

Hey! That was an excellent (meaning useful) example!
Thanks for that.

I asked cause the nested if above looked like it could use the Switch Case.

oops. And my appologies if Switch is implemented in a later release of Rev.
oops. And again my appologies if I've mistakenly deduced Rev 2.6 is just an earlier version of LiveCode 4.6.3.

Re: Rev 2.6 Not LiveCode

Posted: Mon Aug 01, 2011 11:10 am
by gray.nomad
Thank you gurus,
Thanks to all who replied.
Shaosean, I copy/paste you code and it worked instantly. What a live saver. I started to get grey hairs :x
Unfortunatly, Rev 2.6 is not supported anymore and I can understand why, but that is all the REV software that I
probably will ever need.
I wonder if someone could point me into where I could get code snippets/forums or other help for Rev 2.6.

In the meantime, thanks again for the help Shaosean and very best regards to all
Frank

Re: Rev 2.6 Not LiveCode

Posted: Mon Aug 01, 2011 11:25 am
by shaosean
Frank, just ask (but make sure to make a new topic).. I have a copy of Rev from 2.0 to 4.0 installed (have not touched anything branded LiveCode).. Other than some new features and some bug fixes, 2.6 will get you through the day and get your project completed..

Re: Rev 2.6 Not LiveCode

Posted: Thu Aug 04, 2011 4:49 am
by doc
gray.nomad wrote:<snip>
I wonder if someone could point me into where I could get code snippets/forums or other help for Rev 2.6. <snip>
Hello Frank,
The online scripting conferences were all done right along the same time frame as Rev 2.6 and are still unbeatable for learning:
http://www.runrev.com/developers/lesson ... nferences/

They are extremely well done and a huge help to anyone facing the learning curve.

-Doc-