alex OF DEATH Posted July 4, 2007 Share Posted July 4, 2007 Is there anyway to have it return 1 if there is white space? I have a string with two sets of numbers seperated with a white space along with another white space and a series of letters. I need to strip out the letters, which I COULD do with this: do $Item2 = StringTrimRight ( "" & $line, 1 ) until StringIsAlNum ( "" & $item2 ) = 1 BUT the white space prevents it from returning 1. Here is an example of a string I need to work with: -- 3 72 Archmage Coat "A coat that is especially designed to be worn by advanced Muses." -- Despite what it may look like, It's not a game bot. Matter of fact, it helps the game. So please don't let this discourage you from helping. Link to comment Share on other sites More sharing options...
MrCreatoR Posted July 4, 2007 Share Posted July 4, 2007 Hi,To strip the white spaces use StringStripWS($String, 8) Spoiler Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1 AutoIt Russian Community My Work... Spoiler Projects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating ) * === My topics === * ================================================== ================================================== AutoIt is simple, subtle, elegant. © AutoIt Team Link to comment Share on other sites More sharing options...
alex OF DEATH Posted July 4, 2007 Author Share Posted July 4, 2007 Hi,To strip the white spaces use StringStripWS($String, 8)But I need to keep the whitespace. Link to comment Share on other sites More sharing options...
alex OF DEATH Posted July 4, 2007 Author Share Posted July 4, 2007 this is the string your working with. what does the end result need to be3 72 Archmage Coat "A coat that is especially designed to be worn by advanced Muses."3 72 Link to comment Share on other sites More sharing options...
alex OF DEATH Posted July 4, 2007 Author Share Posted July 4, 2007 if i understand mabe Stringleft($line, 4)But the numbers vary.Some have more numbers than others.Like, 10 202 Drive-by Leaping Strike "Leap high into the sky to strike the head of an enemy with an attack that will decrease its Attack and Movement Speeds." Link to comment Share on other sites More sharing options...
xcal Posted July 4, 2007 Share Posted July 4, 2007 (edited) Maybe this'll help a bit... $string = '3 72 Archmage Coat "A coat that is especially designed to be worn by advanced Muses."' $ret = StringStripWS(StringRegExpReplace($string, '[^0-9 ]', ''), 3) MsgBox(0, '', $ret) Edited July 4, 2007 by xcal How To Ask Questions The Smart Way Link to comment Share on other sites More sharing options...
alex OF DEATH Posted July 4, 2007 Author Share Posted July 4, 2007 Maybe this'll help a bit... $string = '3 72 Archmage Coat "A coat that is especially designed to be worn by advanced Muses."' $ret = StringStripWS(StringRegExpReplace($string, '[^0-9 ]', ''), 3) MsgBox(0, '', $ret)Can you explain what that does. I don't seem to understand it from the help file. Also, it always returns "8 7" Link to comment Share on other sites More sharing options...
alex OF DEATH Posted July 4, 2007 Author Share Posted July 4, 2007 ok is your script writing the file that this line is being read from if so show the code where the file is writtenNo, it searches for the line in a file that's already there. Link to comment Share on other sites More sharing options...
xcal Posted July 4, 2007 Share Posted July 4, 2007 Can you explain what that does. I don't seem to understand it from the help file. Also, it always returns "8 7" No idea why it would always return 8 7. For me it returns the expected 3 72. The [^0-9 ] means not a number 0 to 9 and not a space (since there's a space after the 9). So it's replacing all the characters that don't match with '' (nothing). The stringstripws is just trimming the trailing/leading spaces. How To Ask Questions The Smart Way Link to comment Share on other sites More sharing options...
alex OF DEATH Posted July 4, 2007 Author Share Posted July 4, 2007 No idea why it would always return 8 7. For me it returns the expected 3 72. The [^0-9 ] means not a number 0 to 9 and not a space (since there's a space after the 9). So it's replacing all the characters that don't match with '' (nothing). The stringstripws is just trimming the trailing/leading spaces. Oh I see now, thank you. I'll mess with some things and post the results. Link to comment Share on other sites More sharing options...
alex OF DEATH Posted July 4, 2007 Author Share Posted July 4, 2007 It's not xcal's script that is doing something wrong, it's mine. Here's the whole function Func Start() $filename = "Itemlist.txt" $word = $name $h = FileOpen($filename, 0) $line = FileReadLine($h) $Line = StringInStr($line, $word) FileClose($h) $ret = StringStripWS(StringRegExpReplace($line, '[^0-9 ]', ''), 3) $FinalItem = _StringReverse ( $ret ) Send ( "/item " & $finalitem & " " & $amount & " " & $refine & " 100" & " 100" ) Endfunc I had help with this in my last topic, and I don't think I got it working right with the help I got here. I'm tempted to scrap it and do it over now that I know some new things, but not if we can spot whats going wrong. (Which I'm pretty sure I already did, I just can't fix it ) Link to comment Share on other sites More sharing options...
xcal Posted July 4, 2007 Share Posted July 4, 2007 xcal's way is working fine on mine as well. but if you want to try another way try this $string = '10 202 Drive-by Leaping Strike "Leap high into the sky to strike the head of an enemy with an attack that will decrease its Attack and Movement Speeds."' $ret = StringRegExp( $string, '([^a-z][^A-Z]{1,10})',1) MsgBox(0, "", $ret[0]) That works well, too. Maybe even better if the string can contain other numbers later on. I'd just change {1,10} to {1,}. How To Ask Questions The Smart Way Link to comment Share on other sites More sharing options...
alex OF DEATH Posted July 4, 2007 Author Share Posted July 4, 2007 That works well, too. Maybe even better if the string can contain other numbers later on. I'd just change {1,10} to {1,}.1. It's a veeeerrrrryyyy long item file.2. An input box. Link to comment Share on other sites More sharing options...
alex OF DEATH Posted July 4, 2007 Author Share Posted July 4, 2007 just use the upload option when u reply for the file, and give me an example of what you would type in the inputboxI usually type "ruby" because it's short.ItemList.txt Link to comment Share on other sites More sharing options...
alex OF DEATH Posted July 4, 2007 Author Share Posted July 4, 2007 does ruby standy for the jewel of passion in the txt fileWhat I mean is, is that why you type that wordUh, no. It's one of the items. Link to comment Share on other sites More sharing options...
alex OF DEATH Posted July 4, 2007 Author Share Posted July 4, 2007 ok to be more clear are you typing ruby because thats what your looking for in the Itemlist.txtYes. Link to comment Share on other sites More sharing options...
alex OF DEATH Posted July 4, 2007 Author Share Posted July 4, 2007 (edited) returned: /item 4 1 7 8 100 100 supposed to return: /item 311 11 1 5 100 100 assuming we are using ruby -- It's fine, dude. Thanks for help, but you don't have to kill yourself over this script. here's the entire script, just if you care. expandcollapse popup;Item Command Easy-ifier ;Item /item [itemid] [itemtype] [itemamount] [refine] [lifespawn] [stats] [socket] ;--------------------------------------------------------------------------------- #include <GUIConstants.au3> #Include <String.au3> Hotkeyset ( "{Enter}", "Start" ) Opt ("Guioneventmode", 1) #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("AForm1", 620, 102, 194, 117) $Input1 = GUICtrlCreateInput("", 72, 0, 193, 21) $name = GUICtrlCreateLabel("Item NAME", 0, 0, 58, 17) $Input2 = GUICtrlCreateInput("1", 74, 36, 193, 21) $Input3 = GUICtrlCreateInput("5", 75, 78, 193, 21) $amount = GUICtrlCreateLabel("Item AMOUNT", 0, 40, 74, 17) $refine = GUICtrlCreateLabel("Item REFINE", 3, 80, 66, 17) $Niggawats = GUICtrlCreateLabel("BY DEJECT3D", 424, 0, 76, 17) $Label4 = GUICtrlCreateLabel("UPDATES COMING WHEN I'M LESS LAZY", 360, 16, 215, 17) $Label5 = GUICtrlCreateLabel("LIKE LISTS OF ITEMS AT ONCE AND STUFF I GUESS", 328, 32, 272, 17) $Button1 = GUICtrlCreateButton("BIG BUTTONS MAKE EVERYTHING COOL", 264, 48, 329, 49, 0) Guictrlsetonevent ($button1, "start" ) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd ;------------------------------------------------ Func Start() $word = $name $line = FileOpen("C:\Itemlist.txt", 0) $i = 1 While 1 $line1 = FileReadLine($line) $string = StringInStr($line1, $word) If Not $string = 0 Then ExitLoop EndIf $i = $i + 1 WEnd $line = FileReadLine($line, $i) $ret = StringRegExp( $line1, '[^a-z][^A-Z]{1,10}',1) $Item = _StringReverse($ret[0]) Send ( "/item " & $Item & " " & $amount & " " & $refine & " 100" & " 100" ) Endfunc Edited July 4, 2007 by alex OF DEATH Link to comment Share on other sites More sharing options...
alex OF DEATH Posted July 4, 2007 Author Share Posted July 4, 2007 couldn't find ruby, item not found box is looped. Link to comment Share on other sites More sharing options...
alex OF DEATH Posted July 4, 2007 Author Share Posted July 4, 2007 does the gui close after you press your hotkeyno Link to comment Share on other sites More sharing options...
mikehunt114 Posted July 4, 2007 Share Posted July 4, 2007 There were quite a few errors in the code. You were using OnEventMode half the time, and half the time you weren't. GUISetOnEvent($GUI_EVENT_CLOSE, "Exit") or similar should be used for OnEventMode, not using a while loop and getting the event close message. The values from your inputs were miscoded as being a reference to label....you need to GUICtrlRead($input). I think I also simplified your Start() function. Take a look at this code: expandcollapse popup;Item Command Easy-ifier ;Item /item [itemid] [itemtype] [itemamount] [refine] [lifespawn] [stats] [socket] ;--------------------------------------------------------------------------------- #include <GUIConstants.au3> #Include <String.au3> #include <Array.au3> Hotkeyset ( "{Enter}", "Start" ) Opt ("GUIOnEventMode", 1) $Form1 = GUICreate("AForm1", 620, 102, 194, 117) $Input1 = GUICtrlCreateInput("", 72, 0, 193, 21) $name = GUICtrlCreateLabel("Item NAME", 0, 0, 58, 17) $Input2 = GUICtrlCreateInput("1", 74, 36, 193, 21) $Input3 = GUICtrlCreateInput("5", 75, 78, 193, 21) $amount = GUICtrlCreateLabel("Item AMOUNT", 0, 40, 74, 17) $refine = GUICtrlCreateLabel("Item REFINE", 3, 80, 66, 17) $Niggawats = GUICtrlCreateLabel("BY DEJECT3D", 424, 0, 76, 17) $Label4 = GUICtrlCreateLabel("UPDATES COMING WHEN I'M LESS LAZY", 360, 16, 215, 17) $Label5 = GUICtrlCreateLabel("LIKE LISTS OF ITEMS AT ONCE AND STUFF I GUESS", 328, 32, 272, 17) $Button1 = GUICtrlCreateButton("BIG BUTTONS MAKE EVERYTHING COOL", 264, 48, 329, 49, 0) GUICtrlSetOnEvent($button1, "Start" ) GUISetOnEvent($GUI_EVENT_CLOSE, "Terminate") GUISetState(@SW_SHOW) While 1 sleep(10) WEnd ;------------------------------------------------ Func Start() $word = GUICtrlRead($Input1) $file = FileOpen("C:\Itemlist.txt", 0) If $file = -1 Then ConsoleWriteError("Error opening file." & @CRLF) $i = 1 While 1 $line = FileReadLine($file) $string = StringInStr($line, $word) If Not $string = 0 Then ExitLoop EndIf $i += 1 WEnd $string = FileReadLine($file, $i) $string = StringSplit($string, " ") If $string[0] = 4 Then MsgBox(0, "", "/item " & $string[1] & " " & $string[2] & " " & GUICtrlread($Input2) & " " & GUICtrlRead($Input3) & " 100" & " 100" ) Else ConsoleWriteError("Uncommon number of delimiters, check text file." & @CRLF) EndIf Endfunc Func Terminate() Exit 0 EndFunc Hope that helps. IE Dev ToolbarMSDN: InternetExplorer ObjectMSDN: HTML/DHTML Reference Guide[quote]It is surprising what a man can do when he has to, and how little most men will do when they don't have to. - Walter Linn[/quote]--------------------[font="Franklin Gothic Medium"]Post a reproducer with less than 100 lines of code.[/font] 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