AutoHotkey Community

It is currently May 27th, 2012, 12:21 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: TF_Removelines Fails
PostPosted: December 2nd, 2009, 8:59 pm 
Offline

Joined: August 22nd, 2009, 11:23 pm
Posts: 294
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) 


_________________
Image
"Man's quest for knowledge is an expanding series whose limit is infinity"


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 2nd, 2009, 11:05 pm 
Offline

Joined: May 27th, 2007, 9:41 am
Posts: 4999
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 FAQ
TF : Text files & strings lib, TF Forum


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 2nd, 2009, 11:59 pm 
Offline

Joined: August 22nd, 2009, 11:23 pm
Posts: 294
Duh??? :oops: Thanks Hugo,

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

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. :oops: :roll:
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. :roll: :roll: :oops:

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

What makes it doubley frustrating is that I have used many of the other TF functions without my Brain Fart. :cry: :oops:

Thanks, again Hugov :lol:

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

_________________
Image
"Man's quest for knowledge is an expanding series whose limit is infinity"


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 3rd, 2009, 12:04 am 
Offline

Joined: May 27th, 2007, 9:41 am
Posts: 4999
No worries, glad to be of help and see someone using it :-)

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 FAQ
TF : Text files & strings lib, TF Forum


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Leef_me, Pulover, rjgatito, XstatyK, Yahoo [Bot] and 22 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group