Subject: HELP!!!

From: [email-masked]
Date: Mon, 4 Oct 1993 08:00:30 -0700

Ok, so I've been hacking 14 hours now, and my eyes are blurry...but can
anyone explain why I'm getting this output:

[Direct cut and paste except for lines added enlosed by |xxx|]

list 1-$
  1: person = 0;
  2: length_ok = (length(args) == 2);
  3: arg1_ok = (length_ok && (typeof(args[1]) == OBJ));
  4: valid = (arg1_ok && valid(args[1]));
  5: arg2_ok = (valid && (typeof(args[2]) == STR));
  6: player:tell("length_ok ", length_ok, " arg1_ok ", arg1_ok, " valid ",
 valid, " arg2_ok ", arg2_ok);
  7: if (arg2_ok)
  8:   product = args[1];
  9:   feature = args[2];
 10: elseif (length(args) != 4)
 11:   player:tell("Invalid number of arguments.");
|^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
 12:   player:tell("Usage: remove_feature product feature from supplier");
 13:   player:tell("product must inherit from $product.");
 14:   player:tell("feature must be in features list of product.");
 15:   player:tell("feature may enclosed in quotes for multi-word
features.");
 16:   return E_ARGS;
 17: else
 18:   product = $string_utils:match_object(args[1], player.location);
 19:   feature = args[2];
 20:   person = 1;
 21: endif
 22: valid = valid(product);
 23: product_ok = (valid && $object_utils:isa(product, $g.product));
 24: feature_ok = (product_ok && (feature in product.features));
 25: player:tell("valid ", valid, " product_ok ", product_ok, " feature_ok
",
 feature_ok);
 26: if (feature_ok)
 27:   price = this:feature_cost(product, feature);
 28:   this.feature_prices = setremove(this.feature_prices, {product,
feature,
 price});
 29:   if (person)
 30:     this:product_info();
 31:   endif
 32: else
 33:   player:tell("Invalid type of arguments.");
|^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
^|
 34:   player:tell("Usage: remove_feature product feature from supplier");
 35:   player:tell("product must inherit from $product.");
 36:   player:tell("feature must be in features list of product.");
 37:   player:tell("feature may enclosed in quotes for multi-word
features.");
 38:   return E_INVARG;
_39_ endif
^^^^
com
#206:4 successfully compiled.
q
Wizard's Castle

You see game, company, game_room, intro, level_utils, You are on a hill
 over-looking Anytown, USA., intersection, store, office, office_door,
 store_front, game_container, cabinet, trash, Prairie, game_exit, Main
Street,
 autotown, staff_utils, supplier, cash_utils, game_thing, bicycle, and
product
 here.
remove_feature bicycle "rugged tires" from dave
length_ok 0 arg1_ok 0 valid 0 arg2_ok 0
valid 1 product_ok 1 feature_ok 2

|>>  *NEITHER* of the ^^^^^ lines came out <<|
|>> not to mention that none of the following 4 *SHOULD* come out <<|

Usage: remove_feature product feature from supplier
product must inherit from $product.
feature must be in features list of product.
feature may enclosed in quotes for multi-word features.
bicycle         $100 for orders up to 10
bicycle          $90 for orders up to 20
     rugged tires        $3
     smooth tires        $2
-- 
--
-- "TANSTAAFL" Rich [email-masked]

---

From: Pavel Curtis <[email-masked]>
Date: Tue, 5 Oct 1993 10:22:26 -0700

It looks to me like neither of the underlined lines *should* be executed and
that probably your `this:product_info()' verb is printing the four lines you
say shouldn't be printed out.

	Pavel

PS- By the way, it is usually better to show people the results of an @list
command instead of the output of the editor's `list' command, since you might
have made some indentation errors in the editor that might mislead the reader.
Since the @list command only prints code that has been formatted by the server,
it cannot mislead anyone in this way.

---

From: Judy Anderson <[email-masked]>
Date: Tue, 5 Oct 1993 09:58:23 -0700

It looks to me like you have a fundamental misunderstanding of how
arguments work to command line functions.  They're all strings...  use
dobj and iobj if you want to get pre-parsed objects.
$string_utils:explode(dobjstr) or iobjstr can be useful too, calling
match on those results.  Typically what I do when I have a command
that wants more than one argument is call it "frob foo with mumble
frotz as baz" making my arglist any with any, and parse iobjstr for
the "as", then parse the leftover bits.  This enables you to avoid the
ugly construction frob foo "mumble frotz" as baz---it is more user
friendly, and really isn't that much more work.  Anyway, I didn't try
to figure out exactly what your problem was, but checking
typeof(args[1]==OBJ) rang a little bell for me...  If you're intending
this to be called either from command line or from code, the thing to
do is make two verbs, one that does the work, and one that parses the
stuff.  This enables you to separate parsing from doing.