You can use the examples below to test the library and see how it works.
;#include tf.ahk ; remove comment if you don't include TF in your library
;*** Test script to demonstrate how to use TF library -----------------------------------------------------
;
; Notes:
; This script will create a number of text files: testfile.txt, replace.txt and where applicable testfile_copy.txt
; Variables in this testscript:
; - TestFile (used to create a file but also as variable to test the capability of TF to process files & variables
; - F (shorthand for filename Testfile.txt)
; - F2 (shorthand for filename Testfile.txt)
; - t (a global var created by TF())
;
; ! if used in combination with F or TestFile.txt it will overwrite the inputfile (e.g. testfile.txt)
;
; TF_Merge, TF_Prepend, TF_Append, currently do not support variables
; and only work with FILES.
;
; Be sure to read the introduction first to understand the basic concepts of start/end,
; the ! prefix and difference between files & variables
; Documentation : https://ahknet.autohotkey.com/~hugov/tf-lib.htm
; AHK Forum : http://www.autohotkey.com/forum/viewtopic.php?p=307344#307344 (Also for examples)
;
; Most examples below create TestFile_copy.txt so you can see what it it is
; doing if you compare it to the original TestFile.txt that is also generated
;
; create sample file
;
TestFile=
(join`r`n
01 AutoHotkey is a free, open-source utility for Windows.
02 * Automate almost anything by sending keystrokes and mouse clicks. You can write a mouse or keyboard macro by hand or use the macro recorder.
06 * Remap keys and buttons on your keyboard, joystick, and mouse.
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".
06 * Create custom data-entry forms, user interfaces, and menu bars. See GUI for details
05 * Create custom data-entry forms, user interfaces, and menu bars. See GUI for details
%A_Tab%
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.%A_Space%%A_Space%
08 * Run existing AutoIt v2 scripts and enhance them with new capabilities.
08 * Run existing AutoIt v2 scripts and enhance them with new capabilities.
06 * Remap keys and buttons on your keyboard, joystick, and mouse.
08 * Run existing AutoIt v2 scripts and enhance them with new capabilities.
08 * Run existing AutoIt v2 scripts and enhance them with new capabilities.
09 * Convert any script into an EXE file that can be run on computers that don't have AutoHotkey installed.
10 Getting started might be easier than you think. Check out the quick-start tutorial.
)
Replace=
(join`r`n
this is
the Text
from the replace.txt
file
)
FileDelete, %A_ScriptDir%\Replace.txt
FileDelete, %A_ScriptDir%\TestFile.txt
FileDelete, %A_ScriptDir%\TestFile_Copy.txt
FileAppend, %TestFile%,%A_ScriptDir%\TestFile.txt
FileAppend, %Replace%,%A_ScriptDir%\Replace.txt
F=TestFile.txt
F2=TestFile.txt
;To test an example remove the ; on the line
;*** Examples for TF_CountLines ---------------------------------------------------
;MsgBox % TF_CountLines(F) ; count lines, pass on textfile
;MsgBox % TF_CountLines("TestFile.txt") ; count lines, pass on textfile
;MsgBox % TF_CountLines(TF(F)) ; count lines, use TF(F), this will also create global var t, so not the smartest way to do it in this particular case, see example below
;MsgBox % TF_CountLines(TF("TestFile.txt")) ; count lines, use TF(F), this will also create global var t, so not the smartest way to do it in this particular case, see example below
;MsgBox % TF_CountLines(TestFile) ; count lines, pass on variable
;uncomment both lines
;TF(F) ; will create global var t
;MsgBox % TF_CountLines(t) ; count lines
;uncomment both lines
;t:=TF_CountLines(TF(F)) ; count lines, the TF() will create global var t but we assign the output of TF_Countlines to t as well
;MsgBox % t
;uncomment both lines
;TF(F, MyTFileVar) ; create global var MyTFileVar
;MsgBox % TF_CountLines(MyTFileVar) ; count lines
;*** Examples for TF_ReadLines ---------------------------------------------------
;MsgBox % TF_ReadLines(F,5) ; pass on file, read lines 5 to end of file
;MsgBox % TF_ReadLines(F,5) ; pass on file, read lines 5 to end of file
;uncomment both lines
;t:=TF_ReadLines(TF(F),5) ; pass on global var t created by TF(), read lines 5 to end of file, asign result to t
;MsgBox % t
;MsgBox % TF_ReadLines(F,1,5) ; pass on file, read lines 1 to 5
;MsgBox % TF_ReadLines(TestFile,"1-5") ; pass on variable, read lines 1 to 5
;uncomment both lines
;t:=TF_ReadLines(TF(F),"1-5") ; pass on global var t created by TF(), asign output to t, read lines 1 to 5
;MsgBox % t
;uncomment both lines
;MyVar:=TF_ReadLines(TF("testfile.txt","MyVar"),"1-5") ; create global var MyVar by TF(), read lines 1 to 5
;MsgBox % MyVar
;MsgBox % TF_ReadLines(F,"2+3") ; pass on file, start with line 2, increment 3 until end of file so 2,5,8 etc
;MsgBox % TF_ReadLines(TestFile,"2+3") ; pass on variable, start with line 2, increment 3 until end of file so 2,5,8 etc
;MsgBox % TF_ReadLines(F,"1-3,8-10") ; read lines 1 to 3 and 8 to 10
;MsgBox % TF_ReadLines(F,"1,2,5,8",3) ; read lines 1 2 5 8, ignore 3. 3 is endline value which is ignored in such cases
;MsgBox % TF_ReadLines(F,TF_FindLines(F,1,0,"keys"))
;*** Examples for TF_ReplaceInLines ------------------------------------------------
;TF_ReplaceInLines("!" . F,3,5,"key","lock") ; Pass on file, replace key with lock in lines 3 to 5
;MsgBox % TF_ReplaceInLines(TestFile,3,5,"key","lock") ; Pass on variable, replace key with lock in lines 3 to 5
;uncomment both lines
;MyVar:=TF_ReplaceInLines(TestFile,3,5,"key","lock") ; Pass on variable, replace key with lock in lines 3 to 5
;MsgBox % MyVar
;uncomment both lines
;t:=TF_ReplaceInLines(TF(F),"3-5","","key","lock") ; pass on global var t created by TF(), asign output to t, replace key with lock in lines 3 to 5
;MsgBox % t
;TF_ReplaceInLines("!" . F,"1,3,9","","key","lock") ; pass on file, overwrite input, replace key with lock in lines 1 3 and 9
;TF_ReplaceInLines(F,"1,3,9","","key","lock") ; pass on file, replace key with lock in lines 1 3 and 9
;TF_ReplaceInLines(F,"1+3","","key","lock") ; pass on file, replace key with lock in lines 1 4 7 etc until end of file
;TF_ReplaceInLines("!" . F,"1+3","","key","lock") ; pass on file, overwrite input, replace key with lock in lines 1 4 7 etc until end of file
;uncomment both lines
;FileRead, Replace, replace.txt ; Useful trick, you can use another file or multiple lines for a replacement
;TF_ReplaceInLines(F,"2","8","Remap keys",replace) ; replace "Remap keys" with contents from replace.txt
;*** Examples for TF_Replace -----------------------------------------------------
;uncomment both lines
;FileRead, Replace, replace.txt ; Useful trick, you can use another file or multiple lines for a replacement
;TF_Replace(F,"Remap keys",replace) ; replace Remap keys with contents from replace.txt
;TF_Replace(F,"key","lock") ; pass on file, replace key with lock in file
;uncomment both lines
;MyVar:=TF_Replace(TestFile,"key","lock") ; pass on variable, replace key with lock in var
;MsgBox % MyVar
;uncomment both lines
;t:=TF_Replace(TF(F),"key","lock") ; pass on variable, replace key with lock in var
;MsgBox % t
;TF_Replace(F,"`r`n"," ") ; pass on file, replace new lines with space
;MsgBox % TF_Replace(TestFile,"`r`n"," ") ; pass on variable, replace new lines with space
;*** Examples for TF_RegExReplaceInLines -----------------------------------------------------
;TF_RegExReplaceInLines(F,3,8," [a-z]{3} "," lock ") ; pass on file, replace any three letter word with lock in lines 3 to 8
;TF_RegExReplaceInLines(F,"1-3,8-10","","( [a-z]{3}) "," $1lock ") ; pass on file, replace any three letter word with wordlock in lines 1 to 2 and 8 to 10
;MsgBox % TF_RegExReplaceInLines(TF(F),"1-3,8-10","","( [a-z]{3}) "," $1lock ") ; pass on variable, replace any three letter word with wordlock in lines 1 to 2 and 8 to 10. In this case a global var t is also created so using the MsgBox here is not the best of methods, see examples above with t:=TF_... for better use
;*** Examples for TF_RegExReplace ------------------------------------------------------------
;TF_RegExReplace(F,"im)^(.*)$","[$1]") ; pass on file, wrap all lines in []
;TF_RegExReplace("!" . F,"im)^(.*)$","[$1]") ; pass on file, wrap all lines in [], overwrite it
;uncomment both lines
;t:=TF_RegExReplace(TF(F),"im)^(.*)$","[$1]") ; pass on variable created by TF(), wrap all lines in []
;MsgBox % t
;TF_RegExReplace(F,"im)^(.*)\r?\n(.*)","[$1|$2]") ; pass on file, join two consective lines with seperator | and wrap lines in []
;*** Examples for TF_RemoveLines -------------------------------------------------------------
;TF_RemoveLines("!" . F,5) ; pass on file, remove from line 5 to end of file
;TF_RemoveLines("!" . F,5) ; pass on file, remove from line 5 to end of file. Note the ! to indicate TestFile.txt will be the output file
;uncomment both lines
;t:=TF_RemoveLines(TF(F),5) ; pass on variable created by TF(), remove from line 5 to end of var
;MsgBox % t
;MsgBox %TF_RemoveLines(TestFile,"2+3") ; pass on var, delete line 2, increment 3 until end of var so 2,5,8,11 etc
;TF_RemoveLines(F,"5,8") ; remove lines 5 and 8
;TF_RemoveLines(F,"5-8") ; remove lines 5 to 8
;TF_RemoveLines(F,"3-5,7-9",10) ; remove lines 3 to 5 and 7 to 9, ignore end value 10
;TF_RemoveLines(F,-5) ; pass on file, remove the last 10 lines
;*** Examples for TF_RemoveBlankLines ---------------------------------------------------------
;TF_RemoveBlankLines(F) ; remove blanklines in entire file
;TF_RemoveBlankLines("!" . F) ; remove blanklines in entire file
;MsgBox % TF_RemoveBlankLines(TF(F)) ; remove blanklines in entire file
;TF_RemoveBlankLines(F,7) ; remove blanklines starting from line 7
;TF_RemoveBlankLines(F,1,6) ; remove blanklines from lines 1 to 6
;*** Examples for TF_RemoveDuplicateLines -----------------------------------------------------
;TF_RemoveDuplicateLines("!" . F) ; remove duplicate lines in file
;MsgBox % TF_RemoveDuplicateLines(TestFile) ; remove duplicate lines in entire var
;TF_RemoveDuplicateLines(F,"","",1,false) ; remove only Consecutive duplicate lines
;MsgBox % TF_RemoveDuplicateLines(TestFile,"","",1,false) ; remove only Consecutive duplicate lines
;*** Examples for TF_InsertLine ---------------------------------------------------------------
;TF_InsertLine("!" . F,5,5,"---") ; insert --- in line 5
;MsgBox % TF_InsertLine(TestFile,5,5,"---") ; insert --- in line 5
;uncomment both lines
;FileRead, Replace, replace.txt
;TF_InsertLine(F,5,5,replace) ; useful trick, you can insert replace.txt in line 5 or the contents of another var
;MsgBox % TF_InsertLine(TF(F),5,5,replace) ; useful trick, you can insert replace.txt in line 5 or the contents of another var
;TF_InsertLine(F,"2,4,9",5,"---") ; insert --- in lines 2 4 and 9. 5 is endline will be ignored
;TF_InsertLine(F,"1+3","","---") ; insert --- in lines 1 4 7 etc until end of file
;TF_InsertLine(F,4,8,"---") ; insert --- between all lines 4 to 8
;*** Examples for TF_ReplaceLine ---------------------------------------------------------------
;TF_ReplaceLine(F,3,3,"---") ; replace line 3 with ---
;TF_ReplaceLine(F,"1,5,9","","---") ; replace lines 1 5 and 9 with ---
;TF_ReplaceLine(F,"1+3","","---") ; replace lines 1 4 7 etc with --- until end of file
;TF_ReplaceLine(F,"1+3",8,"---") ; replace lines 1 4 7. 8 is end line so no more lines are processed after that
;*** Examples for TF_InsertPrefix ---------------------------------------------------------------
;TF_InsertPrefix(F,"","", "Hello ") ; Prefix Hello in all lines
;MsgBox % TF_InsertPrefix(TestFile,"","", "Hello ") ; Prefix Hello in all lines
;TF_InsertPrefix(F,5,8, "Hello ") ; Prefix Hello in lines 5 to 8
;TF_InsertPrefix(F,5,"", "Hello ") ; Prefix Hello starting from line 5 to end of file
;TF_InsertPrefix(F,"5,8","", "Hello ") ; Prefix Hello in line 5 and 8
;TF_InsertPrefix(F,"2-4,6-9","", "Hello ") ; Prefix Hello in lines 2 to 4 and 6 to 9
;*** Examples for TF_InsertSuffix ---------------------------------------------------------------
;TF_InsertSuffix(F,"2-4,6-9","", " Hello") ; Suffix Hello in lines 2 to 4 and 6 to 9
;MsgBox % TF_InsertSuffix(TF(F),"2-4,6-9","", " Hello") ; Suffix Hello in lines 2 to 4 and 6 to 9
;TF_InsertSuffix(F,"2+5","", " Hello") ; Suffix Hello in lines 2 7 etc
;*** Examples for TF_TrimLeft -------------------------------------------------------------------
; A Tab is one character so lines with tabs might have unexpected results
;TF_TrimLeft(F,"","",25) ; Trim Left 25 Characters all lines
;MsgBox % TF_TrimLeft(TF(F),"","",25) ; Trim Left 25 Characters all lines
;TF_TrimLeft(F,4,7,3) ; Trim Left 3 Characters in lines 4 to 7
;TF_TrimLeft(F,"4,6,8","",5) ; Trim Left 5 Characters in lines 4 6 and 8
;*** Examples for TF_TrimRight ------------------------------------------------------------------
; A Tab is one character so lines with tabs might have unexpected results
;TF_TrimRight(F,"4,6,8","",45) ; Trim Right 45 Characters in lines 4 6 and 8
;MsgBox % TF_TrimRight(TestFile,"4,6,8","",45) ; Trim Right 45 Characters in lines 4 6 and 8
;*** Examples for TF_ConCat ---------------------------------------------------------------------
;TF_ConCat(FirstTextFile, SecondTextFile, OutputFile, Blanks = 0, FirstPadMargin = 0, SecondPadMargin = 0)
;FirstTextFile and SecondTextFile can be both a file, a var, or one a file and the other a var
;TF_ConCat(F,F2,"cat2.txt",10, 5, 8)
;MsgBox % TF_ConCat(F,F2,"",10, 5, 8) ; special case: if you want to return a variable, keep outputfile empty
;MsgBox % TF_ConCat("TestFile.txt",TF(F),"",10, 5, 8) ; special case: if you want to return a variable, keep outputfile empty
;*** Examples for TF_LineNumber ----------------------------------------------------------------
;TF_LineNumber(F) ; Add linenumbers, no padding / leading
;TF_LineNumber(F,1) ; Add linenumbers, padd with zeros: 01 02 v 1 2
;TF_LineNumber(F,1,15) ; Add linenumbers, padd with zeros, restart after 15
;MsgBox % TF_LineNumber(TF(F),1,15) ; Add linenumbers, padd with zeros, restart after 15
;TF_LineNumber(F,0,15) ; Add linenumbers, no padding, restart after 15 (linenumbers are aligned left)
;TF_LineNumber(F,1,15,A_Space) ; Add linenumbers, padding with spaces, linenumbers are aligned right
;*** Examples for TF_ColGet ---------------------------------------------------------------------
;Note: A TAB character is 1 character so for files with TABS the column might not be where you expect it to be
;TF_ColGet(F,"","",2,13) ; get columns 2 to 13 from all lines, so it removes all other columns from the file or variabla
;MsgBox % TF_ColGet(TF(F),"","",2,13) ; get columns 2 to 13 from all lines
;MsgBox % TF_ColGet(TestFile,"2+2","",2,13) ; get columns 2 to 13 from lines 2 4 6 8 etc
;*** Examples for TF_ColPut ---------------------------------------------------------------------
;Note: A TAB character is 1 character so for files with TABS the column might not be where you expect it to be
;TF_ColPut(F,"","",5, "|", 0) ; insert | in column 5 of all lines including empty lines, so that means | will be at column 1
;MsgBox % TF_ColPut(TF(F),"","",5, "|", 1) ; insert | in column 5 of all lines skipping empty lines, so that means | will NOT be at column 1 or at any position in the empty line
;MsgBox % TF_ColPut(TestFile,"2+2","",5, "|", 1) ; insert | in column 5 of lines 2 4 6 8 etc skipping empty lines
;*** Examples for TF_ColCut ---------------------------------------------------------------------
;Note: A TAB character is 1 character so for files with TABS the column might not be where you expect it to be
;TF_ColCut(F, "2+2", "", 4, 38) ; remove columns 4 to 38 in lines 2 4 6 8 etc
;MsgBox % TF_ColCut(TF(F), 4, 10, 10, 25) ; remove columns 10 to 25 in lines 4 to 10
;*** Examples for TF_Tail ---------------------------------------------------------------------
; TF_Tail(Text, Lines = 1, RemoveTrailing = 0, ReturnEmpty = 1)
;MsgBox % TF_Tail(F, 3) ; get the last three lines
;MsgBox % TF_Tail(F, -2) ; get second to last line, negative values only return one line
;MsgBox % TF_Tail(F, 5, 0, 0) ; return the last five lines, with trailing new line and excluding empty lines
;*** Examples for TF_AlignLeft ----------------------------------------------------------------
;TF_AlignLeft(F,"","",90, 1) ; AlignLeft all lines, keep trailing white space
;MsgBox % TF_AlignLeft(TF(F),"","",90, 1) ; AlignLeft all lines, keep trailing white space
;MsgBox % TF_AlignLeft(TestFile,"","",90, 0) ; AlignLeft all lines, remove trailing white space, note the effect on empty lines
;TF_AlignLeft(F, "4", "", 90) ; AlignLeft, starting from line 4
;TF_AlignLeft(F, "3,5", "", 90) ; AlignLeft, lines 3 and 5
;*** Examples for TF_AlignCenter ----------------------------------------------------------------
;TF_AlignCenter(F,"","",150, 1) ; AlignCenter, all lines skip emtpy lines, do not fill with spaces
;MsgBox % TF_AlignCenter(TF(F),5,"", 150) ; AlignCenter, starting from line 5
;TF_AlignCenter(F,5,8,150) ; AlignCenter, lines 5 to 8
;TF_AlignCenter(F,"1+2",9,150) ; AlignCenter 1 3 5 7 and 9, stop at 9
;*** Examples for TF_AlignRight ----------------------------------------------------------------
;TF_AlignRight(F,"","", 190, 0) ; AlignRight, all lines, do not skip emtpy lines fill them with spaces
;MsgBox % TF_AlignRight(TestFile,4,8,150) ; AlignRight, lines 4 to 8
;TF_AlignRight(F,"4,6","",150) ; AlignRight, lines 4 and 6
;TF_AlignRight(F,"6-9","",150) ; AlignRight, lines 6 to 9
;*** Examples for TF_WhiteSpace ----------------------------------------------------------------
;TF_WhiteSpace(F) ; remove leading and trailing whitespace
;MsgBox % TF_WhiteSpace(TestFile) ; remove leading and trailing whitespace
;TF_WhiteSpace(F, 0, 1) ; keep leading and remove trailing whitespace
;MsgBox % TF_WhiteSpace(TF(F), 1, 1, "5-10") ; remove leading and trailing whitespace in lines 5 to 10
;*** Examples for TF_ReverseLines ----------------------------------------------------------------
;uncomment both lines to illustrate the effect more clearly
;TF_LineNumber("!" . F, 1) ; Add linenumbers, padd with zeros: 01 02 v 1 2
;TF_ReverseLines(F,2,9) ; Now reverse lines so we can see it
;TF_ReverseLines("!" . F,2,9)
;*** Examples for TF_Find ----------------------------------------------------------------
;TF_Find(Text, StartLine = 1, EndLine = 0, SearchText = "", ReturnFirst = 1, ReturnText = 0)
;MsgBox % TF_Find(F,"","", "button") ; Find first line with the word button. You can store this in a var for further processing (startline or endline value)
;MsgBox % TF_Find(TF(F),"","", "button") ; Find first line with the word button. You can store this in a var for further processing (startline or endline value)
;MsgBox % TF_Find(TF(F),"","", "button", 0) ; Find all lines with the word button, return line numbers
;MsgBox % TF_Find(TF(F),"","", "button", 0, 1) ; Find all lines with the word button, return text
;MsgBox % TF_Find(TF(F),"","", "button", 0, 2) ; Find all lines with the word button, return lines & text
;*** Examples for TF_Wrap ----------------------------------------------------------------
;TF_Wrap(F,60) ; wrap at col 60
;TF_Wrap(F,30, 0, 10, 15) ; wrap at col 30, do not break words, process lines 10 to 15
;MsgBox % TF_Wrap(TestFile,30, 0, 10, 15) ; wrap at col 30, do not break words, process lines 10 to 15
;*** Examples for TF_Substract ----------------------------------------------------------------
;uncomment these lines for TF_Substract example
;FileDelete, File1.txt
;FileDelete, File2.txt
;FileAppend, 1`n2`n5`n9`n, file1.txt
;FileAppend, 1`n21`n3`n4`n5`n6`n7`n8`n9, file2.txt
;TF_Substract("File1.txt", "File2.txt") ; remove 1 2 5 9 from file2, note 21 is NOT removed
;TF_Substract("File1.txt", "!File2.txt", 1) ; remove 1 2 5 9 from file2, note 21 is removed because 1 and 2 are in file1 due to partial match
;t:=TF_Substract("File1.txt", TF("File2.txt")) ; remove 1 2 5 9 from file2, note 21 is NOT. If file2 is variable then return output to var as well, note you can use TF() here to pass on a file as a variable
;MsgBox % t
;*** Examples for TF_MakeFile ----------------------------------------------------------------
;No need to think about how to return a var not just create file
;TF_MakeFile("empty.txt", 40, 80) ; create empty text, 40 lines, 80 columns filled with spaces
;MsgBox % TF_MakeFile("", 40, 80, "x") ; create empty text variable, 40 lines, 80 columns filled with spaces. To return as variable, keep Text empty
;*** Examples for TF_RangeReplace ----------------------------------------------------------------
;Uncomment the line below for the TF_RangeReplace examples as well
;Range=[insert this`ntext for the`nrange replace Text`ntest function]
;TF_RangeReplace(F, "Create hotkeys for keyboard", "into an EXE file", Range) ; replace from start to end
;If you want to delete a "range" simply leave Replace empty
;MsgBox % TF_RangeReplace(TF(F), "Create ", " keyboard", Range, False, 1, 1) ; replace from start to end, keep start & end IN output file
;TF_RangeReplace(F, "Create", "keyboard", Range, False, 1, 1) ; replace from start to end, keep start & end IN output file
;TF_RangeReplace(F, "Create hotkeys for keyboard", "into an EXE file", Range , False, 1) ; keep start text
;TF_RangeReplace(F, "Create hotkeys for keyboard", "easier than you think", Range , False, 0, 1) ; keep end text
;TF_RangeReplace(F, "", "into an EXE file", Range) ; replace from beginning of file
;TF_RangeReplace(F, "", "", Range) ; basically same as replacing the file with a new one
;TF_RangeReplace(F, "For example", "", Range)
;*** Examples for TF_Sort ----------------------------------------------------------------
;TF_Sort(F,"",5,10) ; sort text file lines 5 to 10
;TF_Sort("!" . F) ; sort text file
;t:=TF_Sort(TF(F))
;MsgBox % "sorted:" t
;TF_Sort(F, "", 4, 8) ; sort lines 4 to 8 of text file keep rest as it is
;MsgBox % TF_Sort(TestFile, "P16") ; sort on 16th column, see AHK Sort options
;*** Examples for Tab2Spaces, Spaces2Tabs
;TF_Spaces2Tab(F,1) ; convert all spaces to tabs
;MsgBox % TF_Spaces2Tab(TF(F),1) ; convert all spaces to tabs
;TF_Tab2Spaces(F)
;TF_Tab2Spaces("!" . F)
;*** Examples for TF_Save ----------------------------------------------------------------
;TF_Save(TF_LineNumber(TestFile), "MyTest.txt") ; add linenumbers to variable and save as MyTest.txt
;TF_Save(TF_LineNumber(TF(F)), "MyTest.txt") ; read file into variable t, add linenumber and save as MyTest.txt. Note it creates global var t with the contents of the original file, it is a bit of a silly example
;*** Examples for TF_Merge/Append/Prepend-------------------------------------------------
;functions below do NOT support variables
;uncomment both lines
;FileList .= F "`r`n" F2 ; create filelist, see also DOC
;TF_Merge(FileList) ; merge files in FileList, output file merged.txt, create merged_copy.txt if it exists
;TF_Merge(FileList, "`n", "!merged2.txt") ; merge files in FileList, output file merged2.txt overwrite if it exists
;TF_Append(F,F2) ; Appends File1 to File2
;TF_Prepend(F,F2) ; Prepends File1 to File2
;*** Examples for TF_SplitFileByLines ----------------------------------------------------------------
;TF_SplitFileByLines(TextFile, SplitAt, Prefix = "file", Extension = "txt", InFile = 1)
;TF_SplitFileByLines(F, 2, "part", "zec", 1) ; split source file every 2 lines, include 2nd line INFILE
;Uncomment both lines
;TF_LineNumber("!" . F)
;TF_SplitFileByLines(F, "3,8,16", "part", "zec", 1) ; split source at lines 3, 8 and 16 until the end of file
;Uncomment both lines
;TF_LineNumber("!" . F)
;TF_SplitFileByLines(F, "3-5", "part", "zec", 1) ; split source every lines 3 and 5 lines, alternate until the end
;uncomment both lines to illlustrate use of variables and returned arrays
;TF_SplitFileByText(TestFile, "keyboard", "part", "zec", 1)
;MsgBox % "Array size: " . Part0 . "`n1st array element: " Part1
;*** Examples for TF_SplitFileByText ----------------------------------------------------------------
;TF_SplitFileByText(F, "button", "part", "zec", 1) ; split source file on every line with the word button, include that line INFILE
;TF_SplitFileByText(F, " [a-z]{11} ", "part", "zec", 1) ; split source file on every line with a word of 11 characters, include that line INFILE