Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 11/05/2017 in all areas

  1. hm... as I remember here (in this topic/thread) was not discused about: "variable meaningful titles/names" Also on AutoIt Wiki: https://www.autoitscript.com/wiki/Best_coding_practices#Names_of_Variables There is no mention about "variable meaningful titles/names". For example in this Wiki page there is: For $i = 1 To 10 $g_vVariableThatIsGlobal &= $i ; This will return 12345678910 totally wiping the previous contents of $g_vVariableThatIsGlobal Next And for this little "for to next" loop I do not see any needs to change it, especially that in this example the loop is inside a small function. But for some time, I have tried in my UDF's to make the variables "significant titles". ; my old coding habbits For $i =1 To $aUsers[0][0] ...... ...... ...... ...... ...... ...... ...... ...... ...... $aUsers[$i][....] ...... ...... ...... ...... ...... ...... ...... ...... ...... Next ; my current coding style For $iUser_idx =1 To $aUsersList[0][0] ...... ...... ...... ...... ...... ...... ...... ...... ...... $aUsersList[$iUser_idx][...] ...... ...... ...... ...... ...... ...... ...... ...... ...... Next ; my old coding habbits For $oUser In $oUsers.count ...... ...... ...... ...... ...... ...... ...... ...... ...... $oUser.value ...... ...... ...... ...... ...... ...... ...... ...... ...... Next ; my current coding style For $oUserNode_enum In $oUserNodes_coll.count ...... ...... ...... ...... ...... ...... ...... ...... ...... $oUserNode_enum.value ...... ...... ...... ...... ...... ...... ...... ...... ...... Next Thanks to them, I avoid many problems with analizing old code. Even when I try to understand my own old code (older then 3 years), I start with rewriting variable names. And then I use Au3Check, and finally i start to understand what is going on in this code. What you think about such convention - I do not mean exactly about the suffix _coll, _enum and _idx but generally about the concept to use "variable meaningful titles/names" ?
    1 point
  2. Melba23

    lisview

    neypro, Please post in English in future. What have you tried already that has not worked? M23
    1 point
  3. Hello. Maybe this? #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <ColorConstants.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> #include <GuiImageList.au3> $hMain = GUICreate("Test", -1, 300, -1, -1, BitOR($WS_SIZEBOX, $WS_SYSMENU, $WS_MAXIMIZEBOX, $WS_MINIMIZEBOX), $WS_EX_ACCEPTFILES) ;x il drag & drop ;;top GUICtrlCreateLabel("Listview colour", 55, 0, 275, 40) GUICtrlSetFont(-1, 24, 400, 0, "Comic Sans MS") GUICtrlSetColor(-1, $COLOR_GREEN) GUICtrlCreateLabel("Testing 123", 200, 40, 120, 18) GUICtrlSetFont(-1, 8, 40, 0, "Comic Sans MS") GUICtrlSetColor(-1, $COLOR_BLUE) ;;body GUICtrlCreateLabel("User:", 25, 68, 30, 16) $inUser = GUICtrlCreateInput("", 56, 66, 83, 21) $btnLookup = GUICtrlCreateButton("Lookup", 150, 60, 75, 33, $BS_DEFPUSHBUTTON) $btnGreen = GUICtrlCreateButton("Green", 230, 60, 43, 33) $btnRed = GUICtrlCreateButton("Red", 275, 60, 43, 33) $listComputers = GUICtrlCreateListView("Name |Model |Serial |OS Install date|HDD", 55, 100, 290, 100, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT, $LVS_SINGLESEL)) GUICtrlSetState($inUser, $GUI_FOCUS) GUISetState(@SW_SHOW) ; Main GUI loop While True $nMsg = GUIGetMsg() Select Case $nMsg = $GUI_EVENT_CLOSE Exit Case $nMsg = $inUser GUICtrlSetState($inUser, $GUI_FOCUS) Case $nMsg = $btnLookup LookupButtonPressed() Case $nMsg = $btnGreen $iIndex = _GUICtrlListView_GetSelectedIndices($listComputers) $machine = _GUICtrlListView_GetItemText($listComputers, Number($iIndex)) _GUICtrlListView_SetItemImage($listComputers, $iIndex, 1) ; ; change to green? ;_GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($listComputers, 0x00FF00, 16, 16)) ; green Case $nMsg = $btnRed $iIndex = _GUICtrlListView_GetSelectedIndices($listComputers) $machine = _GUICtrlListView_GetItemText($listComputers, Number($iIndex)) _GUICtrlListView_SetItemImage($listComputers, $iIndex, 2) ; ; change to red? ;_GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($listComputers, 0xFF0000, 16, 16)) ; red EndSelect WEnd Func LookupButtonPressed() _GUICtrlListView_DeleteAllItems($listComputers) ;$aMachines = machine_lookup($user, $searchstring) Local $aMachines[2][5] $aMachines[0][0] = "PC01" $aMachines[0][1] = "HP Compaq 6000" $aMachines[0][2] = "ABC123" $aMachines[0][3] = "01/01/2001" $aMachines[0][4] = "Toshiba HDD" $aMachines[1][0] = "PC02" $aMachines[1][1] = "HP Compaq 6000" $aMachines[1][2] = "XYZ456" $aMachines[1][3] = "01/01/2001" $aMachines[1][4] = "Toshiba HDD" ;_ArrayDisplay($aMachines) If Not @error Then If IsArray($aMachines) Then $sComputers = _ArrayToString($aMachines, " - ") $sComputers = StringReplace($sComputers, @CRLF, "|") ;ConsoleWrite($sComputers & @CRLF) For $i = 0 To UBound($aMachines) - 1 $machine = $aMachines[$i][0] $model = $aMachines[$i][1] $serial = $aMachines[$i][2] $OSInstallDate = $aMachines[$i][3] $HDD = $aMachines[$i][4] _GUICtrlListView_AddItem($listComputers, $machine) _GUICtrlListView_AddSubItem($listComputers, $i, $model, 1) _GUICtrlListView_AddSubItem($listComputers, $i, $serial, 2) _GUICtrlListView_AddSubItem($listComputers, $i, $OSInstallDate, 3) _GUICtrlListView_AddSubItem($listComputers, $i, $OSInstallDate, 3) _GUICtrlListView_AddSubItem($listComputers, $i, $HDD, 4) $hImage = _GUIImageList_Create(16, 16) _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($listComputers, $COLOR_YELLOW, 16, 16)) ; yellow _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($listComputers, $COLOR_GREEN, 16, 16)) _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($listComputers, $COLOR_RED, 16, 16)) _GUICtrlListView_SetImageList($listComputers, $hImage, 1) Next _GUICtrlListView_SetItemSelected($listComputers, 0) EndIf EndIf EndFunc ;==>LookupButtonPressed Saludos
    1 point
  4. Helpfile would be a good place to check the changes made in syntax over time. Jos v3.3.2.0 Some of the following features are deprecated. Deprecated features are no longer documented but continue to work. Deprecated features will be removed after version 3.3.2.0. It is strongly recommended that scripts relying on deprecated features be updated to work with the new behavior. Some features have already been removed and will be noted as such. AutoIt: ShellExecute() and ShellExecuteWait() no longer use the "open" verb by default. See the remarks section for those functions for more details. The return value of InetGet() has changed. It is important to read and understand the changes because it is possible to leak resources if InetGet() is used incorrectly. InetGet("abort"), @InetGetActive and @InetGetBytesRead are now deprecated. The following list shows the new functions used to access the old behavior: InetGet("abort") - Calling the new InetClose() function with a handle returned from InetGet() will abort a download. @InetGetActive - Calling the new InetGetInfo() function with no parameters returns a count of active downloads. @InetGetBytesRead - Calling the new InetGetInfo() function with a handle returned from InetGet()will return the bytes read (and more) for a download. The FtpBinaryMode option set with AutoItSetOption() has been removed. Now InetGet() takes a flag to specify the transfer mode. The URLDownloadToFile() alias for InetGet() has been removed. AdlibEnable() and AdlibDisable() are deprecated. See the new functions AdlibRegister() and AdlibUnRegister(). OnAutoItStart() is deprecated. See the new pre-processor statement #OnAutoItStartRegister. OnAutoItExit() is deprecated. See the new functions OnAutoItExitRegister() and OnAutoItExitUnRegister(). The AutoItSetOption() option OnExitFunc has been removed. See the new functions OnAutoItExitRegister() and OnAutoItExitUnRegister().
    1 point
×
×
  • Create New...