Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ Perlscript ➜ Error Code Description Variables -- Handy & Cool!

Error Code Description Variables -- Handy & Cool!

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by 1of10   Canada  (54 posts)  Bio
Date Sat 15 Mar 2003 07:19 AM (UTC)

Amended on Sat 15 Mar 2003 07:23 AM (UTC) by 1of10

Message
For people who want a description of the error code being returned by various functions.

Place the following associative array in your script files. Best place is a global script that is included in seperate script files, thus making it available to all without duplication. This is why I love using PerlScript :) At the top of all individual script files require the global one.

require "C:/Program Files/MUclient/scripts/GLOBAL.pl";


If you want to swap single quotes for qouble quotes in the array below, make sure you remember to escape the proper characters! Single quotes do not require escaping.

# ----------------------------------------------------------
# Error codes returned by various functions
# ----------------------------------------------------------
%errCodes = (
	0 => 'Success!',
	30001 => 'World already open.',
	30002 => 'World closed; cannot perform action.',
	30003 => 'Name required; none specified.',
	30004 => 'Sound file cannot be played.',
	30005 => 'Trigger does not exist.',
	30006 => 'Trigger already exists.',
	30007 => 'Trigger "match" text cannot be empty.',
	30008 => 'Object name invalid.',
	30009 => 'Script name/subroutine not in script file.',
	30010 => 'Alias does not exist.',
	30011 => 'Alias already exists.',
	30012 => 'Alias "match" text cannot be empty.',
	30013 => 'Cannot open file.',
	30014 => 'Log file not open.',
	30015 => 'Log file already open.',
	30016 => 'Bad write to log file.',
	30017 => 'Timer does not exist.',
	30018 => 'Timer already exists.',
	30019 => 'Cannot delete variable; not found.',
	30020 => 'SetCommand: Command window not empty.',
	30021 => 'Regular expression syntax error.',
	30022 => 'AddTimer: Invalid time given.',
	30023 => 'AddToMapper: Invalid direction.',
	30024 => 'No items in mapper.',
	30025 => 'Unknown option name.',
	30026 => 'New option value out of range.',
	30027 => 'Trigger sequence value invalid.',
	30028 => 'Trigger "send to" is invalid.',
	30029 => 'Trigger label not specified/invalid for "send to variable".',
	30030 => 'Plugin file not found.',
	30031 => 'Parsing or other problem loading plugin.',
	30032 => 'Plugin cannot set option.',
	30033 => 'Plugin cannot get option.',
	30034 => 'Requested plugin not valid.',
	30035 => 'Only plugins can do this.',
	30036 => 'Plugin script name/subroutine not in plugin script.',
	30037 => 'Plugin does not support save state.',
	30038 => 'Plugin cannot save state.  No state directory?',
	30039 => 'Plugin is disabled.',
	30040 => 'Cannot call plugin routine.'
);


Then to use the new descriptions:

my($return) = $world->deleteVariable("TestVar");
$world->note("DeleteVariable failed: $errCodes{$return}") if ($return);


If all is okay, $return will equal zero, and the note will not show. If you want to see all return values whether success or fail, remove the if ($return) so the note always gets printed.

NOTE: $errCodes{$return} is correct! So is %errCodes{$return}, but Perl run with -w (warnings enabled) will complain and say to use $errCodes instead.

One of Ten
Secondary Adjunct of Unimatrix Z03
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


10,030 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.