Ranek Posted November 30, 2011 Share Posted November 30, 2011 Hey All, I wondered if this was something suited for AutoIt or whether I would be better off attempting it with Java. My programming skills are all in all pretty poor so whichever way would be most effective is the one i'll try. I have a sequence like this. The value of "left" increments by 135 from 0 to 270. Then loops. The value of "top" increments by 154 on each new loop. As below. <div class="js-image size-2" style="height: 143px; left:0px; top: 154px;"> <div class="js-image size-2" style="height: 143px; left:135px; top: 154px;"> <div class="js-image size-2" style="height: 143px; left:270px; top: 154px;"> <div class="js-image size-2" style="height: 143px; left:0px; top: 308px;"> <div class="js-image size-2" style="height: 143px; left:135px; top: 308px;"> <div class="js-image size-2" style="height: 143px; left:270px; top: 308px;"> Every so often I need to edit this information and add a new entry of code in. Which messes up the sequence and requires every piece of code below my new entry to be changed into sequence. Would it be simple to make something to do this for me using AutoIT or should I try using Java? I'm new here, just found out about it. So not entirely sure of the language functionality. Kind Regards Ranek Link to comment Share on other sites More sharing options...
Xenobiologist Posted November 30, 2011 Share Posted November 30, 2011 Should be no problem with Autoit. I'll post a try soon. :-) Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
Xenobiologist Posted November 30, 2011 Share Posted November 30, 2011 Just a short try: $str = '<div class="js-image size-2" style="height: 143px; left:0px; top: 154px;">' & @CRLF & _ '<div class="js-image size-2" style="height: 143px; left:135px; top: 154px;">' & @CRLF & _ '<div class="js-image size-2" style="height: 143px; left:270px; top: 154px;">' & @CRLF & _ '<div class="js-image size-2" style="height: 143px; left:0px; top: 308px;">' & @CRLF & _ '<div class="js-image size-2" style="height: 143px; left:135px; top: 308px;">' & @CRLF & _ '<div class="js-image size-2" style="height: 143px; left:270px; top: 308px;">' & @CRLF $strBefore = $str Global $left[3][2] = [["left:0px", "left:1px"],["left:135px", "left:200px"],["left:270px", "left:400px"]] Global $top[2][2] = [["top: 154px", "top: 100px"],["top: 308px", "top: 300px"]] For $i = 0 To UBound($left) - 1 $str = StringReplace($str, $left[$i][0], $left[$i][1]) Next For $i = 0 To UBound($top) - 1 $str = StringReplace($str, $top[$i][0], $top[$i][1]) Next MsgBox(64, 'Info', $strBefore & @CRLF & @CRLF & $str) Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
Ranek Posted November 30, 2011 Author Share Posted November 30, 2011 (edited) Hi Xenobiologist, Cheers for helping me out.I had a look at your code and tried it out but i'm not sure it does what I want. Maybe its because I didn't explain myself very well. In your example the code finds all examples of the number eg 270 and replaces that with 400. But if for example I wanted to add a new entry in like this. Now there are two of the same line in a row. $str = '<div class="js-image size-2" style="height: 143px; left:0px; top: 154px;">' & @CRLF & _ '<div class="js-image size-2" style="height: 143px; left:135px; top: 154px;">' & @CRLF & _ '<div class="js-image size-2" style="height: 143px; left:270px; top: 154px;">' & @CRLF & _ '<div class="js-image size-2" style="height: 143px; left:0px; top: 308px;">' & @CRLF & _ '<div class="js-image size-2" style="height: 143px; left:135px; top: 308px;">' & @CRLF & _ '<div class="js-image size-2" style="height: 143px; left:135px; top: 308px;">' & @CRLF & _ '<div class="js-image size-2" style="height: 143px; left:270px; top: 308px;">' & @CRLF $strBefore = $str Global $left[3][2] = [["left:0px", "left:1px"],["left:135px", "left:200px"],["left:270px", "left:400px"]] Global $top[2][2] = [["top: 154px", "top: 100px"],["top: 308px", "top: 300px"]] For $i = 0 To UBound($left) - 1 $str = StringReplace($str, $left[$i][0], $left[$i][1]) Next For $i = 0 To UBound($top) - 1 $str = StringReplace($str, $top[$i][0], $top[$i][1]) Next MsgBox(64, 'Info', $strBefore & @CRLF & @CRLF & $str) I would now want the program to output a result like this: <div class="js-image size-2" style="height: 143px; left:1px; top: 100px;"> <div class="js-image size-2" style="height: 143px; left:200px; top: 100px;"> <div class="js-image size-2" style="height: 143px; left:400px; top: 100px;"> <div class="js-image size-2" style="height: 143px; left:1px; top: 300px;"> <div class="js-image size-2" style="height: 143px; left:200px; top: 300px;"> <div class="js-image size-2" style="height: 143px; left:400px; top: 300px;"> <div class="js-image size-2" style="height: 143px; left:1px; top: 500px;"> I'll have a look about and see if anyone has accomplished anything similar. Cheers Ranek Edited November 30, 2011 by Ranek Link to comment Share on other sites More sharing options...
Xenobiologist Posted November 30, 2011 Share Posted November 30, 2011 So, you mean you need something like $startvalue = 0 and $addvalue = 15 and then lines 10 and the program writes 0 15 30 45 ... 150 ? Or is it okay, to have replace the strings like I did in the array? Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
Ranek Posted November 30, 2011 Author Share Posted November 30, 2011 Yes it needs to be in a sequence so. What makes it confusing is the fact that there are more than 2 sequences on the go simultaneously. One goes, 0, 135, 270, 0, 135, 270, 0, 135, 270...... The other goes. 154, 154, 154, 308, 308, 308, 462, 462, 462..... (Increasing by 154 each time) Maybe the term "find and replace" isn't an accurate description of what i'm after. Its more of a pattern match and replace if the value doesn't match the correct pattern. So if the sequence is going up like this 154, 154, 154, 308, 308, 308, 462, 462, 462..... and then encounters a 0. Because the 0 doesn't fit the pattern it should be replaced by the next step of the pattern. 616. I'm terrible at explaining this!! haha 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