mIRC Homepage
Posted By: dmmrs Writing to a txt file then checking it - 10/01/05 09:24 AM
Ok, I'm stuck. I'm prolly missing something very simple, but I can't see it. Here's what I want to do:

We have a channel where we code digital video clips, and I'm making a script where people can see the status of things being coded. For some reason it won't let me add anything being coded.

I want someome to type !coding thisclip (or whatever) and for it to write to a text file called NICKcoderz.txt; thisclip at $time on $date.

Then when they are done coding, and are uploading it, to be able to type !upping thisclip and for mirc to read the txt file, if they havent already typed !coding thisclip, then to return an error, if they have already typed that, and it's in the txt file, then for it to be changed in the NICKcoderz.txt file to; thisclip UPPING at $time on $date.

Phew.

Anyway, here's the code ive got so far:

on *:TEXT:!coding*:#dmmrs: { if ($2 == $null) {
msg #dmmrs Sorry, $nick but you have to enter something that you are coding smile
}
else { if ($read($nick $+ coderz.txt,w, *$2*) == $exists) {
msg #dmmrs Sorry $nick, you told me you were coding this at: $read($nick $+ coderz.txt,w, *$2*)
msg #dmmrs Why not try setting the status of that code first smile
}
else {
msg #dmmrs Thankyou, $nick $+ , you have set your status to coding - $2- - at $time on $date $+ .
write $nick $+ coderz.txt $2- at $time on $date
}
}
}
on *:TEXT:!upping*:#dmmrs: { if ($2 == $null) {
msg #dmmrs Sorry, $nick but you have to enter something that you have been coding smile
}
else { if ($read($nick $+ coderz.txt,w, * $+ $2 $+ *) !== $exists) {
msg #dmmrs Sorry, $nick but it doesn't appear that you are coding $2- $+ , therefore you can't up it smile
}
else {
msg #dmmrs Thanks $nick you have set your status of $2- to upping at $time on $date $+ .
write -s" $+ $2 $+ " $nick $+ coderz.txt Upping $2- at $time on $date
}
}
}


Any help would be appreciated, as always smile
Posted By: inti Re: Writing to a txt file then checking it - 10/01/05 05:55 PM
Hi..

I have changed something, the important part is marked green.
I think, you can't use 'else' twice in this way, you need to use 'elseif'.
And I'm almost sure that $exist doesn't exist in the way you want to use it. You have to use $true or you just leave out the second parameter.

(Sorry for my english..)


on *:TEXT:!coding*:#dmmrs: {
if (!$2) {
msg #dmmrs Sorry, $nick but you have to enter something that you are coding
}
elseif ($read($nick $+ coderz.txt,w,$+(*,$2,*))) {
msg #dmmrs Sorry $nick, you told me you were coding this at: $read($nick $+ coderz.txt,w,$+(*,$2,*))
msg #dmmrs Why not try setting the status of that code first
}
else {
msg #dmmrs Thankyou, $nick $+ , you have set your status to coding - $2- - at $time on $date $+ .
write $nick $+ coderz.txt $2- at $time on $date
}
}
}
on *:TEXT:!upping*:#dmmrs: {
if ($2) {
msg #dmmrs Sorry, $nick but you have to enter something that you have been coding
}
elseif (!$read($nick $+ coderz.txt,w, * $+ $2 $+ *)) {
msg #dmmrs Sorry, $nick but it doesn't appear that you are coding $2- $+ , therefore you can't up it
}
else {
msg #dmmrs Thanks $nick you have set your status of $2- to upping at $time on $date $+ .
write -s" $+ $2 $+ " $nick $+ coderz.txt Upping $2- at $time on $date
}
}
}
Posted By: DaveC Re: Writing to a txt file then checking it - 10/01/05 11:03 PM
Quote:

else { if ($read($nick $+ coderz.txt,w, *$2*) == $exists) {
else { if ($read($nick $+ coderz.txt,w, * $+ $2 $+ *) !== $exists) {


There formatted wrong,
becuase $exists(dir/file) is $true/$false if the dir/file exists you want $null, also the second lines !== (while it might work actually) should be !=

As shown in INIT's script above you can just use
else { if ($read($nick $+ coderz.txt,w, *$2*)) {
else { if (!$read($nick $+ coderz.txt,w, * $+ $2 $+ *)) {

You can nest your IF/ELSE { IF/ELSE } like that, but only is really needed if your doing similar code on every ELSE event before or after the inclosed IF/ELSE
(if that made any sence lol)
Posted By: dmmrs Re: Writing to a txt file then checking it - 11/01/05 07:43 AM
Thankyou smile

Works fine now.
© mIRC Discussion Forums