tweakster2010

Unique error involving variables.

5 posts in this topic

Ok my entire script is a little too big to squeeze it all in but I think I have it narrowed down to if then statements involving Active Directory. I dont think its an Active Directory issue but the way I may be using my If and then. Meaning without my If then statement it works fine. With my If then statement it works for 1 part of the statement but the other it doesnt.

  1. Scenario 1 Direct access for 1 User (picked via Directory List) works fine
  2. Scenario 2 Direct access for 2nd User (picked via Different Directory List) works fine
  3. Scenario 3 If then applied to both users. (User 1 works user 2 does not )
  4. Scenario 4 If then swapped around User 1 being the 2nd user now and user 2 being the first) The one that worked is still working the one that did not work is still not working.

After the Check it moves to a While loop for accessing the links and programs as Cases.

Func Program()
Local $sFQDN_User = _AD_SamAccountNameToFQDN(GuiCtrlRead($Username1))

; Get an array of group names (FQDN) that the current user is immediately a member of
Local $aUser = _AD_GetUserGroups(GuiCtrlRead($Username1))
Local $sFQDN_Group = $aUser[1]

; Check the group membership of the specified user for the specified group
Local $iResult = _AD_IsMemberOf("Identifier 1", $sFQDN_User)
Local $iResult1 = _AD_IsMemberOf("Identifier 2", $sFQDN_User)

If $iResult = True AND $iResult1 = False Then

Now I can swap result 1 and 2 with identifier 1 and 2 and the same one works. 

Local $emailMenu = TrayCreateMenu("Email")
TrayCreateItem("")
Local $idExit = TrayCreateItem("Close")

Primary example of the Menu its creating and then after all menus/items are created it goes to a While to call the case of each click.

When I compile it, it reports an error with variables. My question here is are my variables being declared like above in each "if then" statement crashing it? I would imagine since both identifiers are not looping into each other that it wouldnt double dip either. Just odd but I know im totally missing something and ive been staring at it for awhile now. ><

Share this post


Link to post
Share on other sites



It would help if you could post the error messages when compiling.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Thats the thing no error message at all during compiling. The issue he gets is variable driven saying Line 1739: (file path where he saves the .exe)

Error: Variable used without being declared.

Now to clarify I am in a different group than him and it works for me no line error but for him he gets the line error (he is in the group that does not function when the If then statement is in place but works if there is no if then statement)

Case $ticketprogram
    ShellExecute("File path to ticket program")

This is the case I use for launching programs in the list that is populated after it looks for who is listed.

Local $ticketprogram = TrayCreateItem("Case being used above", $Menu)

The local ticketprogram being used is in both circumstances, I think that may be how I broke it basically. Leading me to believe my only solution would be have everytrhing that is mirrored on both logins go first then check users and populate the differences. that would remove the double variables but I was doing this as a test to check my if then statements to make sure I hit both correctly first. I am still pretty new to some of the principles and was reading the forums yesterday about understanding global vs local in autoit and I was pretty sure I used it in the correct sense but maybe I am mistaken. :/ 

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

ok I removed the iresults as i dont really need it. I am pretty sure its my If then comparison on the ismember of ><

I guess this will show my noviceness in a second. Is it likely the reason its crashing for the other user due to the while loop has Cases that he doesnt have?

My if then comparison ends then I have the While loop

Local $Service = TrayCreateItem("Service", $Menu)

    EndIf
EndIf

While 1
    Switch TrayGetMsg()

Case $Service
    ShellExecute("Path for Service")

Which i guess I am asking. Should I have a while loop located in each If statement? I thought i was sure it shouldnt be but thats my next test. >.>

Edited by tweakster2010

Share this post


Link to post
Share on other sites

Ok so the solution i used was to include the while loop in each if then statement.

My over all issue ended up being I was using defined variables from both sides but only 1 side had access to all of em. So thats where my variables tanked at :(. Thank you for the effort, was beating my head around this for 2 days lol.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now