Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

[Solved] Search Text and if Found call a function



  • Please log in to reply
4 replies to this topic
Pinkfloydd
  • Members
  • 75 posts
  • Last active: May 31 2019 02:43 AM
  • Joined: 01 Jul 2012
Hi

Im trying to do a script for searching text inside a txt file, and I if found that text --> then call a function

I have the following txt file with this

Helicopter

Apple

Banana

Microphone

Ak47

Calculator

Light

Television

Pillow

Then I wanna search the word Calculator, and if i found it, call Function1 for example

Function1()
{
FileAppend, , Calculator.txt
Msgbox, the word Calculator was found it
}

Thanks!

  • Guests
  • Last active:
  • Joined: --
FileRead + InInString + Gosub
and what you have there is a label not a function ;-)
If you want to manipulate text files look at

AHK Library with a number of functions to "manipulate" text, both files such as *.txt, *.ahk, *.html, *.css etc AND Strings (or variables). For example you can delete specific lines, replace words or specific lines, number lines, remove or insert columns of text, etc.
Source: https://ahknet.autoh...ugov/tf-lib.htm



  • Guests
  • Last active:
  • Joined: --
IfInString of course, not InInString ;-)

Pinkfloydd
  • Members
  • 75 posts
  • Last active: May 31 2019 02:43 AM
  • Joined: 01 Jul 2012
✓  Best Answer
Thank u very much!

is there ok?

Fileread, FinderOfCalculator, File.txt

IfInString, FinderOfCalculator, Calculator
	Function1()

Function1()
{
FileAppend, , Calculator.txt
Msgbox, the word Calculator was found it
}	
	


  • Guests
  • Last active:
  • Joined: --
Yep, looks ok to me...