Jump to content

TheDcoder

Active Members
  • Posts

    7,103
  • Joined

  • Days Won

    88

Everything posted by TheDcoder

  1. It would be nice if the OP uses code tags
  2. @czardas Congratulations on your 7,800th post The best thing to do when you need to ReDim an array is: TD
  3. Thanks @water Updated it, TD
  4. @Bowmore Try it: Local $aArray[524288] MsgBox(0, "Script Paused", "Open Task Manager & Have A Look At Its RAM Usage")TD
  5. An array with 524288 elements (all empty) would take 3.4 MB of RAM
  6. @water You totally whacked me on that one
  7. @water Sure, I would not expect that. But I would be happy to know that it has another use
  8. @water was that for me ?
  9. ​Why? Isn't it a good thing? (I am a newbie in the world of programming btw). Just curious
  10. @Melba23 I see... ReDim works fine for me in this case (ReDim take 0.01 ms to expand an array by 1 with 200 elements ). So I will stick to _ArrayAdd because I need to expand an array only ~10 times TD
  11. I found this awesome function called _ArrayAdd which does the same thing as ExpandArray... I don't know about internal workings of it but It does the job (internal workings should be fine b/c its coded by AutoIt pros) TD
  12. @water Will not work for delimiter with multiple characters
  13. My First Submission: ; #FUNCTION# ==================================================================================================================== ; Name ..........: StringTrimLeftUntil ; Description ...: Trim a string left until it reaches the delimiter charecter ; Syntax ........: StringTrimLeftUntil($sDelimiter, $sString) ; Parameters ....: $sDelimiter - Charecter(s) to trim until ; $sString - A string value. ; $iOccurrence - Trim until which occurrence of the delimiter [Default = 1st occurrence] ; $bTrimDelimiter - Do you want to trim the delimiter? Use True or False [Default = True] ; Return values .: Trimmed String ; Author ........: TheDcoder ; Modified ......: Thanks to water for the Idea ; Remarks .......: This function is not case sensitive meaning "DeLiMiTeR" is same as "Delimiter" ; Related .......: StringTrimLeft ; Link ..........: http://bit.ly/StringTrimUntilForAutoIt ; Example .......: No ; =============================================================================================================================== Func StringTrimLeftUntil($sDelimiter, $sString, $iOccurrence = 1, $bTrimDelimiter = True) $iDelimiterLen = StringLen($sDelimiter) $sString = StringTrimLeft($sString, StringInStr($sString, $sDelimiter, 2, $iOccurrence) + ($iDelimiterLen - 1)) ; This is a little hard to explain: #cs =========================================================================================================================================| | What it does is: | | 1. Find the delimiter's position in the string (StringInStr) | | 2. Add delimiter's Length to delimiters position (I remove 1 for delimiter's length because StringInStr already contains that 1 charecter) | | 3. Trim the string :) | #ce =========================================================================================================================================| If $bTrimDelimiter = False Then $sString = $sDelimiter & $sString ; Look at the comment in StringTrimRightUntil ;) Return $sString ; Return the String :D EndFunc ;==>StringTrimLeftUntil ; #FUNCTION# ==================================================================================================================== ; Name ..........: StringTrimRightUntil ; Description ...: Trim a string right until it reaches the delimiter charecter ; Syntax ........: StringTrimRightUntil($sDelimiter, $sString) ; Parameters ....: $sDelimiter - Charecter(s) to trim until ; $sString - A string value. ; $iOccurrence - Trim until which occurrence of the delimiter [Default = 1st occurrence] ; $bTrimDelimiter - Do you want to trim the delimiter? Use True or False [Default = True] ; Return values .: Trimmed String ; Author ........: TheDcoder ; Modified ......: Me ; Remarks .......: This function is not case sensitive meaning "DeLiMiTeR" is same as "Delimiter". ; PLEASE USE StringTrimLeftUntil WHENEVER POSSIBLE! StringTrimRightUntil is slightly slower than StringTrimLeftUntil (62.2% slower to be exact) ; Related .......: StringTrimRight ; Link ..........: http://bit.ly/StringTrimUntilForAutoIt ; Example .......: No ; =============================================================================================================================== Func StringTrimRightUntil($sDelimiter, $sString, $iOccurrence = 1, $bTrimDelimiter = True) $iStringLen = StringLen($sString) ; We need string's len $iDelimiterLen = StringLen($sDelimiter) ; We need delimiter's len too $iOccurrence -= $iOccurrence * 2 ; Convert to negitive integer so that we can find the delimiter from the right-side $sString = StringTrimRight($sString, ($iStringLen - StringInStr($sString, $sDelimiter, 2, $iOccurrence)) - ($iDelimiterLen - 1) + $iDelimiterLen) ; Explanation: #cs ===========================================================================================================================================================| | 1. Find the delimiter's postion in the string from the right-side (StringInStr) & remove string's length to get the no. of chars to trim from te right-side | | 2. Substract (delimiter's len - 1) in the no. of char to trim | | 3. Again add delimiter's len | | 4. Trim the string!!! | #ce ===========================================================================================================================================================| If $bTrimDelimiter = False Then $sString &= $sDelimiter ; This way simplest way to do it without messing with the complex algorithm (Also even I can't understand the algorithm cleary! Even though I got it working somehow :-/) Return $sString ; Return the String EndFunc ;==>StringTrimRightUntilHope it may help someone, TD
  14. @Venix Why wont it compile ? What error do you get in the complication process?
  15. Wow, I thought DOS's apps cannot be executed on windows P.S I remember opening exe files with notepad hoping hack the game & there will be a small note between the binary characters: I done stuff like this when I was 11 (yeah, before 3 years. what an improvement )
  16. I found out my answer Local $aArray[4] = [0, 1, 2, 3] Func ExpandArray(ByRef $aArray, $iExpandCount) ReDim $aArray[UBound($aArray) + ($iExpandCount - 1)] EndFunc
  17. Sorry for posting this in GUI help section
  18. @argumentum Not sure if its dosbox or colored command prompt
  19. Hello , I know about ReDim but I am confused Local $aArray[4] = [0, 1, 2, 3] Func ExpandArray(ByRef $aArray) ; How? EndFuncThanks in Advance, TD
×
×
  • Create New...