Jump to content

Declared variable array, delete then re-create


Recommended Posts

How can you re-use an array to create controls? If you have an treeview (for example), and populate it by stepping through array ($array[$x] = create item), all is good. Now I need to delete the controls (in this case using _gui delete all tree items), and then build the tree back again based off new array values. Using the same array, with less or more values. The tree is built, but all @GUI_CtrlId calls are not handled, I am assuming because the first set of array created variables are still present.

If the array does not change, then all is good. 1+ or - for array size, and the Id is not found in the array.

I will try to hack out a piece of code from my project that works to show you.

later,

Sul

Link to comment
Share on other sites

  • Replies 47
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

I will try to hack out a piece of code from my project that works to show you.

HI,

okay then I'll wait for the example. :lmao:

So long,

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

Sorry, no example. As I was cutting it out, I put a couple msgboxs in and found that my event for watching a checkbox click as also fired when _GUICtrlTreeViewDeleteAllItems was called. If I kill that delete function, the tree is still populated, but it does stop the issue. I think. Back to the help file. Heh.

Sul

Link to comment
Share on other sites

Here is a new question on the matter.

For $x = 1 To Ubound($ar) - 1
   $ar[$x] = guictrlcreatetreemenuitem("text",$treectl)
    guictrlsetonevent(-1,'_func')
Next

Later, need to delete tree items (to clear out). I can find when one of the tree item controls fire, and @GUI_CtrlId let's me find what position in array goes to the control. However, when the gui delete all tree items function is called, the _func event it also firing. I have looked and looked at the help files, but I don't see a way to have a distinction on what can happen.

The action is a check box. I am using BitAND to read the control/gui_check/uncheck.

Can anyone point me to the help file article that might describe an alternate method of calling the check/uncheck event, or how I might achieve being able to tell the difference between a delete event and and check/uncheck event?

later,

Sul

Link to comment
Share on other sites

Here is a new question on the matter.

For $x = 1 To Ubound($ar) - 1
   $ar[$x] = guictrlcreatetreemenuitem("text",$treectl)
    guictrlsetonevent(-1,'_func')
Next

Later, need to delete tree items (to clear out). I can find when one of the tree item controls fire, and @GUI_CtrlId let's me find what position in array goes to the control. However, when the gui delete all tree items function is called, the _func event it also firing. I have looked and looked at the help files, but I don't see a way to have a distinction on what can happen.

The action is a check box. I am using BitAND to read the control/gui_check/uncheck.

Can anyone point me to the help file article that might describe an alternate method of calling the check/uncheck event, or how I might achieve being able to tell the difference between a delete event and and check/uncheck event?

later,

Sul

I am not quite sure I am fully understanding your delema.

Your first question (first post) can be solved by "ReDim" ing your array variables. That with UBound() you would be able to create an array of the proper size. There are some decent examples of this in my CompInfo.au3 Library (link in my sig).

Are the check boxes in the treeview? I must be missing something because I am not recalling the need to BitAND a checkbox state.

JS

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Link to comment
Share on other sites

First, I fill the tree and set event to function

For $i = 1 To UBound($arrFIN) - 1
        If $arrFIN[$i][0] = 1 Then
            $ix = $i 
            $arrFIN[$i][2] = GUICtrlCreateTreeViewItem($arrFIN[$i][1],$treLASTFILTER)
            _GUICtrlTreeViewSetState($treLASTFILTER,-1,48)
            GUICtrlSetOnEvent(-1,"_treeEVENT")
        Else
            $arrFIN[$i][2] = GUICtrlCreateTreeViewItem($arrFIN[$i][1],$arrFIN[$ix][2])
            GUICtrlSetOnEvent(-1,"_treeEVENT")
        EndIf
    NextoÝ÷ Ø×±¶Þ½éí"«~涧ÆîµÈ^rH§Ú,yì!zØ^®ËZµêrº1Ç!yÉ(®éÜç$jëh×6                        ElseIf $arrFIN[$x][0] = 1 Then ; Parent dirctory
                            If BitAND(GUICtrlRead(@GUI_CtrlId),$GUI_CHECKED) Then
                                $arrFIN[$x][1] = "del"
                                GUICtrlSetColor(@GUI_CtrlId,0xFF0000)
                                If $x = UBound($arrFIN) - 1 Then ExitLoop
                                $ix = $x + 1
                                While  1
                                    If $arrFIN[$ix][0] = 1 Or $ix = UBound($arrFIN) - 1 Then ExitLoop
                                    GUICtrlSetColor($arrFIN[$ix][2],0xFF0000)
                                    GUICtrlSetState($arrFIN[$ix][2],$GUI_CHECKED)
                                    $arrFIN[$ix][1] = "del"
                                    $ix+=1
                                WEnd
                                ExitLoop
                            Else
                                $arrFIN[$x][1] = GUICtrlRead(@GUI_CtrlId,1)
                                GUICtrlSetColor(@GUI_CtrlId,0x000000)
                                If $x = UBound($arrFIN) - 1 Then ExitLoop
                                $ix = $x + 1
                                While 1
                                    If $arrFIN[$ix][0] = 1 Or $ix = UBound($arrFIN) - 1 Then ExitLoop
                                    GUICtrlSetColor($arrFIN[$ix][2],0x000000)
                                    GUICtrlSetState($arrFIN[$ix][2],$GUI_UNCHECKED)                     
                                    $arrFIN[$ix][1] = GUICtrlRead($arrFIN[$ix][2],1)
                                    $ix+=1
                                WEnd
                                ExitLoop
                            EndIf

When tree event (checking the box or unchecking) happens, I look to see if array is 1 for parent or 0 for child tree item. If parent, change parent and children. If child, change only child. When calling delete items, every checkbox is affected, and every array (control id) value is fired. After this happens, and array is filled with new data, and tree is made again from new array, the event is never called again. Nor when making the tree, does it assign colors or expand branches. If I take the delete item statement out, then the old data remains, but new data tree items are built as per code states.

Does that explain it any better?

Sul

Link to comment
Share on other sites

First, I fill the tree and set event to function

For $i = 1 To UBound($arrFIN) - 1
        If $arrFIN[$i][0] = 1 Then
            $ix = $i 
            $arrFIN[$i][2] = GUICtrlCreateTreeViewItem($arrFIN[$i][1],$treLASTFILTER)
            _GUICtrlTreeViewSetState($treLASTFILTER,-1,48)
            GUICtrlSetOnEvent(-1,"_treeEVENT")
        Else
            $arrFIN[$i][2] = GUICtrlCreateTreeViewItem($arrFIN[$i][1],$arrFIN[$ix][2])
            GUICtrlSetOnEvent(-1,"_treeEVENT")
        EndIf
    NextoÝ÷ Ø×±¶Þ½éí"«~涧ÆîµÈ^rH§Ú,yì!zØ^®ËZµêrº1Ç!yÉ(®éÜç$jëh×6                        ElseIf $arrFIN[$x][0] = 1 Then ; Parent dirctory
                            If BitAND(GUICtrlRead(@GUI_CtrlId),$GUI_CHECKED) Then
                                $arrFIN[$x][1] = "del"
                                GUICtrlSetColor(@GUI_CtrlId,0xFF0000)
                                If $x = UBound($arrFIN) - 1 Then ExitLoop
                                $ix = $x + 1
                                While  1
                                    If $arrFIN[$ix][0] = 1 Or $ix = UBound($arrFIN) - 1 Then ExitLoop
                                    GUICtrlSetColor($arrFIN[$ix][2],0xFF0000)
                                    GUICtrlSetState($arrFIN[$ix][2],$GUI_CHECKED)
                                    $arrFIN[$ix][1] = "del"
                                    $ix+=1
                                WEnd
                                ExitLoop
                            Else
                                $arrFIN[$x][1] = GUICtrlRead(@GUI_CtrlId,1)
                                GUICtrlSetColor(@GUI_CtrlId,0x000000)
                                If $x = UBound($arrFIN) - 1 Then ExitLoop
                                $ix = $x + 1
                                While 1
                                    If $arrFIN[$ix][0] = 1 Or $ix = UBound($arrFIN) - 1 Then ExitLoop
                                    GUICtrlSetColor($arrFIN[$ix][2],0x000000)
                                    GUICtrlSetState($arrFIN[$ix][2],$GUI_UNCHECKED)                     
                                    $arrFIN[$ix][1] = GUICtrlRead($arrFIN[$ix][2],1)
                                    $ix+=1
                                WEnd
                                ExitLoop
                            EndIf

When tree event (checking the box or unchecking) happens, I look to see if array is 1 for parent or 0 for child tree item. If parent, change parent and children. If child, change only child. When calling delete items, every checkbox is affected, and every array (control id) value is fired. After this happens, and array is filled with new data, and tree is made again from new array, the event is never called again. Nor when making the tree, does it assign colors or expand branches. If I take the delete item statement out, then the old data remains, but new data tree items are built as per code states.

Does that explain it any better?

Sul

That explains alot more for sure. I am most curious as to why you are BitAND'ing the GUICtrlRead().

JS

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Link to comment
Share on other sites

I had assumed that was the way you check for whether a checkbox is checked or not.

Sul

Below is the proper method for checking a check box's state.

If GUICtrlRead(@GUI_CtrlID) = $GUI_CHECKED Then
    ;Do something here
Else
    ;Do something else
EndIf

However @GUI_CtrlID is stated in the helpfile to be only for event functions. I am assuming you are using OnEventMode?

When the tree is made, the check boxes are all unchecked. Clicking on an item will fire the event, regardless of if you click the checkbox or not. So I checke for whehter or not the check box has yes or no, or if nothing, then I do nothing.

Sul

The above code should help in that process...

Let me know how that works out, and if it fixes your problem when you try to delete the tree.

JS

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Link to comment
Share on other sites

No sir, that does not work. Remember that this is a treeview item, with a checkbox style enabled. Here is a peice of the function

ElseIf $arrFIN[$x][0] = 1 Then ; Parent dirctory
                            If BitAND(GUICtrlRead(@GUI_CtrlId),$GUI_CHECKED) Then
                                $arrFIN[$x][1] = "del"
                                GUICtrlSetColor(@GUI_CtrlId,0xFF0000)
                                If $x = UBound($arrFIN) - 1 Then ExitLoop
                                $ix = $x + 1
                                While  1
                                    If $arrFIN[$ix][0] = 1 Or $ix = UBound($arrFIN) - 1 Then ExitLoop
                                    GUICtrlSetColor($arrFIN[$ix][2],0xFF0000)
                                    GUICtrlSetState($arrFIN[$ix][2],$GUI_CHECKED)
                                    $arrFIN[$ix][1] = "del"
                                    $ix+=1
                                WEnd
                                ExitLoop
                            Else
                                $arrFIN[$x][1] = GUICtrlRead(@GUI_CtrlId,1)
                                GUICtrlSetColor(@GUI_CtrlId,0x000000)
                                If $x = UBound($arrFIN) - 1 Then ExitLoop
                                $ix = $x + 1
                                While 1
                                    If $arrFIN[$ix][0] = 1 Or $ix = UBound($arrFIN) - 1 Then ExitLoop
                                    GUICtrlSetColor($arrFIN[$ix][2],0x000000)
                                    GUICtrlSetState($arrFIN[$ix][2],$GUI_UNCHECKED)                     
                                    $arrFIN[$ix][1] = GUICtrlRead($arrFIN[$ix][2],1)
                                    $ix+=1
                                WEnd
                                ExitLoop

The BitAND does work here. To test the method you described, I did exactly as you have said as an IF ENDIF before this whole routine. The message box does not fire with your method as a requirement, but it does fire using the BitAND (those, again, are before any of the above code happens). I believe it is because this is not really a checkbox, but a treeview, maybe a sort of state. If you look at the help file, under GUICtrlRead, you will note that this is the method for a treeview.

Now, the more important issue, is how to call that check/uncheck event, while not allowing the delete items event to also fire the same event. I have banged on it for hours, and still I have a bruised head.

Sul

Link to comment
Share on other sites

No sir, that does not work. Remember that this is a treeview item, with a checkbox style enabled. Here is a peice of the function

;AutoIt Code...

The BitAND does work here. To test the method you described, I did exactly as you have said as an IF ENDIF before this whole routine. The message box does not fire with your method as a requirement, but it does fire using the BitAND (those, again, are before any of the above code happens). I believe it is because this is not really a checkbox, but a treeview, maybe a sort of state. If you look at the help file, under GUICtrlRead, you will note that this is the method for a treeview.

Now, the more important issue, is how to call that check/uncheck event, while not allowing the delete items event to also fire the same event. I have banged on it for hours, and still I have a bruised head.

Sul

Okay, I didnt know that about TreeViews, thanks for that tidbit. So all of the code works, but the problem is when the Delete calls the same function again?

Is there a way I could see all of the code? You could PM it to me if you would like. I will run it and see if I can debug it.

JS

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Link to comment
Share on other sites

Okay, I didnt know that about TreeViews, thanks for that tidbit. So all of the code works, but the problem is when the Delete calls the same function again?

Is there a way I could see all of the code? You could PM it to me if you would like. I will run it and see if I can debug it.

I am happy to have been able to give you some information. I thought I did PM you that yesterday. If you did not get it, let me know and I will resend.

when deleting all the items, set the array to ""

put in a check in the other event for example

CODE: AutoIt

If NOT IsArray($arrFIN) Then Return

I knew I was missing an easy fix. That does keep the event from firing, but there is still an issue.

For this script, I fill the array by reading a file and stringsplit. In the array[x][0] is set 1 for parent, array[x][1] is set 0 for child. Each tree item created sets on event, the code snippet above. The remainder of that snippet is designed to handle children only, while the snippet is for parents.

When clicking on a tree view item, that event is fired. I do not know how to limit the event to only firing upon a check box event, so if you click on an item anywhere, it checks for a CtrlID. If the ID matches a BitAND of check or uncheck, then stuff occurs. Right now a message box pops up if you click on anything.

So, on the initial array build, the resulting tree will always fire the event (and msgbox) no matter where you click, but only do stuff if the Check/Uncheck read is valid.

Using the NOT IsArray() does keep the delete items function from rolling through the entire tree as it deletes each item. I thought that was why my problem existed. However, it seems regardless of whether the event fires for every item deleted, or it is returned because of NOT IsArray(), once the array is declared and filled again, and the tree items populated from the new array, the tree is no longer expanded, and the event no longer fires. All the data is there, but no event to go with it.

Clawing at my mind is that this has something to do with variables not being reused, thus no way to actually fire the event. Don't know why I think that though. Just a nagging thought.

Thank you all for your input.

Sul

Link to comment
Share on other sites

Here is the calling function for the deletion

Func _valsWRITE()
    For $i = 1 to UBound($arrFIN) - 1
        If $arrFIN[$i][1] <> "del" Then
            If StringTrimLeft($arrFIN[$i][1],StringLen($arrFIN[$i][1]) - 1) = ',' Then _
                $arrFIN[$i][1] = StringTrimRight($arrFIN[$i][1],1)
            FileWriteLine($FileOut,$arrFIN[$i][1])
        EndIf
    Next
    FileClose($FileOut)
    FileClose($tmpFile)
    FileDelete($tmpFile)
    GUISwitch($winMAIN)
    GUISetState(@SW_HIDE,$winFinalFilter)
    GUISetState(@SW_SHOW,$winMAIN)
    $arrFIN = ""
    _GUICtrlTreeViewDeleteAllItems($treLASTFILTER)
    MsgBox(0,"","done",1)   
EndFuncoÝ÷ Øw«z+-çîËb¢{aj×â[-ëky殶­sdgVæ2öfÆÄÄ5DdÅDU" Æö6Âb33c¶fÒfÆT÷Vâb33c·F×fÆRà Æö6Âb33c·&RÒfÆU&VBb33c¶f Æö6Âb33c¶"Ò7G&æu7ÆBb33c·&RÂgV÷Cµ²gV÷C² Æö6Âb33c¶'  f÷"b33c¶ÒFòb33c¶%³Ð b33c¶'"Ò7G&æu7ÆBb33c¶%²b33c¶ÒÄ5$Äb f÷"b33c·ÒFòb33c¶'%³Ð bb33c¶'%²b33c·ÒÒgV÷C²gV÷C²FVâ6öçFçVTÆö÷ bb33c·ÒFVâ ô'&FC"b33c¶'$dâÃÂgV÷Cµ²gV÷C²fײb33c¶'%²b33c·Ò VÇ6P ô'&FC"b33c¶'$dâÃÂb33c¶'%²b33c·Ò VæD` æW@ æW@ &TFÒb33c¶'$dåµT&÷VæBb33c¶'$dâÓÕ³5Ð Æö6Âb33c¶Ò f÷"b33c¶ÒFòT&÷VæBb33c¶'$dâÒ bb33c¶'$då²b33c¶Õ³ÒÒFVà b33c¶Òb33c¶ b33c¶'$då²b33c¶Õ³%ÒÒuT7G&Ä7&VFUG&VUfWtFVÒb33c¶'$då²b33c¶Õ³ÒÂb33c·G&TÄ5DdÅDU" ôuT7G&ÅG&VUfWu6WE7FFRb33c·G&TÄ5DdÅDU"ÂÓÃC uT7G&Å6WDöäWfVçBÓÂgV÷Cµ÷G&VTUdTåBgV÷C² VÇ6P b33c¶'$då²b33c¶Õ³%ÒÒuT7G&Ä7&VFUG&VUfWtFVÒb33c¶'$då²b33c¶Õ³ÒÂb33c¶'$då²b33c¶Õ³%Ò uT7G&Å6WDöäWfVçBÓÂgV÷Cµ÷G&VTUdTåBgV÷C² VæD` æW@¤VæDgVæ0oÝ÷ Øw«z+-çîËb¢{ajÜ(®K»-«¢éÝnëg¢ÚkÚºÚ"µÍ[ÈÝYQUS

BRYÝÐ^J   ÌÍØSH[]BQÜ  ÌÍÞHHÈPÝ[
    ÌÍØSHHBBBRY  ÌÍØSÉÌÍÞVÌHHÕRWÐÝY[BBBSÙÐÞ
    ][ÝÉ][ÝË    ][ÝÞYÈÚYHØ][ÝÊBBBBRY ÌÍØSÉÌÍÞVÌHH[ÈÚ[XÝÜBBBBBRY]S
ÕRPÝXY
ÕRWÐÝY
K   ÌÍÑÕRWÐÒPÒÑQ
H[BBBBBIÌÍØSÉÌÍÞVÌWHH   ][ÝÙ[ ][ÝÂBBBBBQÕRPÝÙ]ÛÛÜÕRWÐÝY
BBBBBBQ^]ÛÜBBBBQ[ÙBBBBBBIÌÍØSÉÌÍÞVÌWHHÕRPÝXY
ÕRWÐÝYJBBBBBBQÕRPÝÙ]ÛÛÜÕRWÐÝY
BBBBBBRY]S
ÕRPÝXY
ÑÕRPÝYUY]ÑÙ][Q
    ÌÍÝSTÕSTJK  ÌÍÑÕRWÐÒPÒÑQ
H[BBBBBBQÕRPÝÙ]Ý]JÑÕRPÝYUY]ÑÙ][Q
    ÌÍÝSTÕSTK   ÌÍÑÕRWÕSÒPÒÑQ
BBBBBBBQÕRPÝÙ]ÛÛÜÑÕRPÝYUY]ÑÙ][Q
    ÌÍÝSTÕSTK
BBBBBBBQÜ  ÌÍÚHHHÈPÝ[
    ÌÍØSHHBBBBBBBBRY ÌÍØSÉÌÍÚWVÌHHÑÕRPÝYUY]ÑÙ][Q
    ÌÍÝSTÕSTH[BBBBBBBBIÌÍØSÉÌÍÚWVÌWHHÕRPÝXY
ÑÕRPÝYUY]ÑÙ][Q
    ÌÍÝSTÕSTKJBBBBBBBBBQ^]ÛÜBBBBBBBQ[YBBBBBBS^BBBBBQ[YBBBBBQ^]ÛÜBBBBQ[YBBBQ[ÙRY    ÌÍØSÉÌÍÞVÌHHH[È[ÝÜBBBBBRY]S
ÕRPÝXY
ÕRWÐÝY
K   ÌÍÑÕRWÐÒPÒÑQ
H[BBBBBIÌÍØSÉÌÍÞVÌWHH   ][ÝÙ[ ][ÝÂBBBBBQÕRPÝÙ]ÛÛÜÕRWÐÝY
BBBBBBRY    ÌÍÞHPÝ[
    ÌÍØSHHH[^]ÛÜBBBBBIÌÍÚ^H ÌÍÞ
ÈBBBBBBUÚ[HBBBBBBBRY  ÌÍØSÉÌÍÚ^VÌHHHÜ    ÌÍÚ^HPÝ[
    ÌÍØSHHH[^]ÛÜBBBBBBQÕRPÝÙ]ÛÛÜ ÌÍØSÉÌÍÚ^VÌK
BBBBBBBQÕRPÝÙ]Ý]J   ÌÍØSÉÌÍÚ^VÌK    ÌÍÑÕRWÐÒPÒÑQ
BBBBBBBIÌÍØSÉÌÍÚ^VÌWHH  ][ÝÙ[ ][ÝÂBBBBBBIÌÍÚ^
ÏLBBBBBBUÑ[BBBBBQ^]ÛÜBBBBQ[ÙBBBBBBIÌÍØSÉÌÍÞVÌWHHÕRPÝXY
ÕRWÐÝYJBBBBBBQÕRPÝÙ]ÛÛÜÕRWÐÝY
BBBBBBRY    ÌÍÞHPÝ[
    ÌÍØSHHH[^]ÛÜBBBBBIÌÍÚ^H ÌÍÞ
ÈBBBBBBUÚ[HBBBBBBBRY  ÌÍØSÉÌÍÚ^VÌHHHÜ    ÌÍÚ^HPÝ[
    ÌÍØSHHH[^]ÛÜBBBBBBQÕRPÝÙ]ÛÛÜ ÌÍØSÉÌÍÚ^VÌK
BBBBBBBQÕRPÝÙ]Ý]J   ÌÍØSÉÌÍÚ^VÌK    ÌÍÑÕRWÕSÒPÒÑQ
BBBBBBBBBBBBBIÌÍØSÉÌÍÚ^VÌWHHÕRPÝXY
    ÌÍØSÉÌÍÚ^VÌKJBBBBBBBIÌÍÚ^
ÏLBBBBBBUÑ[BBBBBQ^]ÛÜBBBBQ[YBBBQ[YBBQ[YBS^[[
Link to comment
Share on other sites

I have resolve the issue for the moment by issueing a GUIDelete() command to the GUI with the tree view, then I copied the GUICreate code to a new function. I delete, then create. That seems to take care of it.

The GUI was made on startup, so it's variables should be global. If I delete the GUI, as I understand, AuotIt does not destroy the variables, so they are still loaded. If I then rebuild the GUI, using the same variable names, are they still Global? Or do I need to, in the function, specify thier scope?

Sul

Link to comment
Share on other sites

I have resolve the issue for the moment by issueing a GUIDelete() command to the GUI with the tree view, then I copied the GUICreate code to a new function. I delete, then create. That seems to take care of it.

The GUI was made on startup, so it's variables should be global. If I delete the GUI, as I understand, AuotIt does not destroy the variables, so they are still loaded. If I then rebuild the GUI, using the same variable names, are they still Global? Or do I need to, in the function, specify thier scope?

Sul

In the functions specify their scope. That is what I initially said in my first PM response to you.

Also I did get the PM after I asked you to PM it to me lol.

I am glad you got it resolved.

JS

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Link to comment
Share on other sites

So, you mean that a variable, one it's scope is declared, can have it's scope declared otherwise? I did not realize that. I assumed that since the varible is never really released to 'nothing', that it was static not only in that it is still a loaded entity, but that it would retain it's scope.

That I would guess is a greater incentive to use an option explicit statement. It goes without saying that you should watch how you use or declare variables so that you don't assign a wrong value, but even more so that you don't change the scope. Heh, you can quickly lose your variable that way.

I see now what you meant.

Thanks again,

Sul

Link to comment
Share on other sites

So, you mean that a variable, one it's scope is declared, can have it's scope declared otherwise? I did not realize that. I assumed that since the varible is never really released to 'nothing', that it was static not only in that it is still a loaded entity, but that it would retain it's scope.

That I would guess is a greater incentive to use an option explicit statement. It goes without saying that you should watch how you use or declare variables so that you don't assign a wrong value, but even more so that you don't change the scope. Heh, you can quickly lose your variable that way.

I see now what you meant.

Thanks again,

Sul

A variable can be re-declared in another scope.

Its always safest to declare your variables in the scope you want them in. I declare all of my GUI variables at the top of my script as Global. Even the ones that are part of a function GUI later in the script. Unless its a label or something that will not be used outside of the GUI function.

JS

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Link to comment
Share on other sites

A variable can be re-declared in another scope.

Its always safest to declare your variables in the scope you want them in. I declare all of my GUI variables at the top of my script as Global. Even the ones that are part of a function GUI later in the script. Unless its a label or something that will not be used outside of the GUI function.

JS

JS in my view I find that a bad pratice, prefer to make them local unless I absolutely have to and pass them byref when possible.

Also I try to make sure to use Opt("MustDeclareVars", 1) at the top of my scripts to lessen the possability of mistakes with vars.

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...