Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD Beta Forum
sabman
Novice


Joined: 17 Aug 2007
Posts: 34

PostPosted: Mon Aug 27, 2007 5:59 pm   

[2.01] Bug or Doc Problem with #MATH
 
I'm not sure if this is a bug, my error, or a doc problem.

The math syntax is:

Syntax: #MAT varname expression

Yet when I do:

#MATH temp @amount + 1

It assigns the value of amount to temp and places temp in class 1, although this:

#MATH temp @amount+1

Works perfectly.

Nowhere in the doc does it say if the problem is spaced it needs to be in parenthesis. The syntax also doesn't show that there's a flag for class assignment.

Suggestion 1:
Change the doc to include a statement about spaces in equations and include an example like the one above, but correct. (#MATH temp (@amount + 1))

Suggestion 2:
Change the usage of math to follow suit like other functions (while/if/etc) So that the statement MUST be encapsulated in parenthesis or braces.

Suggestion 3:
Change the #MATH statement to not include any class assignment and instead process the statement after the second whitespace as the entire MATH problem.
Reply with quote
Thinjon100
Apprentice


Joined: 12 Jul 2004
Posts: 190
Location: Canada

PostPosted: Mon Aug 27, 2007 6:13 pm   
 
Just like most commands in zScript, if you need to use spaces, enclose your parameter in {}s...

#MATH temp {@amount + 1} should work fine :)

Otherwise the parser has to decide whether a space in your command call is a split for a separate argument, or if it's supposed to be part of the equation, which it cannot do.
_________________
If you're ever around Aardwolf, I'm that invisible guy you can never see. Wizi ftw! :)
Reply with quote
sabman
Novice


Joined: 17 Aug 2007
Posts: 34

PostPosted: Mon Aug 27, 2007 6:19 pm   
 
Thinjon100 wrote:
Just like most commands in zScript, if you need to use spaces, enclose your parameter in {}s...

#MATH temp {@amount + 1} should work fine :)

Otherwise the parser has to decide whether a space in your command call is a split for a separate argument, or if it's supposed to be part of the equation, which it cannot do.


I agree. As a programmer, I usually enclose all my mathmatical equations just to be on the safeside, unless for some reason syntax doesn't allow.

And just why I mentioned it. Because the syntax first of all doesn't mention of a class assignement. Plus, all the examples are left unbounded.
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Mon Aug 27, 2007 6:36 pm   
 
You don't actually need to use #math - #var will do the same thing if you enclose its value parameter in brackets (). I'd assume that #math has a class parameter because it's exactly the same as #var, but always evaluates its value.

So with that said, I've added the class parameter to the #math help file. I don't think it needs anything beyond that, because zScript commands always have problems if items are unbound and contain spaces, even when there are no extra parameters. Take #additem, for example.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
sabman
Novice


Joined: 17 Aug 2007
Posts: 34

PostPosted: Mon Aug 27, 2007 6:39 pm   
 
That's better, at least. If I had seen the class parameter, I'd have assumed.

When working with scripting languages like this, it can be hard to tell, because there's no standard..
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Mon Aug 27, 2007 6:53 pm   
 
Well, there's an internal standard, and now you know :P

No commands actually allow multi-word unbounded parameters. The ones that look like they do actually take a variable number of parameters and do something with them all afterwards (like #say concating them all together with spaces between and printing them on the screen). So it's consistent, anyway.

If you're that bothered, use Lua ;)
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD Beta Forum All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net