Save/Read Script

By Myidentityisasecret on May 11, 2013

Ehm...
Yeah...

alias save {
  if ($1 != $null) {
    if ($2 != $null) {
      set $+(%,save,.,$1) $2-
      echo -a ' $+ $1 $+ ' has been set to: $2-
    }
    else {
      echo -a Syntax: /save <name> <args>
    }
  }
  else {
    echo -a Syntax: /save <name> <args>
  }
}
alias read {
  if ($1 != $null) {
    if ($($+(%,save,.,$1),2) != $null) {
      echo -a $1 is: $($+(%,save,.,$1),2)
    }
    else {
      echo -a Error, $1 was never saved.
    }
  }
  else {
    echo -a Syntax: /read <name>
  }
}

Comments

Sign in to comment.
Yawhatnever   -  Jun 11, 2013

Using 'read' as an alias name is an ABSOLUTELY HORRIBLE IDEA because mIRC already has an identifier $read().
The same is true of /save. Just be glad you didn't call one of them /dec and then try to use it in another script inside a loop to decrease a variable (I've seen that before).

Checking if $1 is $null inside alias 'save' is redundant, because if $2 is not $null then $1 cannot be $null. Since the only valid format you have requires two parameters, you only need to check if $2 exists to know that they both exist.

$+(%,save,.,$1)

could be

$+(%,save.,$1)

because 'save' and '.' are both literal text. There's no reason to $+() them together.

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.