briannz556
(Getting the hang of it)
2005-07-10 12:15 PM
setting logon hours for a group

Hi There
I'm putting together a kixform that sets allow/deny logon hours for a group of students in AD.

I need to be able to cycle through 25 checkboxes on a kixform and action a function call whenever a checkbox is ticked. The boxes are named $CheckBox1 to $CheckBox25. Is it possible to convert a string into a variable name? If so, how?

For example, it would be nice to be able to do:

Code:

for $day = 1 to 5
for $period = 1 to 5
if somefunction('$$' + 'CheckBox' + Val(5*$day + $period - 5) +'.value') <> ''
action()
endif
next
next



But I'm not sure if "somefunction" exists or even if this is possible?

Can someone offer any ideas?

Cheers


Sealeopard
(KiX Master)
2005-07-10 03:35 PM
Re: setting logon hours for a group

Somefunction is something you'd write yourself, thus you should know whether it exists.

Les
(KiX Master)
2005-07-10 04:23 PM
Re: setting logon hours for a group

I don't get it. Regardless of which checkbox is checked, your psuedo-code would perform the same action since there is only one action in the loop. That, and correct me if I am wrong, but I don't think checkbox has a value property.

What I think you need to do is to check the checkbox.checked property on each one and perform the specific action accordingly.


Les
(KiX Master)
2005-07-10 04:27 PM
Re: setting logon hours for a group

BTW, you can build dynamic $CheckBoxX.checked code constructs using Execute() but as I mentioned above, I don't see the point in it since at some stage in the code you will have to enumerate them individually anyway.

Sealeopard
(KiX Master)
2005-07-10 04:43 PM
Re: setting logon hours for a group

Adn you should always use
Code:

$rc=setoption('NoVarsInStrings','ON')


as it makes coding KiXforms scripts a lot easier.


maciep
(Korg Regular)
2005-07-10 05:28 PM
Re: setting logon hours for a group

check out the Execute() Function

For example (not tested at all)
Code:

for $j = 1 to 25
$ = Execute("$$checked = $$Checkbox" + $j + ".Checked")
if $checked
? "Checkbox" + $j + " is checked"
else
? "Checkbox" + $j + " is not checked"
endif
next



Les
(KiX Master)
2005-07-10 05:45 PM
Re: setting logon hours for a group

Hmmm...
NoVarsInStrings non-compliant...

How far is Pittsburgh from Boston?


maciep
(Korg Regular)
2005-07-10 06:20 PM
Re: setting logon hours for a group

a safe distance away

LonkeroAdministrator
(KiX Master Guru)
2005-07-10 08:12 PM
Re: setting logon hours for a group

just change:
$ = Execute("$$checked = $$Checkbox" + $j + ".Checked")

to:
$ = Execute("$"+"checked = $"+"Checkbox" + $j + ".Checked")

and it is compliant.
actually, I think kixtart acts wrong there.
even though no vars in strings is turned on, double dollar should be translated to single, just like manual says.


briannz556
(Getting the hang of it)
2005-07-11 12:45 AM
Re: setting logon hours for a group

Thanks for that Maciep (and Lonkero for correction). Just what i didn't know and works as required.

As to Les's comment, I was trying to show what the construct was that i wanted NOT the exact use for the construct. Sorry if it fazed you.

Appreciate all the excellent thoughts.