Jump to content

Search the Community

Showing results for tags 'scope'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Location


WWW


Interests

Found 2 results

  1. I whittled down much code and have isolated my problem to where a #include is located in the code, but apparently do not understand the scope of #include. In the example code below I open up a window, then when you press Alt+W I open a second window with a List All button. Clicking the List All button invokes a _DebugArrayDisplay(). At line 4 and 50 are the #include <Debug.au3> for the _DebugArrayDisplay(). If I comment out the line 4 #include <Debug.au3> the program crashes. I thought the line 50 #include <Debug.au3> would work however it does not, so I'm concluding I don't understand what' going on. Any assistance greatly appreciated. #AutoIt3Wrapper_run_debug_mode=Y ;use this to debug in console window <--- LOOK #include <Debug.au3> ;for _DebugArrayDisplay() ;<-- commenting this out makes it fail vs #include at line 50 ??? #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <GuiEdit.au3> #include <WindowsConstants.au3> AutoItSetOption("MustDeclareVars", 1) ;create an example window with an edit control Local $hGUI = GUICreate("Test", 500, 400) ;the main window Local $cIDEdit1 = GUICtrlCreateEdit("Edit control #1", 10, 10, 200, 250, Bitor($ES_WANTRETURN, $WS_VSCROLL, $ES_AUTOVSCROLL, $WS_HSCROLL)) GUISetState(@SW_SHOW, $hGUI) ;show it MsgBox(262144, "USAGE", "Example window." &@CRLF&@CRLF& "Press Alt+W (once or twice) after clicking OK to enter window/control mode.") Local $nMsg While 1 ;this is your code main loop $nMsg = GUIGetMsg() If $nMsg <> 0 Then ;we have a message so Switch $nMsg ;Check for GUI events Case $GUI_EVENT_CLOSE ;the GUI is closed red [X] is clicked Exit Case Else ;do nothing EndSwitch ;End running through GUI events. Else ;no message Sleep(100) ;do something in your program EndIf ;---------------------------------------------------------------------------------------------------------------------------+ ;ADD this function into your $nMsg loop after the $nMsg EndIf ;as shown here or in your While 1 loop so it gets executed | _WindowControlOperations() ;let's go into move/adjust window/control operations if Alt+W pressed | ;comment out this function call when all done, or delete it | ;---------------------------------------------------------------------------------------------------------------------------+ WEnd ;------------------------------------------ this code below intended to be in a UDF eventually ---------------------------------------- Local $hDLL = DllOpen("user32.dll") ;also Global to all functions called - DO NOT close as calling program may be using user32.dll ;actually we CAN close it as user's call to same user32.dll will have a different handle #AutoIt3Wrapper_run_debug_mode=Y ;use this to debug in console window <--- LOOK #include-Once #include <Debug.au3> ;for _DebugArrayDisplay() ;<-- this one does not seem to work, only one in user's program above seems to work #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <GuiEdit.au3> #include <Misc.au3> ;for _IsPressed() #include <WindowsConstants.au3> AutoItSetOption("MustDeclareVars", 1) Func _WindowControlOperations() ;called by user program and only continues below if Alt+W pressed else returns to calling program above If NOT ( ((_IsPressed("12") = 1) AND (_IsPressed("57") = 1)) ) Then ;check for Alt+W ;12 ALT key, 57 W key ; default DLL=user32.dll Return(0) ;as Alt+W not pressed Else ;Alt+W pressed to call rest _WindowControlOperationsContinue() EndIf EndFunc ;Func _WindowControlOperations() Func _WindowControlOperationsContinue() ;Alt+W was pressed Global $aWindowControlLog[1][3] = [ ["Window/Control", "Title", "Left, Top, Width, Height"] ] ;element [0] [Row][Column] ;v2a - create an Instructions window Global $iLeft = 0, $iTop = 0, $iWidth = 0, $iHeight = 0 ;init values Global $sStatus = "$iLeft, $iTop, $iWidth, $iHeight" &@CRLF& $iLeft &", "& $iTop &", "& $iWidth &", "& $iHeight ;create main Instructions window Global $hWndInstructions = GUICreate("Instructions", 300, 457) ;the main instructions window Local $sInstructions = "Click List All to list all adjustments made." &@CRLF& _ " " &@CRLF& _ "Click upper right X to exit program." ;create an edit control - into which we'll put the instruction text Local $cIDInstructions = GUICtrlCreateEdit("", 10, 10, 280, 300, Bitor($ES_WANTRETURN, $WS_VSCROLL, $ES_AUTOVSCROLL)) ;no , $WS_HSCROLL)) Global $sStatus = "$iLeft, $iTop, $iWidth, $iHeight" &@CRLF& $iLeft &", "& $iTop &", "& $iWidth &", "& $iHeight Global $hStatus = _GUICtrlEdit_Create($hWndInstructions, $sStatus, 10, 318, 280, 50) Global $idButton_List = GUICtrlCreateButton("List All" &@CRLF& "Sizes/Positions", 152, 412, 139, 35, 0x2000) ;create control button ,0x2000=multi-line GUISetState(@SW_SHOW, $hWndInstructions) ;show window and edit controls ControlSetText("", "", $cIDInstructions, $sInstructions) ;show instructions ControlSetText("", "", $hStatus, $sStatus) ;show status _While1() ;enter our message loop Return(0) ;to main calling program EndFunc ;Func _WindowControlOperationsContinue() Func _While1() Local $nMsg While 1 ;look for button presses $nMsg = GUIGetMsg() If $nMsg <> 0 Then ;we have a message so Switch $nMsg ;Check for GUI events Case $GUI_EVENT_CLOSE ;the GUI is closed red [X] is clicked GUIDelete($hWndInstructions) ;destroy the Instructions window and all controls therein Return(0) ;to Func _WindowControlOperationsContinue() Case $idButton_List _DebugArrayDisplay($aWindowControlLog, "$aWindowControlLog") ;<-- problem here with #include <Debug.au3> scope Case Else ;do nothing EndSwitch ;End running through GUI events. Else ;no message - do nothing ;no message EndIf WEnd ;While 1 EndFunc ;Func _While1()
  2. Using this script you can analyze the old scripts and search for keywords like: Local Global Dim Static Search only the above keywords used inside the Loop statements like: For ... Next While ... Wend Do ... Until For ... In ... Next This script parses a other script and reports on incorrect variable declarations within loops. Remark: Variable declaration is needed but it should be done outside the loop. Basic information of this script: Currently, the script provides two functions: _Check_Local_In_Loop__File() _Check_Local_In_Loop__Folder () Using functions: _Check_Local_In_Loop__File() You can specify a single file *. Au3 file will be checked for using the keyword "Local" inside the Loop Statements According to the used parameters the result will be send to SciTE console, Clipboard, eventualy displayed using _ArrayDisplay(). Using functions: _Check_Local_In_Loop__Folder () You can specify the folder containing the files *. Au3 All files in the given directory will be subject to analysis like above. The use of parameters, the internal functions: _Check_Local_In_Loop_Check_File ($ HFile, $ fArrayDisplay = True) additionally determines the manner of presenting the results of the work of this script. First Version 2013/12/03 02:00 AM EXAMPLE 1: Run that script in Current Beta: AutoIt 3.3.9.23 select Au3 file for example: array.au3 (from include AutoIt 3.3.9.23) results: Row |Col 0 0|While 1 1|Local $aiCurItems[1] = [0] 2|Local $aiCurItems[1] = [0] Explanation: Open this file in SciTE.exe and search text: Local $aiCurItems[1] = [0] You'll notice that this text is inside: While 1 EXAMPLE 2: Run that script in Current Beta: AutoIt 3.3.9.23 select Au3 file for example: ie.au3 (from include AutoIt 3.3.9.23) results: Row |Col 0 0|For $o_window In $o_ShellWindows 1|Local $f_found = False 2|Local $f_found = False Explanation: Open this file in SciTE.exe and search text: Local $f_found = False You'll notice that this text is inside: For $o_window In $o_ShellWindows EXAMPLE 3: Run that script in Current Beta: AutoIt 3.3.9.23 select Au3 file for example: GuiListView.au3 (from include AutoIt 3.3.9.23) results: Row |Col 0 0|For $i = 0 To $items - 1 1|Local $a_indices[2] 2|Local $a_indices[2] Explanation: Open this file in SciTE.exe and search text: Local $a_indices[2] You'll notice that this text is inside: For $i = 0 To $items - 1 EXAMPLE 4: Run that script in Current Beta: AutoIt 3.3.9.23 select Au3 file for example: array.au3 (from include AutoIt 3.3.8.1) results: Row |Col 0 0|While 1 1|Local $sClip = "" Local $aiCurItems[1] = [0] 2|Local $aiCurItems[1] = [0] Row |Col 0 0|For $x = 1 To 255 1|Local $sFind = _ArraySearch($avArray, Chr($x), 0, 0, 0, 1) 2|Local $sFind = _ArraySearch($avArray, Chr($x), 0, 0, 0, 1) Explanation: Open this file in SciTE.exe and search text: Local $sClip = "" Local $aiCurItems[1] = [0] You'll notice that this text is inside: While 1 search text: Local $sFind = _ArraySearch($avArray, Chr($x), 0, 0, 0, 1) You'll notice that this text is inside: For $x = 1 To 255 Version 2013/12/03 05:34 PM _Check_Local_In_Loop__Folder() ---> FileSelectFolder () parameter $fArrayDisplay = True parameter $fReturnAsString = False Version 2013/12/04 01:42 AM removed parameter $fReturnAsString added output to SciTE console removed not needed info from SciTE console Fixed problem with Loop statements on the begining of script added option (MsgBox) to choose "File or Folder" added option (MsgBox) to choose "Open file" see attached au3 file !!! NEW Version 2013/12/05 01:40 AM added checking for Global Dim and Static some other modyfication in REGEXP pattern see attached: BestCodingPractice_Analyzer__Version_20131205_0140_AM.zip BestCodingPractice_Analyzer.au3 BestCodingPractice_Analyzer__Version_20131205_0140_AM.zip
×
×
  • Create New...