Jump to content

CephasOz

Active Members
  • Posts

    28
  • Joined

  • Last visited

CephasOz's Achievements

Seeker

Seeker (1/7)

0

Reputation

  1. Example of usage for the 3 button UDF. CODEConst $csTtl = "Button Demonstration" Local $iBtn, $sMsg, $sBtn1, $sBtn2, $sBtn3 $sMsg = "Do you want to Save or Restore?" $sBtn1 = "&Save" $sBtn2 = "&Restore" $sBtn3 = "&Cancel" $iBtn = Button3( $csTtl, $sMsg, $sBtn1, $sBtn2, $sBtn3, 3 ) Select Case ( $iBtn == 0 ) ; User closed dialog. Exit Case ( $iBtn == 1 ) ; User selected "Save" button. MsgBox( 64, $csTtl, "You pressed button " & $iBtn ) Case ( $iBtn == 2 ) ; User selected "Restore" button. MsgBox( 64, $csTtl, "You pressed button " & $iBtn ) Case ( $iBtn == 3 ) ; User selected "Cancel" button. Exit EndSelect buttons.au3
  2. Going from your comments, I think the following code does the same job. Func _IncrementStringAsNum( $sNum ) Local $iNum = Int( $sNum ) + 1 If Not StringIsDigit( $sNum ) Then Return -1 If StringLen( String( $iNum ) ) > StringLen( $sNum ) Then Return -2 Return StringFormat( "%0" & StringLen( $sNum ) & "d", $iNum ) EndFunc The code below doesn't work properly. 1) It re-declares a parameter ($a) as a local variable, 2) It doesn't pick up strings with non-digit characters (try "A4"), and 3) It uses a variable ($int) that doesn't get assigned a value. Hope that's helpful.
  3. This is (yet another) program that lists files. It allows the user to use a file specification, and to have folders with no files excluded from the listing. The end result is sent to Notepad (or Wordpad if too big), from where it can be printed. (A non-proportional font is good to ensure that things line up.) The code is original except for Tylo's QuickSort routine. dirprint.zip
  4. These are two little tools that I found helpful when writing scripts dealing with regular expression finding or replacing. The tools allow you to easily test what you want to do in regular expressions, so you can include the correct expressions in your script. re_test.au3 - regular expression test rer_test.au3 - regular expression replacement test re_test.au3 rer_test.au3
  5. If I read the documentation correctly, then BitRotate with a positive number rotates left, while BitShift with a positive number shifts to the right. Should one or the other be changed? (Thanks David, not only for what you do but the way that you do it.)
  6. I wonder what the difference would be between: 1. DirGetSize( $sDir ) and 2. FileExists( $sDir ) And ( StringInStr( FileGetAttrib( $sDir ), "D" ) > 0 ) perhaps implemented as 3. Func DirExists( $sDir ) Return ( FileExists( $sDir ) And ( StringInStr( FileGetAttrib( $sDir ), "D" ) > 0 ) ) EndFunc I tend towards 3, as using If DirExists( "\\Server\share$" ) Then ... makes the intent of your code obvious.
  7. David, of course you're right. (Sorry, JP.)
  8. Could I suggest that Switch/Case/EndSwitch be added to Language Reference - Conditional Statements, and that For/In/Next and With/EndWith be added to Language Reference - Loop Statements in the 3.1.1.++ help file?
  9. In his 1968 work, Go To Statement Considered Harmful , Dijkstra said: It strikes me that many examples in the help file are of the "GoTo" variety. For example, the FileReadLine example (in part): Could we change this to be: ; Read in lines of text until the EOF is reached $line = FileReadLine($file) While @error <> -1 MsgBox(0, "Line read:", $line) $line = FileReadLine($file) Wend Same number of lines of code, but without the "goto jump" provided by ExitLoop. I'm not arguing for an eradication of ExitLoop, merely that the examples should be more in line with best practice.
×
×
  • Create New...