Page 1 of 1 1
Topic Options
#161398 - 2006-05-01 02:23 AM dynamically creating checkboxes
Gilrim Offline
Fresh Scripter

Registered: 2005-07-19
Posts: 20
I'm loading a serverlist from a csv (see this thread), and need to create checkboxes from an array called $serverGroups. I've tried something like this:
Code:
CreateCheckboxes($serverGroups)
Function CreateCheckboxes($boxes)
For Each $item In $boxes
logLine($item)
execute ('$$item = $Form.Controls.CheckBox()')
execute ('$$item.CheckState = 0')
execute ('$$item.Left = 12')
execute ('$$item.Text = "$item"')
execute ('$$item.Top = 150')
execute ('$$item.OnClick = logLine("blah")')
Next
EndFunction


but that doesn't quite do it :P

any suggestions?

Top
#161399 - 2006-05-01 03:29 AM Re: dynamically creating checkboxes
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Ok, you asked for it you got it ...

Code:

Function CreateCheckboxes($boxes)
$Top = 10
For Each $item In $boxes
$=Execute('$$$item = $$Form.Controls.CheckBox()')
$=Execute('$$$item.CheckState = 0')
$=Execute('$$$item.Left = 12')
$=Execute('$$$item.Text = "$item"')
$=Execute('$$$item.Top = $Top')
$=Execute('$$$item.OnClick = "logLine('+"'"+'blah'+"'"+')"')
$Top = $Top + 30
Next
EndFunction




Top
#161400 - 2006-05-01 04:07 PM Re: dynamically creating checkboxes
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
shawn, did you do it yourself or did you get some help from cappy or some other executioner?

I still like the idea of not executing.
thus, you could just do something along these lines:
Code:

Function CreateCheckboxes($boxes)
dim $,$items[ubound($boxes)]
For $=0 to ubound($boxes[$])
logLine($boxes[$])
$items[$] = $Form.Controls.CheckBox()
$items[$].CheckState = 0
$items[$].Left = 12
$items[$].Text = $boxes[$]
$items[$].Top = 150
$items[$].OnClick = logLine("blah")
Next
EndFunction

_________________________
!

download KiXnet

Top
#161401 - 2006-05-01 04:15 PM Re: dynamically creating checkboxes
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
I hate seeing NoVarsInStrings non-compliant snippets posted by the pros. The poor noobs will have a hard time adjusting it.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#161402 - 2006-05-01 05:07 PM Re: dynamically creating checkboxes
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
I would normally have done the NoVarsInStrings version but a) It was enough work just figgering the VarsInString version, and b) it would look about twice as cryptic as it already does. I will leave it to you Les to post the NoVarsInString version.

Jooel - I agree - The control array version is so much better.

Top
#161403 - 2006-05-01 05:13 PM Re: dynamically creating checkboxes
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Quote:

I will leave it to you Les to post the NoVarsInString version.




Hate is such a strong word... especially if it means work for me.

Let Cappy the Executioner do it.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#161404 - 2006-05-01 11:19 PM Re: dynamically creating checkboxes
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Hehee, Cappy will have a field-day ... seriously though, think we lost the Habeebster about 20 posts ago ;0)
Top
#161405 - 2006-05-02 09:20 AM Re: dynamically creating checkboxes
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Nope,

I won't do the NoVarsInStrings code...
The last code 'snippet' where I overdid that execute() thing was KiXtris (counting 553 execute()-statements in 1.02 [yet private]). In the mean time I do code my serious projects with NoVarsInstrings, Explicit and NoMacrosInStrings set to on.

I just don't see the whole picture here, but what about utilizing expando objects on that dynamic checkboxes ?

Just a thought... code as you like
_________________________



Top
#161406 - 2006-05-02 09:37 AM Re: dynamically creating checkboxes
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Oh well,

I do see a part of the whole picture though.
You write a tool that generates rdp-connection lists (*.rdp) reading from csv - files, right?

So, you want to be able to exclude marked Servers, or do your action only on marked items?
What about reading that csv-file (you got that already) and displaying them in a ListView to the user (set MultiSelect to true) then place a button 'generate'(enable/disable the button based on amount of Selected items) and read through the SelectedItems Collection, generating the file based on the content of selected rows ?


Edited by Jochen (2006-05-02 09:39 AM)
_________________________



Top
#161407 - 2006-05-02 10:13 AM Re: dynamically creating checkboxes
Gilrim Offline
Fresh Scripter

Registered: 2005-07-19
Posts: 20
Your right as to what I'm attempting to do. Thing is though, the output from this script is to be used as a QuickLaunch menu, aligned to the very edge of the menu. This gives you a menu with pretty much the same functionality as the start menu. That is: each group of servers will make one directory, containing it's respective server-rdp files. Should look something like this:


thus it would make more sense to allow each admin to select groups of servers to be generated, than selecting each server specifically (the list would be *long*).

I'm gonna have a shot at the generating of checkboxes in a little while, and report back on how that works out. (Btw: when it's done I could post the full script somewhere if it's of any use?)

Top
#161408 - 2006-05-02 12:29 PM Re: dynamically creating checkboxes
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Of course,

we, the collective, love to see the fruits of our helpfulness, and the efforts of others.

The Screenshot you placed here is of course not your current script but a third party app, yes ?

Well, on the other side you should be able to code a rdp launcher app with kf/kixtart.
Let's see where this project leads to ...
_________________________



Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 1046 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.066 seconds in which 0.027 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org