AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

TF_Removelines Fails

 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
txquestor



Joined: 22 Aug 2009
Posts: 294

PostPosted: Wed Dec 02, 2009 7:59 pm    Post subject: TF_Removelines Fails Reply with quote

Hugov or anyone else who can help with the TF() Library.
Thanks for any help you can provide.

Why is the "Clipboard" the only example that works?

Do I have a Syntax Error in my various examples? I don't get any Error Messages

What am I doing wrong? As you can see I tried many different forms
and they all FAILED, except Clipboard

The results are either BLANK Msgbox's or the TEXT in Quotes in the function call

UNCOMMENT any single example below to see the results.

I'm using TF.ahk Version 3

Code:

; TF_RemoveLinesFile

; Why is the "Clipboard" the only example that works?
; Do I have a Syntax Error in my various example? I don't get any Error Messages
; What am I doing wrong? As you can see I tried many different forms and they all FAILED, except Clipboard

; Comment or UnComment each example to see my test results

; From TF_RemovelinesClipboard - http://www.autohotkey.com/forum/topic50519.html

; Date: 12/1/2009 10:11:08 PM

; Removes selected lines from clipboard

;#include tf.ahk     ; Uncomment if TF.ahk is not in the Autohotkey LIB folder

; FileAppend, %clipboard%,%A_ScriptDir%\TFTestFile.txt  ; uncomment to create the TFTestFile.txt

;clipboard =    ; Clear clipboard

/*                        ; uncomment to store data to clipboard
clipboard = ;save example data into clipboard
(
Regular Expressions (RegEx) for AutoHotkey - Internet Explorer provided by Dell;http://www.autohotkey.com/forum/topic12827.html
Ask for Help - Internet Explorer provided by Dell;http://www.autohotkey.com/forum/forum-1.html&sid=e36d0a14e79ead25cda36a384d6c99b9
Using ++ in function call (aka short code camp course) - Internet Explorer provided by Dell;http://www.autohotkey.com/forum/viewtopic.php?p=84194#84194
Put here requests of problems with regular expressions - Internet Explorer provided by Dell;http://www.autohotkey.com/forum/viewtopic.php?t=13545&postdays=0&postorder=asc&highlight=regex&start=240
Search - Internet Explorer provided by Dell;http://www.autohotkey.com/forum/search.php?search_id=1832159812&start=150
Match negation of Regular Expression - Internet Explorer provided by Dell;http://www.autohotkey.com/forum/topic18626.html&highlight=regexmatch+stringsplit
[TIPS] A collection/library of regular expressions - Internet Explorer provided by Dell;http://www.autohotkey.com/forum/viewtopic.php?t=13544
Create basic browser that can autofill forms? - Internet Explorer provided by Dell;http://www.autohotkey.com/forum/viewtopic.php?p=313104#313104

)
;*/          ; uncomment to store data to clipboard

; Examples from TF() Tutorials
; http://www.autohotkey.com/forum/viewtopic.php?p=280363#280363
; http://www.autohotkey.net/~hugov/tf-lib.htm#TF   
;-----------------------------------------
; t:=TF_ReadLines(TF("TestFile.txt"),5)    ; example from TF Tutorial
; MyVar:=TF_ReadLines(TF("TestFile.txt","MyVar"),5)     ; example from TF Tutorial
; 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
;t:=TF_RemoveLines(TF(F),5)    ; pass on variable created by TF(), remove from line 5 to end of var
;-------------------------------------------------------

;F=%A_SCRIPTDIR%\TFTestFile.txt  ; FAILED
;F=TFTestFile.txt ; FAILED

; TF removes the 3rd line of list of URL's

; Uncomment one example line below to test TF_RemoveLines

;Clipboard:=TF_RemoveLines(clipboard, 3, 3) ; will delete line 3  from clipboard PASSED
;NewFile:=TF_RemoveLines(clipboard, 3, 3) ; PASSED
;NewFile:=TF_RemoveLines(TF("C:\AHK Verified Scripts\TFTestFile.txt", "NewFile"), 3, 3) ; FAILED   
;NewFile:=TF_RemoveLines(TF("TFTestFile.txt", "NewFile"), 3, 3) ; FAILED
;NewFile:=TF_RemoveLines(TF(A_ScriptDir "\TFTestFile.txt", "NewFile"), 3, 3) ; FAILED   
;NewFile:=TF_RemoveLines(TF(F, "NewFile"), 3, 3) ; FAILED   
;NewFile:=TF_RemoveLines(F, 3, 3) ; FAILED
;NewFile:=TF_RemoveLines("!" . F,3,3)  ; FAILED
;Clipboard:=TF_RemoveLines("TFTestFile.txt", 3, 3) ; FAILED
;Clipboard:=TF_RemoveLines("C:\AHK Verified Scripts\TFTestFile.txt", 3, 3)  ; FAILED
;t:=TF_RemoveLines(TF("TestFile.txt"),3,3)     ; FAILED
;Clipboard:=TF_RemoveLines(TF("TestFile.txt"),3,3)     ; FAILED

; Uncomment one Msgbox line below to test TF_RemoveLines

;MsgBox % t 
;MsgBox % NewFile   
;MsgBox % Clipboard 
;sTooltip(clipboard, 8)
;sTooltip(NewFile, 8) 


_________________

"Man's quest for knowledge is an expanding series whose limit is infinity"
Back to top
View user's profile Send private message
SoLong&Thx4AllTheFish



Joined: 27 May 2007
Posts: 4999

PostPosted: Wed Dec 02, 2009 10:05 pm    Post subject: Reply with quote

You had me a little scared there for a few seconds Wink

I think the problem lies with the fact you create a file from the clipboard variable before you create the clipboard, so move the fileappend below the clipboard= part and it will work.

Later you call a file that isn't there (testfile.txt and not TFtestfile.txt)

And there are a few where you got the syntax/concept wrong:
you either pass on a FILE or a VARIABLE to a TF function, the result is
Input : File -> Output : File (or File_copy)
Input : Variable -> Output : Variable

All of the below examples work, some you have indicated to FAIL, but infact they work as advertised.

I added linenumbers to the clipboard and delete tftestfile.txt each time you run the test script. Uncomment two lines a time, the TF + the MsgBox to illustrate the output for vars. Look at the scriptdir to see file_copy or the overwritten result for TFs with files...

Code:
clipboard =    ; Clear clipboard
clipboard = ;save example data into clipboard
(
1 Regular Expressions (RegEx) for AutoHotkey - Internet Explorer provided by Dell;http://www.autohotkey.com/forum/topic12827.html
2 Ask for Help - Internet Explorer provided by Dell;http://www.autohotkey.com/forum/forum-1.html&sid=e36d0a14e79ead25cda36a384d6c99b9
3 Using ++ in function call (aka short code camp course) - Internet Explorer provided by Dell;http://www.autohotkey.com/forum/viewtopic.php?p=84194#84194
4 Put here requests of problems with regular expressions - Internet Explorer provided by Dell;http://www.autohotkey.com/forum/viewtopic.php?t=13545&postdays=0&postorder=asc&highlight=regex&start=240
5 Search - Internet Explorer provided by Dell;http://www.autohotkey.com/forum/search.php?search_id=1832159812&start=150
6 Match negation of Regular Expression - Internet Explorer provided by Dell;http://www.autohotkey.com/forum/topic18626.html&highlight=regexmatch+stringsplit
7 [TIPS] A collection/library of regular expressions - Internet Explorer provided by Dell;http://www.autohotkey.com/forum/viewtopic.php?t=13544
8 Create basic browser that can autofill forms? - Internet Explorer provided by Dell;http://www.autohotkey.com/forum/viewtopic.php?p=313104#313104
)
;*/          ; uncomment to store data to clipboard
FileDelete, %A_ScriptDir%\TFTestFile.txt
FileAppend, %clipboard%,%A_ScriptDir%\TFTestFile.txt  ; uncomment to create the TFTestFile.txt

F=%A_SCRIPTDIR%\TFTestFile.txt  ; FAILED
;F=TFTestFile.txt ; FAILED

; Uncomment one example line below to test TF_RemoveLines

; OK:
;Clipboard:=TF_RemoveLines(clipboard, 3, 3) ; will delete line 3  from clipboard PASSED
;MsgBox % Clipboard

; OK
;NewFile:=TF_RemoveLines(clipboard, 3, 3)
;MsgBox % NewFile

; OK
;NewFile:=TF_RemoveLines(TF("TFTestFile.txt", "NewFile"), 3, 3)
;MsgBox % NewFile

; OK
;NewFile:=TF_RemoveLines(TF(A_ScriptDir . "\TFTestFile.txt", "NewFile"), 3, 3)
;MsgBox % NewFile

; OK
;NewFile:=TF_RemoveLines(TF(F, "NewFile"), 3, 3)
;MsgBox % NewFile

;---------------------------- below you got your syntax/concept wrong:
; you either pass on a FILE or a VARIABLE to a TF function, the result is
; Input : File -> Output : File (or File_copy)
; Input : Variable -> Output : Variable

; Failed, and that is correct because you don't pass a variable here but a FILE
; so TFTestFile_copy.txt is created not a variable
;NewFile:=TF_RemoveLines(F, 3, 3) ; "FAILED" with variable because it is a FILE, file_copy is created
;MsgBox % NewFile ; will return one

;NewFile:=TF_RemoveLines("!" . F,3,3)  ; "FAILED" not true, it will overwrite FILE

;Clipboard:=TF_RemoveLines("TFTestFile.txt", 3, 3) ; "FAILED" if file is passed on to TF you can't have it return a var, use TF() if you need to

; OK
;t:=TF_RemoveLines(TF("TFTestFile.txt"),3,3)     ; FAILED (you passed on non existant file, TFTestFile.txt is OK here
;MsgBox % t

_________________
AHK Wiki FAQ
TF : Text files & strings lib, TF Forum
Back to top
View user's profile Send private message
txquestor



Joined: 22 Aug 2009
Posts: 294

PostPosted: Wed Dec 02, 2009 10:59 pm    Post subject: Reply with quote

Duh??? Embarassed Thanks Hugo,

I guess I was too close to it to see the DUH's .... Embarassed Embarassed Embarassed

Quote:

think the problem lies with the fact you create a file from the clipboard variable before you create the clipboard, so move the fileappend below the clipboard= part and it will work.


Actually, the Fileappend is a typo. I added it in after the fact
for anyone wanting to test the text file, so they wouldn't have to create
it manually. I already had the file created.

Just a lot of STUPID mistakes. Embarassed Rolling Eyes
The wrong text file name errors were the 1st ones tested and obvisously they failed.

Then I compounded my errors by the wrong syntax next with the FILE VARS. Rolling Eyes Rolling Eyes Embarassed

Sorry I wasted your time. I should have picked up on those. Embarassed

What makes it doubley frustrating is that I have used many of the other TF functions without my Brain Fart. Crying or Very sad Embarassed

Thanks, again Hugov Laughing

As I said before in other posts, these are Fantastic functions and extremely useful. Laughing
_________________

"Man's quest for knowledge is an expanding series whose limit is infinity"
Back to top
View user's profile Send private message
SoLong&Thx4AllTheFish



Joined: 27 May 2007
Posts: 4999

PostPosted: Wed Dec 02, 2009 11:04 pm    Post subject: Reply with quote

No worries, glad to be of help and see someone using it Smile

I will rethink/write (parts of) the documentation as I can see it might still be a little bit confusing. But working on some other things so might be a while Wink
_________________
AHK Wiki FAQ
TF : Text files & strings lib, TF Forum
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group