Sign in to follow this  
Followers 0
tweakster2010

If Variable And Variable2 Etc Etc

10 posts in this topic

How long can you write an If then Statement where you include a large number of Ands?

Reason I ask is I have a GUI that has a treeview which basically if you dont click onto the 3rd tier I want it to post an error but if you click into the third tier I want it to read tier 1 2 and 3 and be able to insert them into text(my main issue i am trying to do which technically isnt an issue just super long the way I figured to do it is getting the subtrees out of the choices but I can see I am able to read it.

  1. First
    1. A
      1. Alpha
      2. Bravo
      3. Charlie
    2. B
    3. C
  2. Second
  3. Third

Basically I want that I chose Alph in A of First to be read First A Alpha and not just Alpha.

I am struggling to break that part down and just convert to 3 combo boxes with the choices clearing etc based on previously choice >.>

What I had so far is reading it as numbers and not the actual text but the example reads it as text but not the full path information the way I want it to. So the Idea is I need to conver the example to read the full path but I am unsure how to do that.

If GuiCtrlRead($First) AND GuiCtrlRead($Alpha)) = False Then
   MsgBox($MB_SYSTEMMODAL, "Error", "Error didn't drill deep enough! Variable" & GUICtrlRead($First))
EndIf
If GuiCtrlRead($Alpha) Then
   MsgBox($MB_SYSTEMMODAL, "Error", "Worked" & GuiCtrlRead($ALpha))
EndIf

I know this isnt what I want and $alpha is spawned from submenu of $first and then $A.

I also know i can throw this in and get to where I see what is being in there but I dont know how to view it all and not just the last choice.

$idItem = GUICtrlRead($idTreeview) ; Get the controlID of the current selected treeview item
                If $idItem = 0 Then
                    MsgBox($MB_SYSTEMMODAL, "TreeView Demo", "No item currently selected")
                Else
                    $sText = GUICtrlRead($idItem, 1) ; Get the text of the treeview item
                    If $sText == "" Then
                        MsgBox($MB_SYSTEMMODAL, "Error", "Error while retrieving infos about item")
                    Else
                        MsgBox($MB_SYSTEMMODAL, "TreeView Demo", "Current item selected is: " & $sText)
                    EndIf
                EndIf

Any extra insight or help a guy who is struggling to understand the treeview portion out is EXTREMELY appreciated. I already labeled my full treeview and rather not have to break it down to combos but I know I can do the Combos (got most of the form as combos already LOL)

Share this post


Link to post
Share on other sites



#3 ·  Posted (edited)

I am sorry JohnOne but I dont understand the remark. Is it in reference to the help file? Which is where I based most of what I cropped but I can see me missing another section (tends to happen and I go over it a few times trying to figure out the right way) or a shameless bump to find an answer to? Or was what I typed a little too confusing, which this morning looking over again may be the case as I am noticing a jump around >.>

I do believe my struggle is the treeview has to be converted to text which i gathered from the helpful but the main thing I am wondering is how to get it to read the full tier of a 3 tier tree 1->2->3 vs just1 or 2 or 3. Helpful directs to 1 or 2 or 3 from it. I just am failing hard on converting it to reading 1->2->3.

Thanks again for any help. :)

 

This was my final attempt before I came to the forums at which I tried GuiGetMsg as well since that was located in the helpfile.

If GuiCtrlRead($First) AND GuiCtrlRead($Alpha)) = False Then
   MsgBox($MB_SYSTEMMODAL, "Error", "Error didn't drill deep enough! Variable" & GUICtrlRead($First))
EndIf
If GuiCtrlRead($Alpha) Then
   MsgBox($MB_SYSTEMMODAL, "Error", "Worked" & GuiCtrlRead($ALpha))
EndIf

This gives me just the info provided on the selection, i just do not know how to get it to pull the upper tier from the selection  :(.

Local $idItem
            $idItem = GUICtrlRead($idTreeview)
            $sText = GUICtrlRead($idItem, 1) ; Get the text of the treeview item
                    If $sText == "" Then
                        MsgBox($MB_SYSTEMMODAL, "Error", "Error while retrieving infos about item")
                    Else
                        MsgBox($MB_SYSTEMMODAL, "TreeView Demo", "Current item selected is: " & $sText)
                    EndIf

I guess its safe to say im very bad at understanding the treeview portion :/

Thanks again for any help. :)

Edit to correct layout to be a little less confusing.

Edited by tweakster2010

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

$hGUI = GUICreate("UI", 350,575)

Local $idTreeview = GUICtrlCreateTreeView(75, 5, 200, 150)
Local $Main = GUICtrlCreateTreeViewItem("Main", $idTreeview)
   Local $alpha = GUICtrlCreateTreeViewItem("Alpha", $Main)
      Local $One = GuiCtrlCreateTreeViewItem("One", $Alpha)

$Button1 = GUICtrlCreateButton("Button1", 100, 525)

Case $Button1

Local $idItem
$idItem = GUICtrlRead($idTreeview)
$sText = GUICtrlRead($idItem, 1) ; Get the text of the treeview item
If $sText == "" Then
MsgBox($MB_SYSTEMMODAL, "Error", "Error while retrieving infos about item")
Else
MsgBox($MB_SYSTEMMODAL, "TreeView Demo", "Current item selected is: " & $sText)
EndIf
 

This is basically the portion of what I am focused on. Hope this helps identify what my goal is, but basically if I can get it to read the tiers then it moves to variable limit question about reading all my tree options (currently 20+ options).

Thanks, Hope i was posting the portiong you were referring to since posted 2 questions in the end relating to this. >.> Sorry if its confusing at all. I am in a meeting while doing this >.>

For some reason the code broke out and i editted it to get it back in the code boxes as a new code box >.>

Edited by tweakster2010

Share this post


Link to post
Share on other sites

your remark finally dawned me in the right direction, i was only looking at the create and zoned out about the guictrltreeview_ other examples. I will post my results later when I have time to devote to it, but right now i got another project I gotta work on. Thank you john, you responding helped me revisit the helpfile and stop having an airhead moment. :)

Share this post


Link to post
Share on other sites

To be honest, I'm getting the deja-vu here.

Melba23 answered this question I'm certain of it.

Perhaps it was lost in the forum glitch the other day.

The answer was _GUICtrlTreeView_??? some function or other which returns the full treeview path.

Sorry cannot remember which one, never used that control.


AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

That may be what happened, during the weekend i dont really frequent the forums and if it was posted and lost that may explain it. But none the less I was being an airhead, been good about searching the helpfile and forums most of the time just this time I got so far ahead of myself on 1 thought i missed the fact the functions are there. :(

Share this post


Link to post
Share on other sites

The Simple answer is using _GuiCtrlTreeView_GetTree. All I have to do is pull strings out of it which shouldnt be too hard. :) Thank you for the enlightment of my moment. :)

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

I wanted to give up an updated label for anyone else to have incase they end up doing the same thing I did and would like a simple solution.

The Button i have it tied to checks when tree item is selected and then labels them into the array 1/2/3. For me my next step is writing array1 into a category, 2 into a subcategory, and 3 into a class. (ticketing system) :)

Local $idItem
            $idItem = GUICtrlRead($idTreeview)
            $sText = GUICtrlRead($idItem, 1) ; Get the text of the treeview item
                    If $sText == "" Then
                        MsgBox($MB_SYSTEMMODAL, "Error", "Error while retrieving infos about item")
                    Else
                        MsgBox($MB_SYSTEMMODAL, "TreeView Demo", "Current item selected is: " & $sText & "   " & _GUICtrlTreeView_GetTree($idTreeview))
                    EndIf
    Local $aArray = StringSplit(_GUICtrlTreeView_GetTree($idTreeview), '|', $STR_ENTIRESPLIT) ; Pass the variable to StringSplit and using the delimiter "|".
        MsgBox(0, "testing", $aArray[1] & "  "  & $aArray[2] & "   " & $aArray[3])

Hope others might find this useful :)

EDIT: Just wanted to add this also reduces me needing to add a lot of If variable and variable that continues on and on. I was going about it completely wrong at first and made it way more complicated than it needed to be :)

Edited by tweakster2010

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
Sign in to follow this  
Followers 0