James Posted December 29, 2006 Posted December 29, 2006 (edited) What is the proper way of using StringReplace? Case $Replace $2Find = InputBox("Replace", "What string/line would you like to replace?") $ReplaceWith = InputBox("Replace", "What would you like to replace " & $2Find & " with?") $text = StringReplace(GuiCtrlRead($DocEd1), $2Find, $ReplaceWith, 0, 0) $numreplacements = @extended MsgBox(0, "Replace", $numreplacements & " were made!") It thinks it is making the replacements, and it knows its there. But it doesn't "update" $DocEd1 Secure Edited December 29, 2006 by Secure_ICT Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ
Helge Posted December 29, 2006 Posted December 29, 2006 (edited) It did the replacements, but you made it so that the new text is stored in $text and not in $DocEd1. Edited December 29, 2006 by Helge
James Posted December 29, 2006 Author Posted December 29, 2006 Well I have: Case $Replace $2Find = InputBox("Replace", "What string/line would you like to replace?") $ReplaceWith = InputBox("Replace", "What would you like to replace " & $2Find & " with?") $DocEd1 = StringReplace(GuiCtrlRead($DocEd1), $2Find, $ReplaceWith, 0, 0) $numreplacements = @extended MsgBox(0, "Replace", $numreplacements & " were made!") But that doesn't work either. It says it has replaced it, but nothing changes. Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ
GEOSoft Posted December 29, 2006 Posted December 29, 2006 What is the proper way of using StringReplace? Case $Replace $2Find = InputBox("Replace", "What string/line would you like to replace?") $ReplaceWith = InputBox("Replace", "What would you like to replace " & $2Find & " with?") $text = StringReplace(GuiCtrlRead($DocEd1), $2Find, $ReplaceWith, 0, 0) $numreplacements = @extended MsgBox(0, "Replace", $numreplacements & " were made!") It thinks it is making the replacements, and it knows its there. But it doesn't "update" $DocEd1 SecureGUICtrlSetData($DocEd1, $Text) ? George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!"
James Posted December 29, 2006 Author Posted December 29, 2006 No, because that would replace the whole of $DocEd1. Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ
Developers Jos Posted December 29, 2006 Developers Posted December 29, 2006 No, because that would replace the whole of $DocEd1.ahh you want magic ....What else do you think you need to do ?You read the whole text in which you replace a string with another string... logic says you need to store the whole text back into the Edit box ... 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.
James Posted December 29, 2006 Author Posted December 29, 2006 I don't get you.. What do you mean store? Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ
Moderators SmOke_N Posted December 29, 2006 Moderators Posted December 29, 2006 No, because that would replace the whole of $DocEd1.Yes it would, and at the same time change the text you would want to change. You don't expect it to just change the text specific and nothing else do you? The thing I see most in your questions, and in rebuttals, is you seem to forget you are not just messing with "one" function. You have to make "everything" work. Example: $Main = GUICreate('Example', 250, 350) $Edit = GUICtrlCreateEdit('This is the text I am going to change.', 10, 10, 230, 290) $Button = GUICtrlCreateButton('Change', 100, 310, 50, 30) GUISetState() While 1 Switch GUIGetMsg() Case -3 Exit Case $Button $sReadEdit = GUICtrlRead($Edit) GUICtrlSetData($Edit, '') GUICtrlSetData($Edit, StringReplace($sReadEdit, 'am going to', 'did')) EndSwitch WEnd Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
Developers Jos Posted December 29, 2006 Developers Posted December 29, 2006 (edited) I don't get you.. What do you mean store?lets return the question: How do you perceive this replace routine should work ? Now think in a flowchart step by step process and chart that out for yourself... Thats how you start a program ... not writing code and "see where the ship will land" ... Edited December 29, 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.
Helge Posted December 29, 2006 Posted December 29, 2006 $DocEd1 = StringReplace(GuiCtrlRead($DocEd1), $2Find, $ReplaceWith, 0, 0) Now the new text is stored in $DocEd1, but now that you've replaced the control's ID with the text how are you planning on working with the control again ? No, because that would replace the whole of $DocEd1.Well, how are you planning on using the new text then ? Use GUICtrlSetData to update the control with the updated text, using the controlID you don't have anymore.
James Posted December 29, 2006 Author Posted December 29, 2006 (edited) Thanks everyone!I have done it.Case $Replace $2Find = InputBox("Replace", "What string/line would you like to replace?") $ReplaceWith = InputBox("Replace", "What would you like to replace " & $2Find & " with?") $sReadEdit = GUICtrlRead($DocEd1) GUICtrlSetData($DocEd1, '') $DocEd1 = GUICtrlSetData($DocEd1, StringReplace($sReadEdit, $2Find, $ReplaceWith)) $numreplacements = @extended MsgBox(0, "Replace", $numreplacements & " were made!")Thankyou SO much.Edit: It works for the first edit. But then, when you try another edit, it doesn't work.Edit: Well I don't know what I did, but it will replace more than one now. But it doesn't count the amount of replacments. Edited December 29, 2006 by Secure_ICT Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ
Thatsgreat2345 Posted December 29, 2006 Posted December 29, 2006 Why are you setting Guictrlsetdata to $DocEd1? goodness
James Posted December 29, 2006 Author Posted December 29, 2006 Case $Replace $2Find = InputBox("Replace", "What string/line would you like to replace?") $ReplaceWith = InputBox("Replace", "What would you like to replace " & $2Find & " with?") $sReadEdit = GUICtrlRead($DocEd1) GUICtrlSetData($DocEd1, '') GUICtrlSetData($DocEd1, StringReplace($sReadEdit, $2Find, $ReplaceWith)) $numreplacements = @extended MsgBox(0, "Replace", $numreplacements & " were made!") It replaces, but doesnt add the amount of replacments. Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ
Developers Jos Posted December 29, 2006 Developers Posted December 29, 2006 (edited) Edit: Well I don't know what I did, but it will replace more than one now. But it doesn't count the amount of replacments. That is because @extended has the value of the last performed function which is GuiCtrlSetData() $2Find = InputBox("Replace", "What string/line would you like to replace?") $ReplaceWith = InputBox("Replace", "What would you like to replace " & $2Find & " with?") $sReadEdit = GUICtrlRead($DocEd1) $sReadEdit = StringReplace($sReadEdit, $2Find, $ReplaceWith) $numreplacements = @extended GUICtrlSetData($DocEd1, $sReadEdit ) Edited December 29, 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.
Developers Jos Posted December 29, 2006 Developers Posted December 29, 2006 Why are you setting Guictrlsetdata to $DocEd1? goodnessYou want us to nickpick all your stuff this way ? 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.
Thatsgreat2345 Posted December 29, 2006 Posted December 29, 2006 I really question what your trying to do because by the looks of it your making up some random string, replacing the string with a different string then setting it to a input box and seeing how many things were replaced. Well its only going to replace one every time if I'm not mistaken
James Posted December 29, 2006 Author Posted December 29, 2006 Ahh right.. I didn't know that. Thanks JdeB. And everyone. Secure Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ
Thatsgreat2345 Posted December 29, 2006 Posted December 29, 2006 You want us to nickpick all your stuff this way ?Ummm no its just he's destroying his control ID when he's been told already that it would, sure if you want to nickpick my stuff since I hardly ever post questions feel free.
James Posted December 29, 2006 Author Posted December 29, 2006 ThatsGreat: Its a replacement tool, for my BetaPad. Its all working now, so you don't need to worry. Thanks once again for everyone who helped. Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ
Developers Jos Posted December 29, 2006 Developers Posted December 29, 2006 Ummm no its just he's destroying his control ID when he's been told already that it would, sure if you want to nickpick my stuff since I hardly ever post questions feel free.sure ... and he will keep on making mistakes like this till he truly understands more about programming ... Nothing wrong with that ... only Secure really needs to start think about the process more and stop posting every bump he hits. 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.
Recommended Posts