Sign in to follow this  
Followers 0
Scinner

Point me in the right direction, please!

9 posts in this topic

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!

Share this post


Link to post
Share on other sites



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)


NEWHeader1.png

Share this post


Link to post
Share on other sites

#3 ·  Posted (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 by Scinner

Share this post


Link to post
Share on other sites

can you post the file?

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

can you post the file?

8)

The .txt file?

It looks like this:

234

A 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 by Scinner

Share this post


Link to post
Share on other sites

StringStripWS($string, 8)

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0