mIRC Home    About    Download    Register    News    Help

Print Thread
Writing to a txt file then checking it #107446 10/01/05 09:24 AM
Joined: Jul 2004
Posts: 40
D
dmmrs Offline OP
Ameglian cow
OP Offline
Ameglian cow
D
Joined: Jul 2004
Posts: 40
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


i script, therefore i am smirk
theres logic in there somewhere...
Re: Writing to a txt file then checking it #107447 10/01/05 05:55 PM
Joined: Aug 2004
Posts: 16
I
inti Offline
Pikka bird
Offline
Pikka bird
I
Joined: Aug 2004
Posts: 16
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
}
}
}


Regards,
KathY
Re: Writing to a txt file then checking it #107448 10/01/05 11:03 PM
Joined: Sep 2003
Posts: 4,230
D
DaveC Offline
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
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)

Re: Writing to a txt file then checking it #107449 11/01/05 07:43 AM
Joined: Jul 2004
Posts: 40
D
dmmrs Offline OP
Ameglian cow
OP Offline
Ameglian cow
D
Joined: Jul 2004
Posts: 40
Thankyou smile

Works fine now.


i script, therefore i am smirk
theres logic in there somewhere...