Re: Best Practices Issue

new topic     » goto parent     » topic index » view thread      » older message » newer message

On Friday 07 February 2003 08:59 pm, you wrote:
>
> Thinking about Kat's observation, maybe you could create an "invisible"
> (off-screen?) check-box control, and *change* that whenever your variab=
le
> changes; then you could use an "onChange" event trap for the check-box =
to
> re-set the text to what the variable has?

If I've already detected the change enough to change the checkbox, I don'=
t=20
need the checkbox! Instead of changing the checkbox, I just change the=20
control/variable.

Ultimately what is needed is an onChange() event for a variable, but that=
's=20
unlikely (maybe preposterous or something like that!).

Two (three?) ways to do it:

1. intermittently check the values and update all dependencies
2. use onChange() events for controls and either
=09a. call a global watcher procedure that makes sure ALL variables/contr=
ols are=20
up-to-date
=09b. use code in the onChange() event to only update SPECIFIC other cont=
rols

For example:

s =3D { 1, 2, 3, 4 }
-- assign values to controls
-- txtN represents an edit box
-- txt1..txt4 are editable, txt5 is not
txt1 =3D s[1]
txt2 =3D s[2]
txt3 =3D s[3]
txt4 =3D s[4]
-- now, in each edit box control, when the value
-- of the edit box changes, I have to update txt5
txt5 =3D sum( s ) -- this line probably not needed
-- because onChange() events in txt1..txt4

This was just a brain exercise for me when I realized that there were two=
 ways=20
to go about it, and one didn't involve actual variables. That weirded me =
out,=20
but now I just envision that the controls are really just dynamic variabl=
e=20
holders that really do respond to onChange() events... hehehe. The negati=
ve=20
aspect is you can't do any sequence operations with them!!! That's why th=
e=20
variables are so valuable to me... for instance, the sum() function above=
=2E..

txt5 =3D sum( s ) -- with a variable, can be nice and clean
-- versus...
-- this is condensed, 'cuz you prolly have to extract a value() also...
txt5 =3D getText(txt1) + getText(txt2) + getText(txt3) + getText(txt4) --=
 yuck!!

Modularity is also compromised when you don't use variables. I wonder if =
speed=20
is compromised if you use variables... for instance, if you have the sequ=
ence=20
s above, and in each onChange() event for each txt1...txt4 control you si=
mply=20
change the variable s as required... then call a global updater. You at l=
east=20
have your variable in tact, but is this way going to be slower than anyth=
ing=20
else? Maybe you can just use your variables at some point and not at othe=
r=20
points, but then you've got coordination issues, which might never really=
=20
become a big deal anyway...

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu