erezlevi Posted January 29, 2008 Share Posted January 29, 2008 hi, I need help tried by myself don't know what to use here: vb code: For i = 1 To Len(.Buffer) If InStr(InStr(1, s, Chr(27)), s, "H") = 0 Then Exit For s = Replace(s, Mid(s, InStr(1, s, Chr(27)), InStr(InStr(1, s, Chr(27)), s, "H") - InStr(1, s, Chr(27)) + 1), " ", 1) Next AutoIT translation (well at list I tried): for $i=1 to StringLen($s1) $k=StringReplace ($s1,StringMid ($s1,1,StringRegExpReplace ( Link to comment Share on other sites More sharing options...
Squirrely1 Posted January 29, 2008 Share Posted January 29, 2008 (edited) Hi erezlevi - if all you are trying to get done with this one snippet is to manipulate some strings, just put two examples of the kind of string that is the input and of the kind that is the output, and we do the whole thing in AutoIt. You have to get out of the spirit of VB, it was written by yuppie pin-heads from the 1980s. Edited January 29, 2008 by Squirrely1 Das Häschen benutzt Radar Link to comment Share on other sites More sharing options...
erezlevi Posted January 29, 2008 Author Share Posted January 29, 2008 Hi erezlevi - if all you are trying to get done with this one snippet is to manipulate some strings, just put two examples of the kind of string that is the input and of the kind that is the output, and we do the whole thing in AutoIt. You have to get out of the spirit of VB, it was written by yuppie pin-heads from the 1980s.bump, I can't get it to do it with AutoIT. Link to comment Share on other sites More sharing options...
erezlevi Posted January 29, 2008 Author Share Posted January 29, 2008 ok, got some progress: $p1=StringInStr($m,Chr(27)) $p1 now gives me the first chr27 (ESC) in $m. now ... continue to search, hope one of u will find a way soonner. Link to comment Share on other sites More sharing options...
erezlevi Posted January 29, 2008 Author Share Posted January 29, 2008 ok, got some progress: $p1=StringInStr($m,Chr(27)) $p1 now gives me the first chr27 (ESC) in $m. now ... continue to search, hope one of u will find a way soonner. Help! I am almost there! this is the string "list bcms skill 107 [1;1H[24;0H[K7[1;1H[0;7mlist bcms skill 107 [0m8[23;0H[0;7m[" $m=string($s) $p1=StringInStr($m,Chr(27)) $p2=StringInStr($m,"H") $p3=($p2-$p1)+1 $p4=StringMid ($m,$p1,$p3) MsgBox (0,"$m before",$m) $m=StringReplace ($m,$p1," ",$p3) StringReplace ( MsgBox (0,"",$p1&$p2 & @CRLF & $p3 & @CRLF & $p4) MsgBox (0,"$m after",$m) FileOpen ("c:\erez.txt",2) FileWrite ("c:\erez.txt",$m) I need to extract everything in this line that start with Chr(27) and end with "H" like this: [1;1H or this: [23;0H. the problem is that with VB script I have the command: s = Replace(s, Mid(s, InStr(1, s, Chr(27)), InStr(InStr(1, s, Chr(27)), s, "H") - InStr(1, s, Chr(27)) + 1), " ", 1) and with AutoIT the StringReplace does not have border! it only have starting point and replacement string but it does not replace the whole string if the replacment is not equal to the total substring in the first place. how can I use StringRegExpReplace here? Link to comment Share on other sites More sharing options...
Squirrely1 Posted January 29, 2008 Share Posted January 29, 2008 (edited) ...I need to extract everything in this line that start with Chr(27) and end with "H"...There is Regular Expressions Help.I am not a brainiac that I would use StringRegExpReplace without someone holding my hand through the whole process, but if you are just trying to return strings that begin with one character and end with another, StringInStr returns the character position of a given string. I found out about this use of StringInStr here on the forums. So your strategy might look like this:1. Find the position of the first "begin" character in the string.2. Find the position of the first "end" character in the string.3. Use StringMid to get that string.4. Use StringReplace to remove the part that you have stored with StringMid5. Repeat steps 1-4 until no more are found.This strategy involves using a loop, but it runs very quickly and with a way to exit the loop, of course, I estimate it will run for about 8 milliseconds. Edited January 29, 2008 by Squirrely1 Das Häschen benutzt Radar Link to comment Share on other sites More sharing options...
erezlevi Posted January 29, 2008 Author Share Posted January 29, 2008 There is Regular Expressions Help.I am not a brainiac that I would use StringRegExpReplace without someone holding my hand through the whole process, but if you are just trying to return strings that begin with one character and end with another, StringInStr returns the character position of a given string. I found out about this use of StringInStr here on the forums. Your strategy might look like this:1. Find the position of the first "begin" character in the string.2. Find the position of the first "end" character in the string.3. Use StringMid to get that string.4. Use StringReplace to remove the part that you have stored with StringMid5. Repeat steps 1-4 until no more are found.don't you see my code above, that is exactly the issue! but you gave me an Idea now! good foryou! you know when you get stuck and you need something so simple then you ask how come I didn't saw it, you are right! I have it all in my code all the time. I just need to replace with the Stringmid! Link to comment Share on other sites More sharing options...
Squirrely1 Posted January 29, 2008 Share Posted January 29, 2008 Victory ! Das Häschen benutzt Radar 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