[library] TF: Text files & Variables (strings) v3.7

Post your working scripts, libraries and tools
Guest

Re: [library] TF: Text files & Variables (strings) v3.7

07 Feb 2018, 05:19

You need to learn the basics of AutoHotkey - you can't just use A_LoopReadLine like that, you need to have it "outside" of the quotes otherwise it won't be "translated" in the contents. As A_LoopReadLine may also contain new line characters you may need to trim

Code: Select all

TF_RegExReplace("!" A_LoopFileFullPath,"im)\b" trim(A_LoopReadLine,"`r`n") "\b","lock") ; use trim to remove trailing new line chars which may interfere
If it is a word list you are processing you can do it all in one go but you need to study and learn RegEx (hint|list|of|words|like|this) - see regex docs linked to above.
User avatar
Tomer
Posts: 254
Joined: 21 Aug 2016, 05:11

Re: [library] TF: Text files & Variables (strings) v3.7

07 Feb 2018, 05:53

Thanks Guest :bravo:

I know i should have keep the variables outside the quotes from my first exmaple :lol: :lol: :lol:
(although i posted my sample code into the quotes just so you see my sample code).

anyway, what i needed is Trim :)

ps. why you using new lines (,"`r`n") ?
tested it without it and works as well
hasantr
Posts: 88
Joined: 05 Apr 2016, 14:18

Re: [library] TF: Text files & Variables (strings) v3.7

26 Jul 2018, 15:15

I have not been able to use it. Can someone explain it in detail? Could you give me a working example? I really need this library. I'm new to Autohotkey. But I'm so bored with that.

How do we include the library in our work? I did, but things did not work and things went wrong. "C: \ Users \ hasan \ Desktop \ Deneme.ahk (19): ==> Call to nonexistent function.
     Specifically: TF_Find (FilePath, "", "", "i) \ Q" SearchText "\ E", 0, 1)

Thanks.
Guest

Re: [library] TF: Text files & Variables (strings) v3.7

27 Jul 2018, 02:33

Its pretty straight forward.

You can either use #include or use the LIB folder:

1. You can either use #include path-to-your-copy-of\tf.ahk * in your script

* if you have your script and tf.ahk in the same folder #include tf.ahk will work of course

2. Place a copy of tf.ahk in one of the following folders on your computer:

%A_ScriptDir%\Lib\ ; Local library - requires [v1.0.90+].
%A_MyDocuments%\AutoHotkey\Lib\ ; User library.
directory-of-the-currently-running-AutoHotkey.exe\Lib\

Source & More info https://autohotkey.com/docs/Functions.htm#include

Working sample script

Code: Select all

FileDelete, tftestfile123.txt
FileAppend, 
(
01 AutoHotkey is a free, open-source utility for Windows. With it, you can:
02 - Automate almost anything by sending keystrokes and mouse clicks.
03 - Create hotkeys for keyboard, joystick, and mouse. Virtually any key, button, or combination can become a hotkey.
04 - Expand abbreviations as you type them. For example, typing "btw" can automatically produce "by the way".
05 - Create custom data-entry forms, user interfaces, and menu bars. See GUI for details.
06 - Remap keys and buttons on your keyboard, joystick, and mouse.
07 - Respond to signals from hand-held remote controls via the WinLIRC client script.
08 - Convert any script into an EXE file that can be run on computers that don't have AutoHotkey installed.
), tftestfile123.txt


; TF_Find(FilePath, "", "", "i)\Q" SearchText "\E")
MsgBox % TF_Find("tftestfile123.txt", "", "", "abbreviations") ; remember it is case sensitive by default
MsgBox % TF_Find("tftestfile123.txt", "", "", "and",0) ; return a CSV list of all lines with 'and'
MsgBox % TF_Find("tftestfile123.txt", "5", "", "AutoHotkey") ; start at line 5 so it skips the first result e.g. line 1 here

myvar:="autohotkey" ; lowercase

MsgBox % TF_Find("tftestfile123.txt", "", "", "i)\Q" myvar "\E",0,1) ; return the text of all found lines 

Return to “Scripts and Functions”

Who is online

Users browsing this forum: ChaF and 29 guests