flaxcrack Posted January 13, 2006 Share Posted January 13, 2006 Here is my very first UDF. Go easy on me!expandcollapse popup#comments-start Function Name: _StringKeep() Description: Designed to perform the opposite of StringTrimLeft/Right Parameter(s): $nLen - Is how much of the variable you wish to keep $nVar - Is the variable that be used $nOpt - Is the Option that can be used: 1 - Default Option - Will keep the length assigned from the right 2 - -------------- - Will keep the length assigned from the left Requirement(s): AutoIt3 Beta Return Value(s): On Success - The variable with the assigned length to keep On Failure - sets @ERROR = 1 Author: Flaxcrack @ www.autoitscript.com Example: $in = "Here is my input into the script. Look at me go" $out = _FixedVar(16, $in) _SringKeep() will return: Here is my input #comments-end Func _StringKeep($nLen, $nVar, $nOpt = 1) Local $nW1 Local $nW2 If $nOpt = 1 Then $nW1 = 1 EndIf If $nOpt = 2 Then $nW2 = 1 EndIf If Not $nOpt = 0 Or 2 Then SetError(1) EndIf While $nW1 = 1 $nVar = StringTrimRight($nVar, StringLen($nVar) - $nLen) Return $nVar $nw1 = $nw1 + 1 WEnd While $nW2 = 1 $nVar = StringTrimLeft($nVar, StringLen($nVar) - $nLen) Return $nVar $nw2 = $nw2 + 1 WEnd EndFunc [quote] Gilbertson's Law: Nothing is foolproof to a sufficiently talented fool.Sandro Alvares: Flaxcrack is please not noob! i can report you is stop stupid. The Post[/quote]I made this: FWD & MD5PWD() Link to comment Share on other sites More sharing options...
Developers Jos Posted January 13, 2006 Developers Share Posted January 13, 2006 Here is my very first UDF. Go easy on me!Function Name: _StringKeep()Description: Designed to perform the opposite of StringTrimLeft/Right Is this similar to StringLeft() and StringRight() ? 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...
flaxcrack Posted January 13, 2006 Author Share Posted January 13, 2006 Is this similar to StringLeft() and StringRight() ? I made something that was already there. Well that sucks, but I guess the bright side is that you can accomplish StringLeft() and StringRight() with less key strokes using StringKeep(). [quote] Gilbertson's Law: Nothing is foolproof to a sufficiently talented fool.Sandro Alvares: Flaxcrack is please not noob! i can report you is stop stupid. The Post[/quote]I made this: FWD & MD5PWD() Link to comment Share on other sites More sharing options...
Developers Jos Posted January 13, 2006 Developers Share Posted January 13, 2006 I made something that was already there. Well that sucks, but I guess the bright side is that you can accomplish StringLeft() and StringRight() with less key strokes using StringKeep(). You know what's so about the HelpFile ? it has this nice section for all functions: RelatedString, StringInStr, StringLeft, StringLen, StringLower, StringMid, StringRight, StringTrimRight, StringUpper 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...
flaxcrack Posted January 13, 2006 Author Share Posted January 13, 2006 You know what's so about the HelpFile ? it has this nice section for all functions: I know. I consulted the all mighty help file after your first post. And I was thinking to my self that I was being rather clever. [quote] Gilbertson's Law: Nothing is foolproof to a sufficiently talented fool.Sandro Alvares: Flaxcrack is please not noob! i can report you is stop stupid. The Post[/quote]I made this: FWD & MD5PWD() Link to comment Share on other sites More sharing options...
jpm Posted January 13, 2006 Share Posted January 13, 2006 I know. I consulted the all mighty help file after your first post. And I was thinking to my self that I was being rather clever. what not so clever is the logic of this sequence: While $nW1 = 1 $nVar = StringTrimRight($nVar, StringLen($nVar) - $nLen) Return $nVar $nw1 = $nw1 + 1 WEnd $nw1 can never be incremented if you need it. Samething is true for the next sequence with $nw2. Link to comment Share on other sites More sharing options...
flaxcrack Posted January 14, 2006 Author Share Posted January 14, 2006 what not so clever is the logic of this sequence: While $nW1 = 1 $nVar = StringTrimRight($nVar, StringLen($nVar) - $nLen) Return $nVar $nw1 = $nw1 + 1 WEnd $nw1 can never be incremented if you need it. Samething is true for the next sequence with $nw2. @JMP Can you please explain what you mean? [quote] Gilbertson's Law: Nothing is foolproof to a sufficiently talented fool.Sandro Alvares: Flaxcrack is please not noob! i can report you is stop stupid. The Post[/quote]I made this: FWD & MD5PWD() Link to comment Share on other sites More sharing options...
Developers Jos Posted January 14, 2006 Developers Share Posted January 14, 2006 (edited) @JMP Can you please explain what you mean?Come on.... think about it ...one line at the time. While $nW1 = 1 ; <== what is the need of the endless loop ? $nVar = StringTrimRight($nVar, StringLen($nVar) - $nLen) ; Ceate the result value Return $nVar ; Return back to the line that called this function $nw1 = $nw1 + 1 ; <= This line will NEVER be reached WEnd ; <== what is the need on the endless loop ? so this code does the same as your UDF : Func _StringKeep($nLen, $nVar, $nOpt = 1) If $nOpt = 1 Then Return StringTrimRight($nVar, StringLen($nVar) - $nLen) If $nOpt = 2 Then Return StringTrimLeft($nVar, StringLen($nVar) - $nLen) SetError(1) EndFunc Edited January 14, 2006 by JdeB 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...
flaxcrack Posted January 14, 2006 Author Share Posted January 14, 2006 Come on.... think about it ...one line at the time. While $nW1 = 1 ; <== what is the need of the endless loop ? $nVar = StringTrimRight($nVar, StringLen($nVar) - $nLen) ; Ceate the result value Return $nVar ; Return back to the line that called this function $nw1 = $nw1 + 1 ; <= This line will NEVER be reached WEnd ; <== what is the need on the endless loop ? so this code does the same as your UDF : Func _StringKeep($nLen, $nVar, $nOpt = 1) If $nOpt = 1 Then Return StringTrimRight($nVar, StringLen($nVar) - $nLen) If $nOpt = 2 Then Return StringTrimLeft($nVar, StringLen($nVar) - $nLen) SetError(1) EndFunc See. Thats all I needed. A little explaining. I never said was an ueber programer. It is ofcourse my FIRST UDF. [quote] Gilbertson's Law: Nothing is foolproof to a sufficiently talented fool.Sandro Alvares: Flaxcrack is please not noob! i can report you is stop stupid. The Post[/quote]I made this: FWD & MD5PWD() 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