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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
Salaric
Beginner


Joined: 10 Jun 2008
Posts: 17

PostPosted: Wed Aug 25, 2010 8:18 pm   

Illegal Character in Expression
 
Greetings, I am converting a script from zmud to cmud and things have been flawless up to one alias.

Code:
#ALIAS lsitem {#if (%lower( %1) = add) {#if (%5 = %nul or !%isnumber( %2) or !%isnumber( %3) or !%isnumber( %4)) {#show @{sLShopColorErrors}Syntax: LSITEM ADD ~<price~> ~<bin~> ~<qty~> ~<item name~>@{sLShopColorBody}} {#addkey dLShopItems %replace( "%-5", ",", "") "%2 %3 %4";#show Created/updated item @{sLShopColorHighlight}%-5@{sLShopColorBody} (price @{sLShopColorHighlight}%2@{sLShopColorBody}, bin @{sLShopColorHighlight}%3@{sLShopColorBody}, quantity @{sLShopColorHighlight}%4@{sLShopColorBody}).}};#if (%lower( %1) = delete) {#if (%db( @dLShopItems, %replace( "%-2", ",", "")) = "") {#show @{sLShopColorErrors}%-2 isn't a known item.@{sLShopColorBody}} {#delkey dLShopItems "%-2";#show Deleted item @{sLShopColorHighlight}%-2@{sLShopColorBody}.}};#if (%lower( %1) = check or %lower( %1) = list) {sLShopScratch1 = 0;#loopdb @dLShopItems {#if (%2 = %nul or %pos( %2, %key)) {#if (@sLShopScratch1 = 0) {#show "Item                                       Price  Bin  Quantity";#show "-------------------------------------  ---------  ---  --------";sLShopScratch1 = 1};#show @{sLShopColorHighlight}%format( "&-37s", %key) @{sLShopColorBody} %format( "&7.0n", %word( %val, 1))gp ~ %format( "&3.0n", %word( %val, 2)) ~ %format( "&8.0n", %word( %val, 3))}};#if (@sLShopScratch1 = 0) {#show @{sLShopColorErrors}No known items match %-2.@{sLShopColorBody}} {#show "-------------------------------------  ---------  ---  --------"}};#send ""}


I am getting the error: ERROR: Syntax error in Alias: lsitem : illegal character in expression: ,


Any thoughts? All other aliases in this script seem to work just fine but this one
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Thu Aug 26, 2010 2:29 am   
 
It's your use of ( and ) in their unquoted forms via implicit concatenation. () is interpreted as a faster version of %eval().
_________________
EDIT: I didn't like my old signature
Reply with quote
Salaric
Beginner


Joined: 10 Jun 2008
Posts: 17

PostPosted: Thu Aug 26, 2010 4:10 pm   
 
I'm sorry, that made no sense to me. Implicit concatenation?
Reply with quote
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: Thu Aug 26, 2010 8:30 pm   
 
Implicit concatenation means implied concatenation. For instance, when you do something like:

Code:
#show Created/updated item @{sLShopColorHighlight}%-5@{sLShopColorBody} (price @{sLShopColorHighlight}%2@{sLShopColorBody}, bin @{sLShopColorHighlight}%3@{sLShopColorBody}, quantity @{sLShopColorHighlight}%4@{sLShopColorBody}).}}


You are implying that the entire code is one big string. It's the short form of doing:

Code:
#SHOW %concat("Created/updated item ",@{sLShopColorHighlight}, %-5, @{sLShopColorBody}," (price ",@{sLShopColorHighlight}, %2, ... )


So what happens here is that the ( in (price is being interpreted as an %eval statement instead of a string. If you wanted to keep your code this way, you would need to do ~( instead of just (.

Alternatively, you should be able to do #SHOW {Created/updated ... } and it should work properly, as %eval functions are not evaluated within {}.

Hope this makes sense...

Charneus
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD General Discussion 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