Jump to content

Script freezes


Recommended Posts

Hi, I have been using AutoIT on and of for some years now. Just for some quick apps to test some things. Like this script: test VPN tunnel / connectivity issues. It has been trown together quickly jacking pieces of script from all over the form. You might recognize some 😉 Thanks all for that 💪

But... Now I have this issue for my script freezing. Sometimes after less then 100 cycles, sometimes it runs for more then 1500 cycles, but in the end it always freezes. My PC is (for testing purposes) set to not hibernate tha,t kills the script for sure but I do not mind that. The script does not freeze on windows lock.

I've been spending many evenings for now to do all kinds of tweaks to find the error. First I tought is was froze on the Sleep function, so I made my own. This sleep function has also the benefit that it can be interrupted when Pause or Mute is selected from the TrayMenu.

But I can't figure why it freezes, I hope someone can help... 🙏

I added all the icons and so in the zip so you can run it on your own. Probably you need to change IP address in de .ini and the rasdial will have different or no values. But it does not realy matter.

Here's the script (it's not very clean, sorry... should have been a quick (and dirty) project 😳)

Thanks for your help, Alex.

#NoTrayIcon
#pragma compile(ProductName, "tptst WPS AlwaysOn-UserTunnel Check")
#pragma compile(ProductVersion, 0.5.2)
#pragma compile(InternalName, "tptst VPoN Check")
#pragma compile(OriginalFilename, TunnelPing)
#pragma compile(Icon, .\Resources\App.ico)

#include <TrayConstants.au3> ; Required For the $TRAY_ICONSTATE_SHOW constant.
#include <Date.au3>
#include <FileConstants.au3>
#include <Notifications.au3>

; Opt("TrayIconDebug", 1) ; Debugging info on Systray hover

OnAutoItExitRegister("ExitScript")

Global $appVersion = "0.5.2"

Global $filenameLog = ".\Logs\" & @YEAR & @MON & @MDAY & "_TunnelPing_log.txt"
Global $tptstServer = IniRead(".\TunnelPing.ini", "Settings", "tptstServer", "10.202.1.21")
Global $tptstTimeout = IniRead(".\TunnelPing.ini", "Settings", "tptstTimeout", "1000")
Global $tptstPingWait = IniRead(".\TunnelPing.ini", "Settings", "tptstPingWait", "5")

Global $myMute = False
Global $myPause = False
Global $myInterupt = False

Opt("GUIOnEventMode", 1)
_Notifications_Startup()

; Singleton code:
If WinExists("SA_0bc53fe0-59c2-11e2-bcfd-0800200c9a66_SA") Then
    TrayTip("Already running", "tptst AlwaysOn-UserTunnel Check is already running. Close other instance first.", 0, 1)
    ConsoleWrite("tptst WPS AlwaysOn-UserTunnel Check already running." & @CRLF)
    _Sleep(5000)
    Exit
EndIf

AutoItWinSetTitle("SA_0bc53fe0-59c2-11e2-bcfd-0800200c9a66_SA")

Opt("TrayOnEventMode", 1)
Opt("TrayMenuMode", 1 + 2 + 8) ; The default tray menu items will not be shown and items are not checked when selected.

TraySetClick(8 + 1)

;Global $tiLC = TrayCreateItem("Loading...")
;Global $tiUT = TrayCreateItem("Loading...")
;Global $tiDT = TrayCreateItem("Loading...")

TrayCreateItem("") ; Create a separator line.

$tiPause = TrayCreateItem("Pause")
TrayItemSetOnEvent(-1, "myPause")

$tiMute = TrayCreateItem("Mute")
TrayItemSetOnEvent(-1, "myMute")

TrayCreateItem("") ; Create a separator line.

TrayCreateItem("Open Log Folder")
TrayItemSetOnEvent(-1, "openDir")

TrayCreateItem("") ; Create a separator line.

TrayCreateItem("Info" & "  (" & $appVersion & ")")
TrayItemSetOnEvent(-1, "Info")

TrayCreateItem("") ; Create a separator line.

TrayCreateItem("Exit")
TrayItemSetOnEvent(-1, "ExitApp")

; Now we're ready to accept messages
TraySetState()

Main()

Func Main()

    ; TraySetToolTip("WPS Always-On VPN Check (" & $appVersion & ")")

    $setState = 0

    existLog() ; Check if Log exists, if not create file and write header

    Local Static $mCount = 0

    While 1 ; Loop myPing until exit by Tray event. Changed method after Stack Overflow issue.

        If Not $myPause Then   ; Issue is that start of pause is not an interrupt. Idea user numbers 0 not interrupt > 1 interrupt
            $setState = myPing($setState)
            _Sleep($tptstPingWait * 1000) ; Wait for next ping
        Else
            myTrayIcon(0) ; 1 = Up, 2 = UpMute, 3 = Down, 4 = DownMute, 0 = Pause
            _Sleep(10000)
        EndIf

        $mCount += 1
        ConsoleWrite(_NowCalc() & " --> Main() called " & $mCount & " time(s)" & @CRLF)

    WEnd

EndFunc   ;==>Main

Func _Sleep($iDelay)
    Local $i = 0
    Local $iSleep = $iDelay / 100
    ConsoleWrite(_NowCalc() & " --> Function Sleep: " & $iSleep * 100 & @CRLF)
    While $i <= $iSleep
        Sleep(100)
        $i = $i + 1
        If $myInterupt = True Then
            $myInterupt = False
            Return
        EndIf
    WEnd

EndFunc   ;==>_Sleep

Func myTrayIcon($iSet) ; 1 = Up, 2 = UpMute, 3 = Down, 4 = DownMute, 0 = Pause

    Switch $iSet
        Case 0
            TraySetIcon(".\Resources\Pause.ico")
        Case 1
            TraySetIcon(".\Resources\NetworkUp.ico")
        Case 2
            TraySetIcon(".\Resources\NetworkUpMute.ico")
        Case 3
            TraySetIcon(".\Resources\NetworkDown.ico")
        Case 4
            TraySetIcon(".\Resources\NetworkDownMute.ico")
    EndSwitch

EndFunc   ;==>myTrayIcon

Func myMute()

    $myInterupt = True

    If $myMute = False Then
        $myMute = True
        TrayItemSetState($tiMute, $TRAY_CHECKED)
    Else
        $myMute = False
        TrayItemSetState($tiMute, $TRAY_UNCHECKED)
    EndIf

EndFunc   ;==>myMute

Func myPause()

    $myInterupt = True

    If $myPause = False Then
        $myPause = True
        TrayItemSetState($tiPause, $TRAY_CHECKED)
    Else
        $myPause = False
        TrayItemSetState($tiPause, $TRAY_UNCHECKED)
    EndIf

EndFunc   ;==>myPause


Func myPing($oldState)

    CheckVPN(0)

    If $oldState = 0 Then
        writeLog(">> " & _NowCalc() & " Application started       <<")
        writeLog("   Srv: " & $tptstServer & " Mto: " & $tptstTimeout & " Fq: " & $tptstPingWait)
        writeLog(CheckVPN(1))
        writeLog("---------------------------------------------------")
    Else
        ; Wait some time for next ping. Value defined in ini file.
        $debugWait = $tptstPingWait * 1000
    EndIf

    ; Ping the AutoIt website with a timeout of 250ms.
    Local $iPing = Ping($tptstServer, $tptstTimeout)

    If $iPing Then ; If a value greater than 0 was returned then display the following message.
        If $myMute = False Then
            TraySetIcon(".\Resources\NetworkUp.ico")
        Else
            TraySetIcon(".\Resources\NetworkUpMute.ico")
        EndIf

        If ($oldState = 1) Then Return $oldState ; Do nothing is server state is the same

        If $myMute = False Then
            _Notifications_SetTextAlign("left")
            _Notifications_SetTransparency(150)
            _Notifications_SetDateFormat("DD.MM.YYYY")
            _Notifications_SetTimeFormat("HH:MM:SS")
            _Notifications_SetSound(".\Resources\notify.wav")
            _Notifications_SetButtonText("OK")
            _Notifications_SetColor(0xFDFDFD)
            _Notifications_SetBkColor(0x008000)
            _Notifications_Create("Server (" & $tptstServer & ") Ping Success", "The roundtrip-time took: " & $iPing & "ms." & @CRLF & CheckVPN(2))
        EndIf

        writeLog(_NowCalc() & " " & "▲ UP   [RT: " & $iPing & "ms]")
        $oldState = 1

    Else

        $myError = @error

        If $myMute = False Then
            TraySetIcon(".\Resources\NetworkDown.ico")
        Else
            TraySetIcon(".\Resources\NetworkDownMute.ico")
        EndIf

        If ($oldState = 2) Then Return $oldState ; Do nothing is server state is the same

        If $myMute = False Then
            _Notifications_SetTextAlign("left")
            _Notifications_SetTransparency(150)
            _Notifications_SetDateFormat("DD.MM.YYYY")
            _Notifications_SetTimeFormat("HH:MM:SS")
            _Notifications_SetSound(".\Resources\alarm.wav")
            _Notifications_SetButtonText("OK")
            _Notifications_SetColor(0xFDFDFD)
            _Notifications_SetBkColor(0xFF0000)
            _Notifications_Create("Server (" & $tptstServer & ") Ping Failed", "Server not reachable. Ping error: " & $myError & "." & @CRLF & CheckVPN(2))
        EndIf

        writeLog(_NowCalc() & " " & "▼ DOWN " & CheckVPN(0))

        $oldState = 2

    EndIf

    Return $oldState

EndFunc   ;==>myPing

Func openDir()
    $logPath = StringLeft(@AutoItExe, StringInStr(@AutoItExe, "\", 0, -1)) & "Logs" ; Path to log files
    ShellExecute($logPath)
EndFunc   ;==>openDir

Func existLog()
    ; Check if Log exists. If not Create new file with header
    $sFileName = @ScriptDir & $filenameLog

    If FileExists($sFileName) Then
        Return
    Else
        writeLog("===================================================")
        writeLog(">>       tptst AlwaysOn VPN Ping App " & $appVersion & "       <<")
        writeLog("---------------------------------------------------")
    EndIf
EndFunc   ;==>existLog

Func openLog()
    ShellExecute($filenameLog)
EndFunc   ;==>openLog

Func writeLog($logEntry)

    $sFileName = @ScriptDir & $filenameLog ; Create file in same folder as script

    $hFilehandle = FileOpen($sFileName, $FO_APPEND) ; Open file - append to file

    FileWrite($hFilehandle, $logEntry)

    closeLog($hFilehandle)
EndFunc   ;==>writeLog

Func closeLog($hFilehandle)
    FileWrite($hFilehandle, @CRLF) ; Line feed
    FileClose($hFilehandle) ; Close the file handle
EndFunc   ;==>closeLog

Func CheckVPN($outputType)

    Local $deviceTunnel = "- NOST"
    Local $userTunnel = "- NOST"

    Local $line
    Local $Run = Run("cmd.exe" & " /c " & "rasdial", @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)

    While 1
        $line &= StdoutRead($Run)
        If @error Then ExitLoop
    WEnd


    If (StringInStr($line, "AlwaysOn-DeviceTunnel")) > 0 Then
        $deviceTunnel = "▲ UP  "
    Else
        $deviceTunnel = "▼ DOWN"
    EndIf

    If (StringInStr($line, "AlwaysOn-UserTunnel")) > 0 Then
        $userTunnel = "▲ UP  "
    Else
        $userTunnel = "▼ DOWN"
    EndIf

    $shortString = "[UT: " & $userTunnel & "  DT: " & $deviceTunnel & "]"

    $longString = ">> UserTunnel   UT: " & $userTunnel & "                       <<" & @CRLF & _
            ">> DeviceTunnel DT: " & $deviceTunnel & "                       <<"

    $notifyString = "UT = " & $userTunnel & "    DT = " & $deviceTunnel

    ;TrayItemSetText($tiLC, "Last checked @ " & _NowTime(5))

    ;TrayItemSetText($tiUT, "UserTunnel:      " & $userTunnel)
    ;TrayItemSetText($tiDT, "DeviceTunnel:  " & $deviceTunnel)

    If $outputType = 1 Then
        Return $longString
    ElseIf $outputType = 2 Then
        Return $notifyString
    Else
        Return $shortString
    EndIf

EndFunc   ;==>CheckVPN

Func ExitScript()
    writeLog("---------------------------------------------------")
    If @exitMethod < 3 Then writeLog(">> Application exit >> User Closed the App       <<")
    If @exitMethod = 3 Then writeLog(">> Application exit >> User Log off              <<")
    If @exitMethod = 4 Then writeLog(">> Application exit >> Windows Shutdown          <<")
    writeLog(">> " & _NowCalc() & " End of Logging            <<")
    writeLog("===================================================")
EndFunc   ;==>ExitScript

Func ExitApp()
    ConsoleWrite("ExitApp()")
    Exit
EndFunc   ;==>ExitApp

Func Info()
    ; Display a message box about the AutoIt version and installation path of the AutoIt executable.
    MsgBox($MB_SYSTEMMODAL, "tptst WPS AlwaysOn-UserTunnel Check", "Pings file server " & $tptstServer & " and returns the roundtrip-time." & @CRLF & _
            "App executes a single ping every " & $tptstPingWait & " seconds. Timeout is set to " & $tptstTimeout & " ms." & @CRLF & @CRLF & _
            "You can change these settings in the TunnelPing.ini file." & @CRLF & @CRLF & _
            "Success:" & @TAB & "the roundtrip-time in milliseconds ( greater than 0 )." & @CRLF & @CRLF & _
            "Failure:" & @TAB & "0 if host is not pingable or other network errors occurred and" & @CRLF & _
            @TAB & "sets the @error flag to non-zero." & @CRLF & @CRLF & _
            "@error:" & @TAB & "1 = Host is offline" & @CRLF & _
            @TAB & "2 = Host is unreachable" & @CRLF & _
            @TAB & "3 = Bad destination" & @CRLF & _
            @TAB & "4 = Other errors" & @CRLF & @CRLF & _
            "App calls on RASDial to check if UserTunnel and DeviceTunnel exists. " & @CRLF & @CRLF & _
            "Current status VPN Tunnels: " & CheckVPN(2) & @CRLF & @CRLF & _
            "Version: " & $appVersion & " AMU" & @CRLF & _
            "App tested with 'clumsy 0.2' -- https://jagt.github.io/clumsy/" & @CRLF & @CRLF & _
            "Install Path: " & StringLeft(@AutoItExe, StringInStr(@AutoItExe, "\", 0, -1)) & @CRLF & @CRLF & _ ; Find the folder of a full path.
            "Major versions:" & @CRLF & @CRLF & _
            "0.1   Inital release" & @CRLF & _
            "0.2   Added Tunnel status" & @CRLF & _
            "0.3   Bug fix: Stack Overflow" & @CRLF & _
            "0.4   Added Mute and Pause options and dynamic ToolTip info" & @CRLF & _
            "0.5   Bug fix: Freezing script" & @CRLF)
EndFunc   ;==>Info

 

TunnelPing.zip

Link to comment
Share on other sites

You have provided the full script, I believe.  It is very hard for us to find the problem since you have no idea where the problem is yourself.  What you are asking us is to debug your program if I understand you correctly.  I doubt someone will help you much for it.  But, if you want to help yourself, I would highly recommend that you set a log file where you will write result of every single statement into it.  You will find obviously where the freeze occurs.  You can then try to replicate the problem with a smallest snippet of your code.  And if you still can't solve the issue, we will be glad to help you out.

Link to comment
Share on other sites

Add

AutoItSetOption("TrayIconDebug", 1)

to your script.
When runnung move your mouse over the AutoIt icon in the system tray and you will see the statement being executed.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

I once had a similar issue, and the problem was caused because i was calling functions within functions.

When i get the oportunity to test the code, i'll remove some of those frequent calls within the functions, or add returns to them, to make sure they do return.

Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Link to comment
Share on other sites

Thanks all for pointing me in the right direction. Been stipping the script until I found where the issue is caused. Still no clue why because it just freezes. Not in a function, not on a particular instruction. It is different every time (most on sleep though, but that is logical since the rest takes only ms to complete).

Anyway, this is the part where it fails: (The code is bigger than nessesary, but it is just to test and understand what goes on.) Thanks for helping out.

#include "WinAPI.au3"
#include "Date.au3"

Opt("TrayIconDebug", 1) ; Debugging info on Systray hover

Main()

Func Main()

    Local Static $mCount = 0

    While 1
        ConsoleWrite(CheckRasdial())
        Sleep (1000)

        $mCount += 1
        ConsoleWrite(" --> Looped " & $mCount & " times @ " & _NowCalc() & @CRLF & @CRLF)
    WEnd

EndFunc

Func CheckRasdial()

    Local $deviceTunnel = False

    Local $line
    Local $Run = Run("cmd.exe" & " /c " & "rasdial", @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)

    While 1
        $line &= StdoutRead($Run)
        If @error Then ExitLoop

    WEnd

    ConsoleWrite($line & @CRLF)

    If (StringInStr($line, "AlwaysOn-DeviceTunnel")) > 0 Then
        $deviceTunnel = True
    Else
        $deviceTunnel = False
    EndIf

    Return "$deviceTunnel = " & $deviceTunnel

EndFunc   ;==>CheckRasdial

 

Link to comment
Share on other sites

Link to comment
Share on other sites

Thanks for helping me out! It always is different. Usually between 100 - 400 loops. But it can be sooner but never has it been over 600 loops.

OS: Win10 

It also freezes compiled, but I run it just via Tools -> Go because of the ConsoleWrite output.

This is my AutoIT version:

SciTE
32-bit
Version 4.2.0 
    Sep  3 2019 19:04:05
by Neil Hodgson.
 Updated by Jos
 

 

Link to comment
Share on other sites

AutoIT version was already in my previous post ☺️: 4.2.0 of September 3. 2019 updated by Jos.

This is btw the error after I force the script to stop:

$deviceTunnel = True --> Looped 143 times @ 2020/04/24 21:28:48

>Process failed to respond; forcing abrupt termination...
>Exit code: 1    Time: 336.2

 

Link to comment
Share on other sites

Link to comment
Share on other sites

11 minutes ago, Nine said:

NVM, just saw it both in win10 and win7.  After close to 200 loops, a little under.

No memory leak.  As with you, random location.

That's a bit of a relieve. So I don't have to debug my whole computer 😁

 

Link to comment
Share on other sites

Well I believe it is RasDial that causes the problem.  I tried the exact same script with another program and it does not freeze.  Could you also try using another program, see if you get the same result as I am getting (no freeze) ?

Link to comment
Share on other sites

Try this code, after 650 loop it didn't crash (win10).  If it doesn't for you, you have something to work with.  Otherwise, I am afraid I will not be more helpful.

#include "WinAPI.au3"
#include "Date.au3"

Opt("TrayIconDebug", 1) ; Debugging info on Systray hover

Main()

Func Main()

    Local Static $mCount = 0

    While 1
        ConsoleWrite(CheckRasdial() & @CRLF)
        Sleep (1000)

        $mCount += 1
        ConsoleWrite(" --> Looped " & $mCount & " times @ " & _NowCalc() & @CRLF)
    WEnd

EndFunc

Func CheckRasdial()

    Local $deviceTunnel = False

    Local $line
    Local $Run = Run("cmd.exe" & " /c " & "ver", @ScriptDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
    ProcessWaitClose ($Run)

    While 1
        $line &= StdoutRead($Run)
        If @error Then ExitLoop
    WEnd

    ConsoleWrite($line & @CRLF)

    If (StringInStr($line, "AlwaysOn-DeviceTunnel")) > 0 Then
        $deviceTunnel = True
    Else
        $deviceTunnel = False
    EndIf

    Return "$deviceTunnel = " & $deviceTunnel

EndFunc   ;==>CheckRasdial

I know there is a lot useless code, but I wanted to keep as much as possible the original script

Link to comment
Share on other sites

#include "WinAPI.au3"
#include "Date.au3"

Opt("TrayIconDebug", 1) ; Debugging info on Systray hover

Local $mCount = 0, $deviceTunnel = False, $line, $Run, $Read, $Str

Main()

Func Main()
    $Run = Run("conhost", '', @SW_SHOW, $STDIN_CHILD + $STDOUT_CHILD)
    Do
        $Read = StdoutRead($Run, False, False)
        $Str = StringInStr($Read, 'Microsoft Windows')
    Until $Str <> 0
    While 1
        ConsoleWrite(CheckRasdial())
        Sleep (300)
        $mCount += 1
        ConsoleWrite(" --> Looped " & $mCount & " times @ " & _NowCalc() & @CRLF)
    WEnd
EndFunc

Func CheckRasdial()
    StdinWrite($Run, 'rasdial'&@CRLF)
    Do
        $line = StdoutRead($Run, True, False)
        $Str = StringInStr($line, 'completed')
    Until $Str <> 0
        $line = StdoutRead($Run, False, False)
        consoleWrite('$line:'& $line&@CRLF)
        If @error Then
            StdioClose($Run)
            ProcessClose($Run)
            ConsoleWrite('Read Failed!' &@CRLF)
        Else
            ConsoleWrite('Read ok!'&@CRLF)
        EndIf
    If StringInStr($line, "AlwaysOn-DeviceTunnel") <> 0 Then
        $deviceTunnel = True
    Else
        $deviceTunnel = False
    EndIf
    Return "$deviceTunnel = " & $deviceTunnel
EndFunc   ;==>CheckRasdial

I tried another approach, but im having issues debugging, because my terminal/cmd window is just blank, without any characters, and i would like to see what the script is doing. Changed to "conhost" and now it shows.. need to look into this later, but the general idea with this one is to keep the stream open, since we're going to repeatedly call the same cmd, and just keep writing and reading the stream. On a side note, it's just a good practice to declare variables outside functions, to keep from declaring them over and over again.

Edited by careca
Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Link to comment
Share on other sites

@careca  I think you got a great idea here in keeping the stream open.  I will try this in morning using cmd.exe as the base run. 

1 hour ago, careca said:

On a side note, it's just a good practice to declare variables outside functions, to keep from declaring them over and over again.

Allow me to totally disagree with you on this one.  It is not a good practice to pull every single variables out of functions to make them Global (even though you have declared them Local, but the fact is that they are global).  Good practices are, on the contrary, to reduce the use of global variables, as it makes large programs harder to follow and debug.

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...