mIRC Home    About    Download    Register    News    Help

Print Thread
Writing a TXT File with the $nick in it #94086 13/08/04 09:26 PM
Joined: Aug 2004
Posts: 10
B
BigP Offline OP
Pikka bird
OP Offline
Pikka bird
B
Joined: Aug 2004
Posts: 10
I want to use an on text command to write text to a file.

The file must have the users nick in the filename for my read scripts benefit.

<bob124> I like footy.

on *:TEXT:*footy*:#: /write c:\temp\footy\$nick.txt $nick $1-

I just get a file called "$nick.txt" rather than bob124.txt

Anyone point me in the right direction please ?

Re: Writing a TXT File with the $nick in it #94087 13/08/04 10:07 PM
Joined: Dec 2002
Posts: 788
C
Coolkill Offline
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 788

write $+(c:\temp\footy\,$nick,.txt) $nick $1-

Or,

write c:\temp\footy\ $+ $nick $+ .txt $nick $1-


They are both the exact same, just differnet method of using $+, the $+ COMBINES things together, in this case an identifier and text.

Eamonn.

Re: Writing a TXT File with the $nick in it #94088 13/08/04 11:25 PM
Joined: Aug 2004
Posts: 10
B
BigP Offline OP
Pikka bird
OP Offline
Pikka bird
B
Joined: Aug 2004
Posts: 10
thx for the quick reply Eamonn works a treat laugh

Can you tell me if theres a quick way to test script commands rather than writing the script unloading and loading ?

e.g. /scripttry $read(c:\temp\footy\bob.txt,w,*fred*) | if (readn == 0) echo bob.txt doesnt exist!

Re: Writing a TXT File with the $nick in it #94089 13/08/04 11:44 PM
Joined: Dec 2002
Posts: 788
C
Coolkill Offline
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 788
Editing your scripts via the mIRC scripting editor (alt+r) updates them instantly although some might not trigger until you restart mirc for obvious reasons like, 'On Start'.

Quote:

scripttry $read(c:\temp\footy\bob.txt,w,*fred*) | if (readn == 0) echo bob.txt doesnt exist!

If your trying to check if the file exists.

alias scripttry {
if (!$isfile("C:\temp\footy\bob.txt")) { echo bob.txt doesnt exist! }
}

Syntax; /scripttry

And to make it "dynamic".

alias scripttry {
if (!$1) { echo -a - Syntax: /scripttry [nickname] | return }
if (!$isfile($+(",C:\temp\footy\,$1-,.txt"))) {
echo -a - $1- $+ .txt doesnt exist!
}
else { echo -a - $1- $+ .txt exists! }
}

Syntax; /scripttry nickname

Eamonn.

Re: Writing a TXT File with the $nick in it #94090 14/08/04 02:03 AM
Joined: Feb 2004
Posts: 2,019
FiberOPtics Offline
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
Hi,

you are going to run into troubles at some point, when your script tries to make a file that contains illegal characters. Some characters which can be contained in a nickname, like | for example, cant be used in a filename.

You're probably better of using a hash table.

Things to check out: /hadd, $hget, /hsave, /hload etc. /help hash tables

Greets


Gone.
Re: Writing a TXT File with the $nick in it #94091 14/08/04 02:10 AM
Joined: Dec 2002
Posts: 230
G
greeny Offline
Fjord artisan
Offline
Fjord artisan
G
Joined: Dec 2002
Posts: 230
I guess that's what $mkfn is for. It replaces invalid characters with underscores.

Re: Writing a TXT File with the $nick in it #94092 14/08/04 02:14 AM
Joined: Feb 2004
Posts: 2,019
FiberOPtics Offline
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
I know there are work arounds for it, but there was no mention/sign of it in his script, so it seemed like a good thing to point out, cuz he probably didn't think of it.

Greets


Gone.