KiXforms Forum Index KiXforms
The Forum for the KiXforms Community
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 Quick Links 
Site News
Downloads
Documentation
Donations
Script Archive
Tracking Systems

$checkbox[$r] -- error in expression

 
Post new topic   Reply to topic    KiXforms Forum Index -> Advanced Scripting
View previous topic :: View next topic  
Author Message
danilda
KiXforms Follower
KiXforms Follower


Joined: 20 Jul 2007
Posts: 16

PostPosted: Thu Aug 23, 2007 5:17 pm    Post subject: $checkbox[$r] -- error in expression Reply with quote

I am having problems with this line of code:

$checkBox[$r] = $GroupBox2.Controls.CheckBox($aresults[$r,$c], $h, $i, 240, 15)

I keep getting this message "error in expression". According to what I have been reading, this should work. Can anyone provide any guidance? Below is the entire code.

Thanks -- dee


Break On
$System = CreateObject("Kixtart.System")
;************* Form **************
$Form = $System.Form()
$Form.BackColor = 212,208,200
$Form.Height = 130
$Form.Left = -4
$Form.Text = "Create Network User Application"
$Form.Top = -118
$Form.Width = 1273
;**************************************

dim $h, $i, $counter
$GroupBox2 = $Form.Controls.GroupBox("Groups/Distribution Lists:", 0, 120, 1265, 605)
; == Return the Name, AdsPath and members of all groups =========
$aAttributes = "Name"
$sADsPath = "LDAP://"+GetObject("LDAP://rootDSE").Get("defaultNamingContext")
$strFilter = "(&(objectClass=group)(!sAMAccountName=IT Department)(!sAMAccountName=Sales-1))"
$aResults = fnLDAPQuery($aAttributes,$sADsPath,$strFilter,"name")

For $r = 0 to Ubound($aResults)
For $c = 0 to UBound($aresults,2)

if $i = 600
$h=$h+250
$i = 15
endif

$checkBox[$r] = $GroupBox2.Controls.CheckBox($aresults[$r,$c], $h, $i, 240, 15)

$i=$i+15

Next
Next

Function fnLDAPQuery($What,Optional $From,Optional $Filter,Optional $OrderBy,Optional $Scope,
Optional $User,Optional $Pswd)

Dim $oCon,$oCMD,$oRS,$sQ,$aR,$C,$R

$sQ="<"+Iif($From="","LDAP://"+GetObject("LDAP://rootDSE").Get("defaultNamingContext"),
$From)+">;"+$Filter+";"+Iif(VarType($What)>8192,Join($What,','),$What)+";"+
Iif($Scope<>"base" AND $Scope<>"onelevel","subtree",$Scope)

$oCon=CreateObject("ADODB.Connection")
$oCon.Provider="ADsDSOObject"
$oCon.Properties("Encrypt Password").Value=1
$oCon.Properties("ADSI Flag").Value=1
If $User AND $Pswd
$oCon.Properties("User ID").Value=$User
$oCon.Properties("Password").Value=$Pswd
EndIf
$oCon.Open("Active Directory Provider")

$oCMD=CreateObject("ADODB.Command")
$oCMD.ActiveConnection=$oCon
$oCMD.CommandText=$sQ
$oCMD.Properties("Page Size").Value=1000
$oCMD.Properties("Timeout").Value=30
$oCMD.Properties("Cache Results").Value=0

If InStr($OrderBy,"distinguishedName")
$oRS=CreateObject("ADODB.Recordset")
$oRS.CursorLocation=3
$oRS.Sort=$OrderBy
$oRS.Open($sQ,$oCon,0,1,1)
Else
If $OrderBy
$oCMD.Properties("Sort On").Value=$OrderBy
EndIf
$oRS=$oCMD.Execute
EndIf
If @ERROR Exit @ERROR EndIf
If $oRS.BOF AND $oRS.EOF Exit @ERROR EndIf

$aR = $oRS.GetRows()
Dim $aFR[Ubound($aR,2),Ubound($aR,1)]
For $R=0 to Ubound($aR,2)
For $C=0 to Ubound($aR,1)
$aFR[$R,$C]=$aR[$C,$R]
Next
Next

$fnLDAPQuery=$aFR
EndFunction
Back to top
View user's profile Send private message
pearly
KiXforms Aficionado
KiXforms Aficionado


Joined: 27 Jan 2004
Posts: 332

PostPosted: Thu Aug 23, 2007 5:54 pm    Post subject: Reply with quote

Can you place your code in code tags so it's easier to read? Thanks Wink
Back to top
View user's profile Send private message
danilda
KiXforms Follower
KiXforms Follower


Joined: 20 Jul 2007
Posts: 16

PostPosted: Thu Aug 23, 2007 5:57 pm    Post subject: Reply with quote

Here you go.

Code:
Break On
$System = CreateObject("Kixtart.System")
;************* Form **************
$Form = $System.Form()
$Form.BackColor = 212,208,200
$Form.Height = 130
$Form.Left = -4
$Form.Text = "Create Network User Application"
$Form.Top = -118
$Form.Width = 1273
;**************************************

dim $h, $i, $counter
$GroupBox2 = $Form.Controls.GroupBox("Groups/Distribution Lists:", 0, 120, 1265, 605)
; == Return the Name, AdsPath and members of all groups =========
$aAttributes = "Name"
$sADsPath = "LDAP://"+GetObject("LDAP://rootDSE").Get("defaultNamingContext")
$strFilter = "(&(objectClass=group)(!sAMAccountName=IT Department)(!sAMAccountName=Sales-1))"
$aResults = fnLDAPQuery($aAttributes,$sADsPath,$strFilter,"name")

For $r = 0 to Ubound($aResults)
For $c = 0 to UBound($aresults,2)

if $i = 600
$h=$h+250
$i = 15
endif

$checkBox[$r] = $GroupBox2.Controls.CheckBox($aresults[$r,$c], $h, $i, 240, 15)

$i=$i+15

Next
Next

Function fnLDAPQuery($What,Optional $From,Optional $Filter,Optional $OrderBy,Optional $Scope,
Optional $User,Optional $Pswd)

Dim $oCon,$oCMD,$oRS,$sQ,$aR,$C,$R

$sQ="<"+Iif($From="","LDAP://"+GetObject("LDAP://rootDSE").Get("defaultNamingContext"),
$From)+">;"+$Filter+";"+Iif(VarType($What)>8192,Join($What,','),$What)+";"+
Iif($Scope<>"base" AND $Scope<>"onelevel","subtree",$Scope)

$oCon=CreateObject("ADODB.Connection")
$oCon.Provider="ADsDSOObject"
$oCon.Properties("Encrypt Password").Value=1
$oCon.Properties("ADSI Flag").Value=1
If $User AND $Pswd
$oCon.Properties("User ID").Value=$User
$oCon.Properties("Password").Value=$Pswd
EndIf
$oCon.Open("Active Directory Provider")

$oCMD=CreateObject("ADODB.Command")
$oCMD.ActiveConnection=$oCon
$oCMD.CommandText=$sQ
$oCMD.Properties("Page Size").Value=1000
$oCMD.Properties("Timeout").Value=30
$oCMD.Properties("Cache Results").Value=0

If InStr($OrderBy,"distinguishedName")
$oRS=CreateObject("ADODB.Recordset")
$oRS.CursorLocation=3
$oRS.Sort=$OrderBy
$oRS.Open($sQ,$oCon,0,1,1)
Else
If $OrderBy
$oCMD.Properties("Sort On").Value=$OrderBy
EndIf
$oRS=$oCMD.Execute
EndIf
If @ERROR Exit @ERROR EndIf
If $oRS.BOF AND $oRS.EOF Exit @ERROR EndIf

$aR = $oRS.GetRows()
Dim $aFR[Ubound($aR,2),Ubound($aR,1)]
For $R=0 to Ubound($aR,2)
For $C=0 to Ubound($aR,1)
$aFR[$R,$C]=$aR[$C,$R]
Next
Next

$fnLDAPQuery=$aFR
EndFunction
Back to top
View user's profile Send private message
danilda
KiXforms Follower
KiXforms Follower


Joined: 20 Jul 2007
Posts: 16

PostPosted: Mon Sep 10, 2007 1:23 pm    Post subject: Reply with quote

For those interested, below is the answer to my question. I added $checkboxes variable and then used that to create my checkboxes.


global $Checkboxes[UBound($aresults)], $h, $i

$checkboxes[$r] = $GroupBox5.Controls.CheckBox($aresults[$r,$c], $h, $i, 250, 15)
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    KiXforms Forum Index -> Advanced Scripting All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group