mIRC Home    About    Download    Register    News    Help

Print Thread
#4834 04/01/03 12:08 PM
Joined: Jan 2003
Posts: 44
L
Ameglian cow
OP Offline
Ameglian cow
L
Joined: Jan 2003
Posts: 44
Is there anything out in software that will automatically tell me where in my scripts that syntax errors exist?

Besides, posting to the boards?

thanks.

roger

#4835 04/01/03 12:36 PM
Joined: Dec 2002
Posts: 1,321
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Dec 2002
Posts: 1,321
mIRC itself is usually very good about complaining loudly and stomping off in a huff if you get syntax wrong. Logic problems are another matter entirely, and those are the tougher ones to track down.

To my uncertain knowledge, I have never heard of any third-party software that checked mIRC script syntax.


DALnet: #HelpDesk and #m[color:#FF0000]IR[color:#EEEE00]C
#4836 04/01/03 01:20 PM
Joined: Jan 2003
Posts: 44
L
Ameglian cow
OP Offline
Ameglian cow
L
Joined: Jan 2003
Posts: 44
ok, then.

this script at first working, now has failed, and I don't know why?


-----------------
;
; state of ___ !system
;
ON *:TEXT:!status*:#mychan:{
msg $nick please use /msg chromer !status
close -m $nick
}
ON *:TEXT:!server*:#mychan:{
msg $nick please use /msg chromer !server
close -m $nick
}
ON *:TEXT:!event*:#mychan:{
msg $nick please use /msg chromer !event
close -m $nick
}
;
ON *:TEXT:!status*:?:{
msg $nick ---------------
msg $nick $fulldate
play -tstatus $nick c:\windows\desktop\mychan.txt 500
msg $nick ---------------
close -m $nick
}
ON *:TEXT:!server*:?:{
msg $nick ---------------
msg $nick $fulldate
play -tserver $nick c:\windows\desktop\mychan.txt 500
msg $nick ---------------
close -m $nick
}
ON *:TEXT:!event*:?:{
msg $nick ---------------
msg $nick $fulldate
play -tevent $nick c:\windows\desktop\mychan.txt 500
msg $nick ---------------
close -m $nick
}
;
;
; !seen system
;
ON 1:JOIN:#mychan:{
if ($read(c:\windows\desktop\mychan.dat,s,$nick)==$null) {
write c:\windows\desktop\mychan.dat $nick $&
joined at: $left($time,5) $+ $time(tt) $left($gmt(zzz),3) $+ : $+ $&
$right($gmt(zzz),6)
}
else {
write -s c:\windows\desktop\mychan.dat $nick $&
joined at: $left($time,5) $+ $time(tt) $left($gmt(zzz),3) $+ : $+ $&
$right($gmt(zzz),6)
}
}
ON *:PART:#eve-test:{
if ($read(c:\windows\desktop\mychan.dat,s,$nick)==$null) {
write c:\windows\desktop\eve-test.dat $nick $&
left at: $left($time,5) $+ $&
$time(tt) $left($gmt(zzz),3) $+ : $+ $&
$right($gmt(zzz),6)
}
else {
write -s $+ $nick c:\windows\desktop\mychan.dat $nick $&
left at: $left($time,5) $+ $&
$time(tt) $left($gmt(zzz),3) $+ : $+ $&
$right($gmt(zzz),6)
}
}
ON *:QUIT:{
if ($read(c:\windows\desktop\mychan.dat,s,$nick)==$null) {
write c:\windows\desktop\eve-test.dat $nick $&
quit at: $left($time,5) $+ $&
$time(tt) $left($gmt(zzz),3) $+ : $+ $&
$right($gmt(zzz),6)
}
else {
write -s $+ $nick c:\windows\desktop\mychan.dat $nick $&
quit at: $left($time,5) $+ $&
$time(tt) $left($gmt(zzz),3) $+ : $+ $&
$right($gmt(zzz),6)
}
}
ON *:NICK:{
if ($read(c:\windows\desktop\mychan.dat,s,$nick)==$null) {
write c:\windows\desktop\mychan.dat $nick $&
changed name to $newnick at: $left($time,5) $+ $&
$time(tt) $left($gmt(zzz),3) $+ : $+ $&
$right($gmt(zzz),6)
}
else {
write -s $+ $nick c:\windows\desktop\mychan.dat $nick $&
changed name to $newnick at: $left($time,5) $+ $&
$time(tt) $left($gmt(zzz),3) $+ : $+ $&
$right($gmt(zzz),6)
}
}
ON 1:INPUT:*:{
if ($1 == "!seen") {
if ( $2 == $null ) {
echo Please specify a nick
halt
}

if ($read(c:\windows\desktop\mychan.dat,s,$2)!=$null) {
echo [seen-serve] $read(c:\windows\desktop\mychan.dat,s,$2)
}
else {
echo I haven't seen $2
}
}
}
ON *:TEXT:!seen*:?:{
if ( $2 == $null ) {
msg $nick Please specify a nick
msg $nick usage /msg chromer !seen nick
halt
}

if ($read(c:\windows\desktop\mychan.dat,s,$2)!=$null) {
msg $nick [seen-serve] $read(c:\windows\desktop\mychan.dat,s,$2)
}
else {
msg $nick I haven't seen $2
}
close -m $nick
}
------------------------------
if nothing appears wrong with it, could it be that mirc created too many files?

ie, I noticed for every part, join, name change, that it created a file for each nick.

even if it's not that, what is the method I should use to make sure it wipes those temp files out?

any help or optimizations greatly appreciated.

btw, I never touched mirc before and it took me 3 days to write this script, from looking at other scripts, studying the help etc.

this script worked 2 days ago and now has stopped cold.
other scripts work however.

#4837 04/01/03 03:20 PM
Joined: Dec 2002
Posts: 1,321
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Dec 2002
Posts: 1,321
* Hammer gets out his red marker and goes to work.
Code:
;
; state of ___ !system
;
ON *:TEXT:!status*:#mychan:{
  msg $nick please use /msg chromer !status
  [color:red];  Why are you closing $nick's query window if the msg you got was in #mychan?[/color]
  close -m $nick
}
ON *:TEXT:!server*:#mychan:{
  msg $nick please use /msg chromer !server
  close -m $nick
}
ON *:TEXT:!event*:#mychan:{
  msg $nick please use /msg chromer !event
  close -m $nick
}
;
ON *:TEXT:!status*:?:{
  msg $nick ---------------
  msg $nick $fulldate
  [color:red];  play will take however long it will take[/color]
  play -tstatus $nick c:\windows\desktop\mychan.txt 500
  [color:red];  The following message will not display in the right place
  ;  put it as the last entry in that .txt file in that section[/color]
  msg $nick ---------------
  [color:red]; The close -m will also happen too soon since your /play is still continuing.[/color]
  close -m $nick
}
ON *:TEXT:!server*:?:{
  msg $nick ---------------
  msg $nick $fulldate
  play -tserver $nick c:\windows\desktop\mychan.txt 500
  msg $nick ---------------
  close -m $nick
}
ON *:TEXT:!event*:?:{
  msg $nick ---------------
  msg $nick $fulldate
  play -tevent $nick c:\windows\desktop\mychan.txt 500
  msg $nick ---------------
  close -m $nick
}
;
;
; !seen system
;
ON 1:JOIN:#mychan:{
  [color:red];  You must maintain spaces around [color:green]==[/color][/color]
  if ($read(c:\windows\desktop\mychan.dat,s,$nick)[color:red] == $null[/color]) {
    write c:\windows\desktop\mychan.dat $nick $&
    joined at: $left($time,5) $+ $time(tt) $left($gmt(zzz),3) $+ : $+ $&
    $right($gmt(zzz),6)
  }
  else {
    write -s c:\windows\desktop\mychan.dat $nick $&
    joined at: $left($time,5) $+ $time(tt) $left($gmt(zzz),3) $+ : $+ $&
    $right($gmt(zzz),6)
  }
}
ON *:PART:#eve-test:{
  [color:red];  I will rewrite this one slightly, using $iif, to get rid of the
  ;  if condition. You can decide if you wish to change the others
  ;  or use this style instead.[/color]
  write [color:red]$iif($read(c:\windows\desktop\mychan.dat,s,$nick),$+(-s,$nick))[/color] $&
    c:\windows\desktop\eve-test.dat $nick left at: $&
    [color:red]$left($time,hh:nntt) $+($left($gmt(zzz),3),:,$right($gmt(zzz),6))[/color]
}
ON *:QUIT:{
  if ($read(c:\windows\desktop\mychan.dat,s,$nick)[color:red] == $null[/color]) {
    write c:\windows\desktop\eve-test.dat $nick $&
    quit at: $left($time,5) $+ $&
    $time(tt) $left($gmt(zzz),3) $+ : $+ $&
    $right($gmt(zzz),6)
  }
  else {
    write -s $+ $nick c:\windows\desktop\mychan.dat $nick $&
    quit at: $left($time,5) $+ $&
    $time(tt) $left($gmt(zzz),3) $+ : $+ $&
    $right($gmt(zzz),6)
  }
}
ON *:NICK:{
  if ($read(c:\windows\desktop\mychan.dat,s,$nick)[color:red] == $null[/color]) {
    write c:\windows\desktop\mychan.dat $nick $&
    changed name to $newnick at: $left($time,5) $+ $&
    $time(tt) $left($gmt(zzz),3) $+ : $+ $&
    $right($gmt(zzz),6)
  }
  else {
    write -s $+ $nick c:\windows\desktop\mychan.dat $nick $&
    changed name to $newnick at: $left($time,5) $+ $&
    $time(tt) $left($gmt(zzz),3) $+ : $+ $&
    $right($gmt(zzz),6)
  }
}
ON 1:INPUT:*:{
  [color:red];  No quotes[/color]
  if ($1 == [color:red]!seen[/color]) {
    [color:red];  if ($2 == $null) can be restated if (!$2)[/color]
    if ($2 == $null) {
      [color:red];  Get used to specifying a target with your echo's. For this particular case, it will not matter, but if you ever try
      ;  to echo out a line that begins with a number, you will get unexpected results. Get into the habit early on.[/color]
      echo [color:red]-a[/color] Please specify a nick
      halt
    }
    [color:red];  If this $read() returns anything at all, it found a match (which will be stored in $ifmatch here)[/color]
    if [color:red]($read(c:\windows\desktop\mychan.dat,s,$2))[/color] echo [color:red]-a[/color] [seen-serve] [color:red]$ifmatch[/color]
    else echo [color:red]-a[/color] I haven't seen $2
  }
}
ON *:TEXT:!seen*:?:{
  if ($2 == $null) {
    msg $nick Please specify a nick
    msg $nick usage /msg chromer !seen nick
    halt
  }
  if [color:red]($read(c:\windows\desktop\mychan.dat,s,$2))[/color] msg $nick [seen-serve] [color:red]$ifmatch[/color]
  else msg $nick I haven't seen $2
  close -m $nick
}

Note: Changes, notes and considerations are in red. Compare what you have with what I have marked or changed.


DALnet: #HelpDesk and #m[color:#FF0000]IR[color:#EEEE00]C
#4838 04/01/03 08:40 PM
Joined: Jan 2003
Posts: 44
L
Ameglian cow
OP Offline
Ameglian cow
L
Joined: Jan 2003
Posts: 44
Ok, I took all the advice and optimized it, it's much smaller now and faster too. weee.

I feel I'm getting better at reading and understanding this mirc script now.

much thanks to hammer.

here is the optimized code.
Code:
; state !system

ON *:TEXT:!status*:#mychan:{
  msg $nick please use /msg chromer !status
}
ON *:TEXT:!server*:#mychan:{
  msg $nick please use /msg chromer !server
}
ON *:TEXT:!event*:#mychan:{
  msg $nick please use /msg chromer !event
}

ON *:TEXT:!status*:?:{
  ;%mychan_state is defined in my variables section
  play -tstatus $nick %mychan_state
  ;closes the window on my side, doesn't close the window on their side.
  close -m $nick
}
ON *:TEXT:!server*:?:{
  play -tserver $nick %mychan_state
  close -m $nick
}
ON *:TEXT:!event*:?:{
  play -tevent $nick %mychan_state
  close -m $nick
}


; !seen system
; for some reason the following 4 events
; create temp files using the nick of person
; causing the event
; this can become quite a lot of files
; in a large irc chat room
ON 1:JOIN:#mychan:{
  ;%mychan_users is defined in my variables_section
  write $iif($read(%mychan_users,s,$nick),$+(-s,nick)) $&
      $nick joined at: $left($time,hh:nntt) $left($gmt(zzz),3),:,$&
      $right($gmt(zzz),6)
  if($isfile($nick)) remove $nick
}
ON *:PART:#mychan:{
  write $iif($read(%mychan_users,s,$nick),$+(-s,nick)) $&
      $nick left at: $left($time,hh:nntt) $left($gmt(zzz),3),:,$&
      $right($gmt(zzz),6)
  if($isfile($nick)) remove $nick
}
ON *:QUIT:{
  write $iif($read(%mychan_users,s,$nick),$+(-s,nick)) $&
      $nick quit at: $left($time,hh:nntt) $left($gmt(zzz),3),:,$&
      $right($gmt(zzz),6)
  if($isfile($nick)) remove $nick
}
ON *:NICK:{
  write $iif($read(%mychan_users,s,$nick),$+(-s,nick)) $&
      $nick changed name at: $left($time,hh:nntt) $left($gmt(zzz),3),:,$&
      $right($gmt(zzz),6)
  if($isfile($nick)) remove $nick
}

ON *:TEXT:!seen*:?:{
  if (!$2) {
    msg $nick Please specify a nick
    msg $nick usage /msg chromer !seen nick
    halt
  }

  if ($read(%mychan_users,s,$2)) msg $nick [seen-serve] $ifmatch
  else msg $nick I haven't seen $2

  close -m $nick
}
ON 1:INPUT:*:{
  if ($1 == !seen) {
    if (!$2) {
      echo -a Please specify a nick
      halt
    }

    if ($read(%mychan_users,s,$2)) echo [seen-serve] $ifmatch
    else echo I haven't seen $2
  }
}

; many thanks to Hammer of #mirc on dalnet for the great help
; and mirc knowledge matrix


and in the variables.ini I have

Code:
%mychan_state=c:\windows\desktop\blah_state
%mychan_users=c:\windows\desktop\blah_users

#4839 05/01/03 03:11 AM
Joined: Dec 2002
Posts: 1,321
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Dec 2002
Posts: 1,321
Code:
;  state !system
  
[color:red];  Since you have only a single command,  you don't really need to put
;  those message commands on separate lines. Also, since it's a single
;  command, you don't need to use the group separators { and } either.[/color]
  
ON *:TEXT:!status*:#mychan: [color:red].[/color]msg $nick please use /msg chromer !status
ON *:TEXT:!server*:#mychan: [color:red].[/color]msg $nick please use /msg chromer !server
ON *:TEXT:!event*:#mychan:  [color:red].[/color]msg $nick please use /msg chromer !event
  
; !seen system
; %mychan_users is defined in my variables_section
 
ON 1:JOIN:#mychan:{
  write $iif($read(%mychan_users,s,$nick),$+(-s,nick)) [color:red]%mychan_users[/color] $&
  $nick joined at: $left($time,hh:nntt) [color:red]$+([/color]$left($gmt(zzz),3),:,$right($gmt(zzz),6)[color:red])[/color]
}
ON *:PART:#mychan:{
  write $iif($read(%mychan_users,s,$nick),$+(-s,nick)) [color:red]%mychan_users[/color] $&
  $nick left at: $left($time,hh:nntt) [color:red]$+([/color]$left($gmt(zzz),3),:,$right($gmt(zzz),6)[color:red])[/color]
}
ON *:QUIT:{
  write $iif($read(%mychan_users,s,$nick),$+(-s,nick)) [color:red]%mychan_users[/color] $&
  $nick quit at: $left($time,hh:nntt) [color:red]$+([/color]$left($gmt(zzz),3),:,$right($gmt(zzz),6)[color:red])[/color]
}
ON *:NICK:{
  write $iif($read(%mychan_users,s,$nick),$+(-s,nick)) [color:red]%mychan_users[/color] $&
  $nick changed name at: $left($time,hh:nntt) [color:red]$+([/color]$left($gmt(zzz),3),:,$right($gmt(zzz),6)[color:red])[/color]
}


DALnet: #HelpDesk and #m[color:#FF0000]IR[color:#EEEE00]C
#4840 05/01/03 04:58 PM
Joined: Jan 2003
Posts: 3,012
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2003
Posts: 3,012
Hammer I have nothin against the use of the braces, but as a programmer I don't see any reason to critique him. Most structures with script, programs, etc enforce the use of braces for even the most simple execution. Getting in the happit of the braces is a bad one. When you get in the habbit, in my opinion, there is less chance for error, and the code just looks that much more comprehendable..

-KingTomato
http://www.kingtomato.com
AIM: otamoTgniK


-KingTomato
#4841 05/01/03 06:16 PM
Joined: Dec 2002
Posts: 1,321
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Dec 2002
Posts: 1,321
Speed test it every way you can think of. Let me know what you find out. I think you'll see why I made the suggestions I did.

{ and } are required for multiple commands under a single condition, what ever it happens to be. They are used to group the commands, usually to put multiple commands on separate lines under a condition. ( and ) are used to surround and delimit a conditional expression. None of them are required.

Granted, readability is a big issue, especially when you are initially coding something or if you are troubleshooting. If speed is not an issue, then multiple lines and lots of extra characters for the parser to eliminate make no real difference. However, if speed is an issue, then optimizing your code only makes sense. As a programmer, I'm sure you realise that.


DALnet: #HelpDesk and #m[color:#FF0000]IR[color:#EEEE00]C
#4842 06/01/03 02:45 AM
Joined: Jan 2003
Posts: 44
L
Ameglian cow
OP Offline
Ameglian cow
L
Joined: Jan 2003
Posts: 44
thanx again man, you helped me to find why those files were being created, code was getting complex to look at. I've learned quite alot from you.

-----------------
Now about INPUT event.

I have:

Code:
ON *:INPUT:*:{
  if ( $1 == !replay ) && ( $2 != $null ) {
   ...
 }
...
}


I would realy like to have the !replay in place of the *, but when I do that, the event fails completely.

Any ideas?

#4843 06/01/03 03:58 AM
Joined: Dec 2002
Posts: 1,321
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Dec 2002
Posts: 1,321
The :*: means "when I type (actually, when I hit the enter key with text in the editbox) in any window"...it is not the same thing as a :<matchtext>: field; it specifies what kind of window mIRC is supposed to react in when you type something and hit Enter. This just means that you have to parse $1- yourself.
Code:

on *:INPUT:#:{
  if (($1 == !replay) &amp;&amp; ($2)) {
    [color:#006600];
    ;  This section of code will execute if you typed 
    ;  [color:black]!replay text here[/color]
    ;  in a channel window editbox.
    ; [/color]
    MyReplayAlias $active $2-
    halt
    ;[/color]
  }
  elseif ($1 == !config) {
    [color:#006600];
    ;  This section of code would bring up a dialog called 
    ;  MyConfig using the table definition tdefMyConfig
    ;[/color]
    dialog -m MyConfig tdefMyConfig
    halt
  }
}


DALnet: #HelpDesk and #m[color:#FF0000]IR[color:#EEEE00]C
#4844 07/01/03 09:08 PM
Joined: Jan 2003
Posts: 44
L
Ameglian cow
OP Offline
Ameglian cow
L
Joined: Jan 2003
Posts: 44
thanks, I've been doing that, was just hoping that I didn't have too.

Joined: Dec 2006
Posts: 9
S
Nutrimatic drinks dispenser
Offline
Nutrimatic drinks dispenser
S
Joined: Dec 2006
Posts: 9
if you put all on text event in the same one like I did in my mirc bot.

see:
on *:TEXT:*:#,?: {
if (!command1 isin $1) { ... }
if (!command2 isin $1) { ... }
if (!command3 isin $1) { ... }
else { halt }
}

check this massive on text out at -> http://www.sicorps.org/download/scrps.mrc

Last edited by SICORPS; 30/12/06 07:52 AM.

/ mIRC, PHP, Linux help and tutorial forum: www.SICORPS.org /
Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
While we appreciate replies to topics, SICORPS, please refrain from posting to topics that are 6 months or more in age.

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
And especially 4 years! Heh.

Btw, you don't need an else { halt } in something like that. And, return is better than halt when you're just trying to halt your own script.


Invision Support
#Invision on irc.irchighway.net

Link Copied to Clipboard