Leaderboard
Popular Content
Showing content with the highest reputation on 05/03/2012 in all areas
-
This example:- ConsoleWrite(StringRegExpReplace(FileRead("test.txt"), "(?s)^(?:.+?\v+.+?\h{2,})(.+?)\h{2,}.*$", "$1") & @LF) returns FFF84F1 from:- That is, the code in the quote is the contents of the "test.txt" text file.2 points
-
This function is very fast compared to standard _StringRepeat() when number of repeated chars is big. In my tests this version is faster than original for > 50 chars. Time needed for this new StringRepeat() is constant no matter how many chars you repeat (nCount) so for big numbers of repeated characters it's MUCH FASTER (hundred times). StringRepeat Function: Func StringRepeat($sChar, $nCount) $tBuffer = DLLStructCreate("char[" & $nCount & "]") DllCall("msvcrt.dll", "ptr:cdecl", "memset", "ptr", DLLStructGetPtr($tBuffer), "int", Asc($sChar), "int", $nCount) Return DLLStructGetData($tBuffer, 1) EndFunc Testing example for compare speed with standard _StringRepeat (try to change number of chars): #include <String.au3> $start = TimerInit() _StringRepeat('a',1000) ConsoleWrite(TimerDiff($start)& @CRLF) $start = TimerInit() StringRepeat('a',1000) ConsoleWrite(TimerDiff($start)& @CRLF) Func StringRepeat($sChar, $nCount) $tBuffer = DLLStructCreate("char[" & $nCount & "]") DllCall("msvcrt.dll", "ptr:cdecl", "memset", "ptr", DLLStructGetPtr($tBuffer), "int", Asc($sChar), "int", $nCount) Return DLLStructGetData($tBuffer, 1) EndFunc EDIT: There is one difference/limitation from original _StringRepeat(): This new StringRepeat() can repeat only one character, so it's not posiible to do: StringRepeat('abc',3) --> result is 'aaa' Maybe I should change its name from StringRepeat() to CharRepeat() EDIT2: Here is MemSet in form of UDF: Func MemSet($pDest, $nChar, $nCount) DllCall("msvcrt.dll", "ptr:cdecl", "memset", "ptr", $pDest, "int", $nChar, "int", $nCount) If @error Then Return SetError(1,0,False) Return True EndFunc1 point
-
Here's something to demo a way to do it. It's very basic, but it allows you to create and change the INI file. $IniFile = "text.ini" $ButtonText = IniRead($IniFile, "news", "motd", " Hello ") GUICreate("test", 200, 100) $Button = GUICtrlCreateButton(" Say something ", 10, 10) $Edit = GUICtrlCreateEdit("", 10, 40, 180, 50) $Button2 = GUICtrlCreateButton(" Change INI text ", 100, 10) GUISetState() while 1 $msg = GUIGetMsg() Switch $msg Case -3 Exit case $Button $ButtonText = IniRead($IniFile, "news", "motd", " Hello ") GUICtrlSetData($Edit, $ButtonText) Case $Button2 IniWrite($IniFile, "news", "motd", GUICtrlRead($Edit)) EndSwitch WEnd1 point
-
For one of my projects, I use a text ini file with this format: val1=true val2=4 val3="text" I read it, pass its contents to this function to populate variables from it: Func ReadInputParms ( $InBuf ) ;$inBuf is the text contents of the ini file dim $Input dim $InTokens dim $KeyVal dim $Key Dim $bDimmed = false $InBuf = StringRight ( $InBuf, StringLen ( $InBuf ) - 1 ) if StringLen ( $InBuf ) = 0 Then ; Process the command line if no buffer was passed in $Input = $CmdLineRaw EndIf $InTokens = StringSplit($InBuf, @CRLF, 1) Dim $boolval, $numval, $stringval for $i = 1 to $InTokens[0] ; loop through all input lines, and parse them if StringLen ( $InTokens [ $i ] ) > 0 Then Dim $array = StringSplit($InTokens[$i], "=") $Key = StringLower($array[1]) if StringInStr($Key, chr(34)) > 0 Then $Key = StringReplace($Key, chr(34), "") if StringInStr($InTokens[$i], "=") > 0 Then $KeyVal = $array[2] ; remove start and end quotes if needed if StringLeft($KeyVal, 1) = chr(34) and StringRight($KeyVal, 1) = chr(34) Then $KeyVal = StringMid($KeyVal, 2, stringlen($KeyVal) - 2) EndIf Else $KeyVal = True EndIf select case StringLower ( $Key ) = "booleanvalue" $boolval = ( StringLower($KeyVal) = "true" ) ; assign ini value to boolean variable case StringLower ( $Key ) = "numericvalue" $numval = $KeyVal * 1 ; assign ini value to numeric value Case StringLower ( $Key ) = "stringval" $stringval = $KeyVal ; assign ini value to string variable case StringLower ( $Key ) = "/?" ; user asked for help, display usage ShowUsage("") Exit 0 case Else ; unexpected value, show usage ShowUsage("Unknown parameter, '" & $InTokens[$i] & "'.") Exit 1 EndSelect EndIf Next EndFunc1 point
-
1 point
-
post 6 + post 11 #include<Constants.au3> Local $pid = Run("wmic csproduct list brief", @SystemDir, @SW_HIDE, $STDOUT_CHILD) ;wmic isn't an internal command to CMD ProcessWaitClose($pid) ;better than loops $output = StdoutRead($pid) ConsoleWrite($output) $array = StringSplit($output, @CRLF, 1) $pattern = 'Products+(.*?)s+w+' For $i = 0 to ubound($array) - 1 $re = StringRegExp($array[$i], $pattern , 3) If isarray($re) Then ConsoleWrite($re[0] & @LF) ExitLoop Endif Next1 point
-
Nice trick, can be used to change part of the buffers too. $nCount = 100 $sChar = "a" $tBuffer = DllStructCreate("char[" & $nCount & "]") DllCall("msvcrt.dll", "ptr:cdecl", "memset", "ptr", DllStructGetPtr($tBuffer), "int", Asc($sChar), "int", $nCount) ConsoleWrite(DllStructGetData($tBuffer, 1) & @CRLF) DllCall("msvcrt.dll", "ptr:cdecl", "memset", "ptr", DllStructGetPtr($tBuffer) + 5, "int", Asc("b"), "int", 10) ConsoleWrite(DllStructGetData($tBuffer, 1) & @CRLF) DllCall("msvcrt.dll", "ptr:cdecl", "memset", "ptr", DllStructGetPtr($tBuffer) + 5, "int", Asc(" "), "int", 10) ConsoleWrite(DllStructGetData($tBuffer, 1) & @CRLF) DllCall("msvcrt.dll", "ptr:cdecl", "memset", "ptr", DllStructGetPtr($tBuffer) + 50, "int", Asc(" "), "int", DllStructGetSize($tBuffer) - 50) ConsoleWrite(DllStructGetData($tBuffer, 1) & @CRLF) DllCall("msvcrt.dll", "ptr:cdecl", "memset", "ptr", DllStructGetPtr($tBuffer) + 75, "int", Asc("z"), "int", DllStructGetSize($tBuffer) - 75) ConsoleWrite(DllStructGetData($tBuffer, 1) & @CRLF)1 point
-
How to add link breaks?
kegiaumat055 reacted to czardas for a topic
What is this random number of sentences all about? $open= FileOpen('input.txt', 128) If @error Then Exit $update=FileOpen('output.txt',BitOR(128, 8, 1)) If @error Then Exit $text=FileRead($open) StringReplace($text, @CR, "") StringReplace($text, @LF, "") $text = StringStripWS($text, 3) If StringRight($text, 1) = "." Then $text = StringTrimRight($text, 1) $sens = StringSplit($text,".",1) $sString = "" For $i = 1 To $sens[0] For $j = 1 To Random(3,6,1) If $i > $sens[0] Then ExitLoop $sString &= $sens[$i] & "." $i += 1 Next $sString &= @CRLF $i -= 1 Next FileWrite($update, $sString)1 point -
1 point
-
How to add link breaks?
kegiaumat055 reacted to czardas for a topic
Okay that's a problem with the forum code tags. You should click the option where it says popup and the code appears in a new window. If you copy that and paste it directly into SciTE it should work fine. AdmiralAlkex got there first.1 point -
How to add link breaks?
kegiaumat055 reacted to AdmiralAlkex for a topic
Try copying from the popup and/or with a different browser1 point -
How to add link breaks?
kegiaumat055 reacted to czardas for a topic
Perhaps it was not intentional: since the OP's mother tongue is not English. I gave him the benefit of the doubt. Thanks for testing the script. The flags in the 3rd line really ought to be BitOr'ed together, but I didn't write that part.1 point -
How to add link breaks?
kegiaumat055 reacted to guinness for a topic
I agree with BrewManNH, just rude. czardas, I don't have a problem with your code in post #7. The output I got was1 point -
How to add link breaks?
kegiaumat055 reacted to czardas for a topic
I don't know - I can't recreate that error. It's possible you copied the wrong code, because I did make some changes to it. Does the code work for anyone else?1 point -
Notepad Help
Dasttann777 reacted to Skitty for a topic
Best way I'd recommend a user learn autoit is by randomly searching for cool scripts, play with them and change stuff until you mess it up. Gives you a good feel of how autoit works. I've also made a habit of saving every script that seems interesting to me in a folder called "script bank", it's already grown to be 150+ mb and it's very damn handy to use when creating new scripts because I tend to separate functions that do an intended action into categories, this way I can just do a quick search through the folder, and I'll have a working script in no-time after a few copy and paste maneuvers. I've probably got at least 30% of all the scripts in the example section separated and categorized in there.1 point