Scinner Posted December 28, 2008 Posted December 28, 2008 Hi! Can someone point me in the right direction? What Im trying to do: I got a .doc with a number in it 0-5000 and I want to read the number and depending on what number it is I'd like to do various actions after that. (IF statements) What to do? How do i get the value in the .doc to be a "$var" (Is that even the right way to do it?) And can I ignore "spaces" for example "_236__" (where _ = space) and only get the number? I know you all like to see some code before you help out but I dont even know where to start. Would very much appreciate all help/tips you can give me!
Valuater Posted December 28, 2008 Posted December 28, 2008 Like this... #include <String.au3> Local $File = @ScriptDir & "\Name.txt" Local $Before = "buy " Local $After = " apples" $Read = FileRead($File) ; This is for demo only - remove later $Read = "Please go to the store and buy 32 apples for later" $Final = _StringBetween($Read, $Before, $After) MsgBox(0x0, "Found", $Final[0]) ; returns an array 8)
Scinner Posted December 28, 2008 Author Posted December 28, 2008 (edited) Like this... #include <String.au3> Local $File = @ScriptDir & "\Name.txt" Local $Before = "buy " Local $After = " apples" $Read = FileRead($File) ; This is for demo only - remove later $Read = "Please go to the store and buy 32 apples for later" $Final = _StringBetween($Read, $Before, $After) MsgBox(0x0, "Found", $Final[0]) ; returns an array 8) Thank you! I will experiment with that for a while and see if I can make it work. The thing is that my doc only have one number in it (sometimes spaces)and no other words or numbers so I dont know what to do with $Before and $After. Is there another way? Im sure it would be easy if I were a master of AutoIt which Im not as you surely know by now. Edited December 28, 2008 by Scinner
Scinner Posted December 28, 2008 Author Posted December 28, 2008 (edited) can you post the file?8)The .txt file?It looks like this: 234A space then a random number between 0-5000.But sometimes its just a number and no spaces.I just want to use that number to do some IF statements. If the number is for example 4321 then do one thing and if its 221 do another. My english is pretty poor so Im sorry if Im not able to make myself understood. Edited December 28, 2008 by Scinner
Valuater Posted December 28, 2008 Posted December 28, 2008 so... Local $File = @ScriptDir & "\Name.txt" $Read = FileRead($File) $Final = StringStripWS($Read, 8) MsgBox(0x0, "Found", $Final) 8)
Scinner Posted December 28, 2008 Author Posted December 28, 2008 StringStripWS($string, 8)Thank you!That was one of the things I needed!Now all I want to know is how I get the number to be a "$var"? or a "$string" so I can give it som statements.
Scinner Posted December 28, 2008 Author Posted December 28, 2008 so... Local $File = @ScriptDir & "\Name.txt" $Read = FileRead($File) $Final = StringStripWS($Read, 8) MsgBox(0x0, "Found", $Final) 8) Thank you again! I think I got it now!
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