Edano Posted August 12, 2013 Share Posted August 12, 2013 (edited) BlackBox Solitary and Multiplayer Game v2.1 This is an update of previous versions i made some years ago. Description and rules can be found >here. New is the multiplayer mode. two or more of the same script can be copied to other computers and communicate via TCP/IP. Since all is combined in one script, it serves as receiver and sender, server and client, which was a bit tricky to code. there was a recent discussion about this issue, so i decided to publish it. Part of the script is a simple but clever rich edit chat console in HTTP. Two multiplayer options: players play simultaneously the same computer generated game (hidden from each other), or the players set the puzzle mutually. Savegames can be imported by dropping them into the window. . taken down .. Have some fun E. Edited August 16, 2013 by Edano [color=rgb(255,0,0);][font="'comic sans ms', cursive;"]FukuLeaks[/color][/font] Link to comment Share on other sites More sharing options...
wakillon Posted August 13, 2013 Share Posted August 13, 2013 Can't test game : returns 4 error(s), 54 warning(s) And declare global variables inside functions is not a good coding practice... AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts Link to comment Share on other sites More sharing options...
Edano Posted August 13, 2013 Author Share Posted August 13, 2013 (edited) Can't test game : returns 4 error(s), 54 warning(s) And declare global variables inside functions is not a good coding practice... . very weird. runs for me without any problem, compiled, uncompiled, from console. in every way i try. btw i gave it away to friends and there was never a problem. E. Edit: maybe maybe.... , it is an example script (and no UDF) with 1,500 lines and there is one or the other 'test function' that doesn't get used, only for developing, but it runs without errors. Edited August 13, 2013 by Edano [color=rgb(255,0,0);][font="'comic sans ms', cursive;"]FukuLeaks[/color][/font] Link to comment Share on other sites More sharing options...
guinness Posted August 13, 2013 Share Posted August 13, 2013 I didn't experience any warnings with v3.3.8.1 on Windows 7 x64. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
Edano Posted August 13, 2013 Author Share Posted August 13, 2013 mine is xp pro sp3 and tested on win7 and vista as well, autoit v3.3.8.1 [color=rgb(255,0,0);][font="'comic sans ms', cursive;"]FukuLeaks[/color][/font] Link to comment Share on other sites More sharing options...
FireFox Posted August 13, 2013 Share Posted August 13, 2013 (edited) He may have re-enabled the Au3Check (see it's originally disabled). Edited August 13, 2013 by FireFox Link to comment Share on other sites More sharing options...
BrewManNH Posted August 13, 2013 Share Posted August 13, 2013 If you run Tidy on the script, and sort the functions alphabetically, the errors will show up. Never declare Global variables in function for just this reason, just because your functions aren't called in that order doesn't mean it was coded well. Note I said well, not wrong. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
wakillon Posted August 13, 2013 Share Posted August 13, 2013 I always check scripts before try, and seeing so many errors and warning, i didn't run it. >"C:\Program Files\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /prod /AU3Check /in "C:BlackBox.au3" +>16:21:14 Starting AutoIt3Wrapper v.2.1.2.9 Environment(Language:040C Keyboard:0000040C OS:WIN_7/ CPU:X64 OS:X86) >Running AU3Check (1.54.22.0) from:C:Program FilesAutoIt3 C:BlackBox.au3(68,21) : WARNING: $Solved: possibly used before declaration. If $Solved = ~~~~~~~~~~~~~~~~~~~~^ C:BlackBox.au3(68,35) : WARNING: $Manual: possibly used before declaration. If $Solved =0 And $Manual= ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:BlackBox.au3(69,42) : WARNING: $Timer: possibly used before declaration. Global $Zeit=TimerDiff($Timer) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:BlackBox.au3(72,32) : WARNING: $GUI: possibly used before declaration. ControlSetText($GUI, ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:BlackBox.au3(72,44) : WARNING: $Toolbar: possibly used before declaration. ControlSetText($GUI,"",$Toolbar+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:BlackBox.au3(75,26) : WARNING: $LAN: possibly used before declaration. If WinActive($LAN) ~~~~~~~~~~~~~~~~~~~~~~~~~^ C:BlackBox.au3(75,51) : WARNING: $LGroup: possibly used before declaration. If WinActive($LAN) And GUICtrlRead($LGroup+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:BlackBox.au3(76,29) : WARNING: $Second: possibly used before declaration. If WinActive($Second) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:BlackBox.au3(77,34) : WARNING: $Group: possibly used before declaration. If GUICtrlRead($Group+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:BlackBox.au3(78,44) : WARNING: $bMax: possibly used before declaration. If GUICtrlRead($Group+3)>$bMax Then ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:BlackBox.au3(80,44) : WARNING: $hMax: possibly used before declaration. If GUICtrlRead($Group+7)>$hMax Then ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:BlackBox.au3(84,31) : WARNING: $Chat: possibly used before declaration. ElseIf WinActive($Chat) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:BlackBox.au3(85,43) : WARNING: $Send: possibly used before declaration. Local $p=GUICtrlGetState($Send+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:BlackBox.au3(89,22) : WARNING: $Connected: possibly used before declaration. If $Connected> ~~~~~~~~~~~~~~~~~~~~~^ C:BlackBox.au3(91,44) : WARNING: $PID: possibly used before declaration. If @error Or ProcessExists($PID) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:BlackBox.au3(92,55) : WARNING: $Multi: possibly used before declaration. If $rcv="" Then $rcv=ControlGetText($Multi, ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:BlackBox.au3(94,26) : WARNING: $Incoming: possibly used before declaration. ElseIf $Incoming Then ~~~~~~~~~~~~~~~~~~~~~~~~~^ C:BlackBox.au3(95,23) : WARNING: $Socket: possibly used before declaration. If $Socket= ~~~~~~~~~~~~~~~~~~~~~~^ C:BlackBox.au3(95,67) : WARNING: $Port: possibly used before declaration. If $Socket=-1 Then $Socket=TCPListen(@IPAddress1,$Port) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:BlackBox.au3(110,37) : WARNING: $Grid: possibly used before declaration. Local $t=@GUI_CtrlId-$Grid[0][0] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:BlackBox.au3(118,26) : WARNING: $4: possibly used before declaration. If GUICtrlRead($4- ~~~~~~~~~~~~~~~~~~~~~~~~~^ C:BlackBox.au3(120,73) : WARNING: $Lsg: possibly used before declaration. GUICtrlSetColor($Grid[$x][$y],0xE8E8E8-0xB2B2B2*$Lsg[$x][$y]) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:BlackBox.au3(128,33) : WARNING: $Atoms possibly not declared/created yet $Atoms+=1-2*$Lsg[$x][$y] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:BlackBox.au3(132,45) : ERROR: syntax error If $Connected > -1 Then Global $Load&= ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:BlackBox.au3(132,60) : ERROR: multi-line 'If' missing 'Then'. If $Connected > -1 Then Global $Load&=$x&":"&$y&"|" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:BlackBox.au3(135,20) : WARNING: $Rays possibly not declared/created yet $Rays+=_Score() ~~~~~~~~~~~~~~~~~~~^ C:BlackBox.au3(142,21) : WARNING: $Beams possibly not declared/created yet $Beams+=_Score() ~~~~~~~~~~~~~~~~~~~~^ C:BlackBox.au3(149,22) : WARNING: $3: possibly used before declaration. If GUICtrlRead($3+ ~~~~~~~~~~~~~~~~~~~~~^ C:BlackBox.au3(156,34) : WARNING: $Ball: possibly used before declaration. If $Ball[$x+$xdir][$y+$ydir] Then ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:BlackBox.au3(168,23) : WARNING: $Beams: possibly used before declaration. For $i=0 To $Beams+ ~~~~~~~~~~~~~~~~~~~~~~^ C:BlackBox.au3(170,36) : WARNING: $ColDiff: possibly used before declaration. If ($col[0]-$ColDiff[$i][0]) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:BlackBox.au3(184,14) : WARNING: $Atoms: possibly used before declaration. If $Atoms= ~~~~~~~~~~~~~^ C:BlackBox.au3(189,29) : WARNING: $1: possibly used before declaration. ControlEnable($GUI,"",$1- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:BlackBox.au3(221,17) : WARNING: $U32: possibly used before declaration. DllCall($U32, ~~~~~~~~~~~~~~~~^ C:BlackBox.au3(221,22) : WARNING: $INT: possibly used before declaration. DllCall($U32,$INT, ~~~~~~~~~~~~~~~~~~~~~^ C:BlackBox.au3(221,42) : WARNING: $HWN: possibly used before declaration. DllCall($U32,$INT,"RedrawWindow",$HWN, ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:BlackBox.au3(221,52) : WARNING: $PTR: possibly used before declaration. DllCall($U32,$INT,"RedrawWindow",$HWN,$GUI,$PTR, ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:BlackBox.au3(224,13) : WARNING: $Game possibly not declared/created yet $Game+=1 ~~~~~~~~~~~~^ C:BlackBox.au3(226,54) : WARNING: $Rays: possibly used before declaration. If TCPSend($Connected,"RES"&$t&"|"&$cnt&"|"&$Rays& ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:BlackBox.au3(226,65) : WARNING: $Score: possibly used before declaration. If TCPSend($Connected,"RES"&$t&"|"&$cnt&"|"&$Rays&"|"&$Score& ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:BlackBox.au3(275,36) : WARNING: $Menu: possibly used before declaration. If @GUI_CtrlId>$Menu[$h-5] Then ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:BlackBox.au3(285,57) : WARNING: $BB: possibly used before declaration. Local $file=FileOpenDialog($Title,@ScriptDir,"("&$BB& ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:BlackBox.au3(309,20) : WARNING: $BlackBox: possibly used before declaration. _Chat($BlackBox& ~~~~~~~~~~~~~~~~~~~^ C:BlackBox.au3(309,27) : WARNING: $fcRED: possibly used before declaration. _Chat($BlackBox&$fcRED& ~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:BlackBox.au3(309,42) : WARNING: $Tabelle: possibly used before declaration. _Chat($BlackBox&$fcRED&$Tabelle[0][0]& ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:BlackBox.au3(309,48) : WARNING: $fEnd: possibly used before declaration. _Chat($BlackBox&$fcRED&$Tabelle[0][0]&$fEnd& ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:BlackBox.au3(309,53) : WARNING: $fs2: possibly used before declaration. _Chat($BlackBox&$fcRED&$Tabelle[0][0]&$fEnd&$fs2& ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:BlackBox.au3(328,22) : WARNING: $NewRLS: possibly used before declaration. _Chat($NewRLS& ~~~~~~~~~~~~~~~~~~~~~^ C:BlackBox.au3(342,15) : WARNING: $2: possibly used before declaration. For $i=$2 To ~~~~~~~~~~~~~~^ C:BlackBox.au3(358,36) : WARNING: $xBorder: possibly used before declaration. If ($b+2)*($Size+2)+20+$xBorder> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:BlackBox.au3(359,36) : WARNING: $yBorder: possibly used before declaration. If ($h+2)*($Size+2)+38+$yBorder> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:BlackBox.au3(361,40) : WARNING: $BBN: possibly used before declaration. If $Connected>-1 Then _ToolTip($BBN, ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:BlackBox.au3(406,36) : WARNING: $Ecke: possibly used before declaration. ControlSetText($GUI,"",$Ecke[0], ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:BlackBox.au3(447,50) : WARNING: $Func: possibly used before declaration. GUICtrlSetOnEvent($Ecke[$i],$Func[$i]) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:BlackBox.au3(501,23) : WARNING: $Cheat: possibly used before declaration. WinMove($Cheat, ~~~~~~~~~~~~~~~~~~~~~~^ C:BlackBox.au3(1254,13) : WARNING: $End: possibly used before declaration. If $End Then ~~~~~~~~~~~~^ C:BlackBox.au3(1294,46) : ERROR: _Value() called with wrong number of args. If $s="VAL" Then Local $a=_Value($t,4) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:BlackBox.au3(909,16) : REF: definition of _Value(). Func _Value($t) ~~~~~~~~~~~~~~~^ C:BlackBox.au3(1294,47) : ERROR: syntax error If $s="VAL" Then Local $a=_Value($t,4)) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:BlackBox.au3 - 4 error(s), 54 warning(s) !>16:21:15 AU3Check ended. Press F4 to jump to next error.rc:2 >Exit code: 0 Time: 1.588 AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts Link to comment Share on other sites More sharing options...
Edano Posted August 13, 2013 Author Share Posted August 13, 2013 (edited) nobody forces you to run it. it is just an offer to share it. . Global can be used to assign to global variables inside a function, but if a local variable (or parameter) has the same name as a global variable, the local variable will be the only one used. . i think someone has to rewrite the helpfile then. i have good reasons to do what i did. Cheers E Edited August 13, 2013 by Edano [color=rgb(255,0,0);][font="'comic sans ms', cursive;"]FukuLeaks[/color][/font] Link to comment Share on other sites More sharing options...
Developers Jos Posted August 13, 2013 Developers Share Posted August 13, 2013 (edited) i think someone has to rewrite the helpfile then. i have good reasons to do what i did. Why do we need to rewrite the helpfile and why are you in denial? Jos Edited August 13, 2013 by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
BrewManNH Posted August 13, 2013 Share Posted August 13, 2013 Not taking away anything from how the script runs, because it runs well, but you redeclared several variables as global inside at least 3 functions. When if you'd declared them as Global at the top of the script you would only have to assign the values to the variable name. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
guinness Posted August 13, 2013 Share Posted August 13, 2013 i have good reasons to do what i did.Well there are better ways to do what you're doing. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
Edano Posted August 13, 2013 Author Share Posted August 13, 2013 Not taking away anything from how the script runs, because it runs well, but you redeclared several variables as global inside at least 3 functions. When if you'd declared them as Global at the top of the script you would only have to assign the values to the variable name. .. so please give me a hint. why is doing this wrong or bad or worth a 'warning' ? people have told me here frequently (almost every day) that i am an idiot and i don't understand the language and a few more insults i forgot, so please help me to become a better coder. [color=rgb(255,0,0);][font="'comic sans ms', cursive;"]FukuLeaks[/color][/font] Link to comment Share on other sites More sharing options...
guinness Posted August 13, 2013 Share Posted August 13, 2013 Well I didn't call you an idiot nor did I say you were stupid, it's not only disrespectful but demeaning too. We're all learning still.I would really advise you to read this >> '?do=embed' frameborder='0' data-embedContent>> it's quite an interesting discussion and something that got me thinking. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
Edano Posted August 13, 2013 Author Share Posted August 13, 2013 Well I didn't call you an idiot nor did I say you were stupid, it's not only disrespectful but demeaning too. We're all learning still. I would really advise you to read this >> '?do=embed' frameborder='0' data-embedContent>> it's quite an interesting discussion and something that got me thinking. . no, not you [color=rgb(255,0,0);][font="'comic sans ms', cursive;"]FukuLeaks[/color][/font] Link to comment Share on other sites More sharing options...
guinness Posted August 13, 2013 Share Posted August 13, 2013 I also like the approach of using "an object-like" variable, which you can see in my PasswordValid UDF. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
Edano Posted August 13, 2013 Author Share Posted August 13, 2013 (edited) Variables should always be declared in the smallest scope possible in any language (for languages that support it). For example, don't front-load your functions with all the variable declarations. Declare variables right before they are used. If a variable doesn't need to exist in global scope then use it in local scope. Prefer function return values and function parameters to pass data around rather than global variables. Keep variables in existence no more than necessary. by >Valik i understand this statement as equivalent to: "don't front-load your script with all the global variable declarations. Declare variables right before they are used." Edited August 13, 2013 by Edano [color=rgb(255,0,0);][font="'comic sans ms', cursive;"]FukuLeaks[/color][/font] Link to comment Share on other sites More sharing options...
guinness Posted August 13, 2013 Share Posted August 13, 2013 So you think you adhere to that comment? UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
Edano Posted August 13, 2013 Author Share Posted August 13, 2013 you refer to valik's statement ? i am not sure, he is a competent programmer. it stands against common udf and scripting practices. i think both is possible and depends on the script architecture. i am not fixed to any position, as long as it works. i made scripts with loads of front declarations, especially arrays and inireadings are more practical at the beginning, so you can easily find the assignments. but i have problems with titling the one thing as 'good' practice and the other as 'bad'. in my above script i use the criticized method because the script runs an embedded child process of itself, and this child process doesn't need so many globals as the parent, but runs thru the same (but not all) function(s). the link you gave me is interesting, but i was aware of most of the problems already. but i could have missed a point. i bookmarked it to reread it. [color=rgb(255,0,0);][font="'comic sans ms', cursive;"]FukuLeaks[/color][/font] Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now