mIRC Homepage
Posted By: BigP Writing a TXT File with the $nick in it - 13/08/04 09:26 PM
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 ?
Posted By: Coolkill Re: Writing a TXT File with the $nick in it - 13/08/04 10:07 PM

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.
Posted By: BigP Re: Writing a TXT File with the $nick in it - 13/08/04 11:25 PM
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!
Posted By: Coolkill Re: Writing a TXT File with the $nick in it - 13/08/04 11:44 PM
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.
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
Posted By: greeny Re: Writing a TXT File with the $nick in it - 14/08/04 02:10 AM
I guess that's what $mkfn is for. It replaces invalid characters with underscores.
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
© mIRC Discussion Forums