TF_GetData() bug
stealzy opened this issue · comments
TF_GetData(byref OW, byref Text, byref FileName) {
If (text = 0) ; v3.6
{
MsgBox, 48, TF Lib Error, % "Read Error:``npossible reason: perhaps you used ! vs ""!"" ?"
Some newbie try to use this lib, but failed.
His text contain only one line: "000000".
I dont know that you mean here, possibly you mean text = ""
?
You don't use TF_GetData() in a script on its own. TF_GetData is called by all other TF functions to test if a variable or a file has been passed on to a TF_... function.
That particular line/error message is shown if a user makes a syntax error:
TF_...(! "file.txt",...)
vs TF_...("!file.txt",...)
. The ! before a filename is used to write back the result of the TF function to the source file instead of a copy (file_copy.txt). I noticed that some users tried to use it like ! "file.txt" instead of "!file.txt" and I show the MsgBox as a reminder.
I can read/work with a file with one line containing "000000" without any problems.
What function are you using and how are you calling it, if you post it I might spot a syntax error (below each TF command there is a short example in the readme.md
TF_GetData() is called first in many user function.
msg =
(
000000
)
MsgBox % TF_TrimLeft(msg, 1, 1, 3)
— Error msgbox.
msg =
(
C:\users\desktop.ini
)
MsgBox % TF_TrimLeft(msg, 1, 1, 3)
— I get 1 here, because I have this file on disk.
msg =
(
!C:\
)
MsgBox % TF_TrimLeft(msg, 1, 1, 3)
— Error msgbox.
IMHO, from such type of function I expected behavior like SubStr().
No hidden parameters, no undefinied try read file, no error msgbox.
A good tool should be simple.
Of course, I understand that it's too late change it here.
Sorry but only the last one gives an error message, the first two work fine here.
Your second example should have created a file C:\users\desktop_copy.ini, it should be there.
The 1 indicates it hasn't been able to make a backup - There is little point in using MsgBox with files as, well it writes back the result to a file and does NOT return the changed content to a variable which you can display in a MsgBox.
The last one tries to read a file "C:" which of course doesn't exist (there is no such file) so it gives an error message saying it can't read it. You can pass on a variable as a filename which is what you are doing here in the second and third example.
So as far as I can see: no bugs and it works as intended.
Edit: v3.7 (April 16, 2017)
- #4
- https://autohotkey.com/boards/viewtopic.php?p=142166#p142166 in case user pass on zeros "0000" - will error out when passing on one 0