Sign in to follow this  
Followers 0
am632

find word in text file and display msgbox help

10 posts in this topic

Hi, I have no idea where to start with this as i have never done it before, i have tried searching but cant seem to find exactly what i want.

basically i want to search a text file, and if a specified word is found in the text file then it will display a message box, is it is not found then it will do something else... i would like something like..

wordtofind = 0

search (document.txt, wordtofind)

if wordtofind is found then

word to find = 1

if wordtofind = 0 then

msgbox blabla

else

msgbox mehmeh

do u get what i mean or am i going about this the wrong way? (i realise the above isnt actual code obviously, but this is how i would picture it to be layed out)

thanks

Share this post


Link to post
Share on other sites



Hi, i have tried searching but cant seem to find exactly what i want.

I find that difficult to believe.

Go to the helpfile and read about and test the example of FileRead()

The variable you use with fileread will be your string.

All Done?

Now go back to the helpfile and read about and test the example of StringInStr()

Once you understand the return values of that function, you should be done, thats assuming you know what If..Else..EndIf conditions are.

If not, make your way back to the merry old helpfile and perform a search.


AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

I find that difficult to believe.

Go to the helpfile and read about and test the example of FileRead()

The variable you use with fileread will be your string.

All Done?

Now go back to the helpfile and read about and test the example of StringInStr()

Once you understand the return values of that function, you should be done, thats assuming you know what If..Else..EndIf conditions are.

If not, make your way back to the merry old helpfile and perform a search.

you may also find the stringsplit function helpful in picking out the individual words. use the delimiters to mark where you separate the text file lines.

A script like what you're trying is not that hard. Put some effort into a code and post when you're stuck. I think you'd get more assistance that way. The members here seem to be of the thought "it's your code, I'm not going to write it for you, but will help you make it better".

With that in mind, go forth and build you a text file scrapper script :)

Share this post


Link to post
Share on other sites

hi, thanks for the replies, and i did try searching but for terms such as 'search text file' and 'find word in file' like i say i havn't done this before so im not exactly just guna know to search for fileread and stringinstr am i? thanks for ur help anyway

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

I understand you am632. I've been there too..not knowing how to search for what I wanted. Some people never been there and some other just forgot they've been. People are always harsh with people who doesn't seem to search and post "easy" question like these. Let me know if you get your script working or post it here if you're stuck I'll help you the best I can.

Edited by Djordhan

Share this post


Link to post
Share on other sites

I understand you am632. I've been there too..not knowing how to search for what I wanted. Some people never been there and some other just forgot they've been. People are always harsh with people who doesn't seem to search and post "easy" question like these. Let me know if you get your script working or post it here if you're stuck I'll help you the best I can.

thanks m8, i appreciate it

Share this post


Link to post
Share on other sites

I understand you am632. I've been there too..not knowing how to search for what I wanted. Some people never been there and some other just forgot they've been. People are always harsh with people who doesn't seem to search and post "easy" question like these. Let me know if you get your script working or post it here if you're stuck I'll help you the best I can.

Harsh? really, I dont think so.

Expecting someone who has been a member of the forum for almost 2 years, to know how to navigate a helpfile is not unreasonable, and far from harsh, plus my reply was constuctive and helpful.


AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Harsh was not the good word I agree and I'm sorry about that. I guess I based my comment on am's reply, which may not have initially been on the correct tone.

I was just wondering why people always expect others to know how to search a help file (and I'm not talking about this particular post, but generally). I'm the first one to think that we would evolve way faster by sharing directly our knowledge on the forum instead on letting newcomers rely on the help files, going through the learning curve again and again, that's why there are schools out there and not just libraries.

By the way, I don't want to start a debate here so I'll just present my excuse to John, my comment was not justified.

Edited by Djordhan

Share this post


Link to post
Share on other sites

A reply here to say 'look at this function and that function' is surely the equivalent output to an 'ideal' search of the help files and forum. So looking at the functions, trying something out and only then coming back for more advanced assistance doesn't seem unreasonable.

I think there are 2 types of reasonable requests here -

1) the description of the required process and [the help search having failed] asking what functions might be of use to fulfil the process

and

2)having created code but got stuck with a problem, and asking for further guidance.

There may be more.

William

Share this post


Link to post
Share on other sites

Yeah the replies in this post are good. They were pointing at correct references.

I guess there should be a "Help for Noobs" forum around then.

Because some people may never even have touched a programming/scripting language before and may ask question like "How can I sort my photos ?" and not "How can I sort an array?".

Anyway, how's your script goin am632 ? :)

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