help with referencing differnt fields with labels?

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
Frank Deutsch
Posts: 5
Joined: Mon Aug 24, 2015 5:05 am

help with referencing differnt fields with labels?

Post by Frank Deutsch » Mon Aug 31, 2015 5:52 am

Hello Gurus,
I hope I can get some help here, please.
I have a card with 3 groups.
2 groups contain 5 radio button each.
Each radio button has a value ascribed to it by it's script. IE.
grp Potential
on mouseUp
put "" into fld tFPV
put 5 into fld tFPV
end mouseUp
grp Occurance Factor
on mouseUp
put "" into fld tOFV
put 5 into fld tOFV
end mouseUp
Values range from 1 to 5 in each group.

This value is * by a script in the button
on mouseUp
set the backgroundColor of fld tValue to "white"
wait 1 second
put '' into fld tValue
--multilpy tFPV * tOFV and put result into fld tValue
put fld tFPV * fld tOFV into fld tValue
--set the backgroundColor Risk_Matrix lbl "lbl1" to "red (This is the line that I cannot get right. I want the background Color of the corresponding label (Nr.) in the grp Risk Matrix to change from white opaque to either red, yellow or green)
end mouseUp

So far so good, the multiplier puts the correct value into tValue.

I also have a group "Risk Matrix" consisting on 5 lables * 5 rows numbered from 1 to 25 (for inst. lbl1, lbl2, etc to lbl25) All lbl fields are set to opaque white

My intention is that when my tValue field produces a value of lets say 1, the lbl1 background color ought to change to red (or Yellow or Green) depending on risk severity.

I have tried for several hours, but I NEED HELP.
Would some kind soul please point me into the right direction, please.

best regards
Frank

SparkOut
Posts: 2947
Joined: Sun Sep 23, 2007 4:58 pm

Re: help with referencing differnt fields with labels?

Post by SparkOut » Mon Aug 31, 2015 9:15 am

The labels are all named "lbl1" through "lbl25", right? I ask because I am unclear about your other fields. ( labels are ALSO fields, just with a set of properties applied to stop being generally editable). You would

Code: Select all

set the backColor of field "lbl7" to "red"
now. Always quote field (or object) names unless you are dynamically referencing them via a variable. For instance in your first group setup handler, what is

Code: Select all

put 5 into fld tFPV
meant to do? Do you mean there is a field called tFPV which should have 5 put into it? (Note you don't have to put empty into it first). Or is tFPV a variable which contains a field name that you want to update? Either quote the field name "tFPV" (this would be a very confusing naming convention) or to force the engine to resolve the variable referencing the field, enclose it in parentheses

Code: Select all

put 5 into field (tFPV)
this is sometimes important when constructing a name reference from a mixture of literals and variables:-
So given a value of 7, you can

Code: Select all

set the backColor of field ("lbl" & field (tValue)) to "red"

Post Reply