mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Dec 2002
Posts: 99
M
MDA Offline OP
Babel fish
OP Offline
Babel fish
M
Joined: Dec 2002
Posts: 99
Greetings,

I need some help on a command which permits me to scan a text file for a username, if not found then add it.

if (!$read(C:\1Report/IMusers.txt,w,* $+ %msnimaddy)) { write C:\1Report/IMusers.txt %msnimaddy }

Seems like that should work, but it doesn't, that code still writes the variable containing the username %msnimaddy even if it already exists in the IMusers.txt file.

Your suggestions and help on that code snippt would be greatly appreciated.

Thanks,
MDA

Joined: Mar 2004
Posts: 457
D
Fjord artisan
Offline
Fjord artisan
D
Joined: Mar 2004
Posts: 457
Try $read(C:\1Report/IMusers.txt,s,%msnimaddy)

Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
How is this file organised? Just a nickname per line, nothing else?

Btw you've typoed in your code if (!$read(C:\1Report/IMusers.txt,... should be \

if (!$read(C:\1Report\IMusers.txt,w,%msnimaddy)) { write C:\1Report/IMusers.txt %msnimaddy }

Oh yeah, you could also check /write with -s flag if you're gonna write anyway.

Greets


Gone.
Joined: Nov 2003
Posts: 2,327
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Nov 2003
Posts: 2,327
I don't know if it's filesystem dependant but it doesn't seem to matter here.

Code:
//echo -a $read(c:\program files/mIRC\readme.txt,1)


New username: hixxy
Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
Oh yeah, I wasn't thinking clearly, I should get some sleep. *wink*

Seems to work even when using / rather than \

Greets

Joined: Dec 2002
Posts: 99
M
MDA Offline OP
Babel fish
OP Offline
Babel fish
M
Joined: Dec 2002
Posts: 99
Greetings and thank you for responding,

The code listed works, the problem was found in acouple spaces that were buffered into the front of the %msnimaddy variable. Although the output sequential text file didn't show those buffered spaces in front of the corresponding %msnimaddy, each time the !read statement looked for a match, it didn't find it, because the file being written was ignoring those buffered spaces in the output of writing the %msnimaddy variable to that file.

By removing the hidden buffer character spaces in front of what I was trying to save, namely the pure %msnimaddy, I was able to isolate that variable, save and search for that variable correctly.

Example:

%msnimaddy [hidden buffer spaces x2]Testinjay@yahoo.com

Wouldn't find thru that !read routine a search for

@msnimaddy Testinjay@yahoo.com

And the !read-write statement would repeatedly write in that %msnimaddy as a new addition.

Although pulling up IMusers.txt would reveal:
Testinjay@yahoo.com
Testinjay@yahoo.com

Which for all purposes appear in the resulting IMusers.txt file to be identical.

Thanks for your feedback and comments previously,
MDA


Link Copied to Clipboard