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
Tech
GURU


Joined: 18 Oct 2000
Posts: 2733
Location: Atlanta, USA

PostPosted: Sat Oct 21, 2006 5:43 pm   

[1.11] Some minor multiline errors.
 
There are minor errors with multi-line compilation.

Consider

Code:

#IF (TRUE) {
  #show do this
  #IF (False) { #SHOW do something}
  #show do some more
}
Code:

#IF (TRUE) {
#show do this
#IF (False) { #SHOW do something}
#show do some more
}
Code:
#IF (TRUE) {
 #show do this
 #IF (False) {
#SHOW do something
  }
 #show do some more
}


all compile.

But the following do not.

Code:

#IF (TRUE) {
  #show do this
#IF (False) { #SHOW do something}
  #show do some more
}
Code:

#IF (TRUE) {
  #show do this
  #IF (False) { #SHOW do something}
    #show do some more
}
Code:

#IF (TRUE) {
#show do this
#IF (False) { #SHOW do something}
  #show do some more
}
Code:

#IF (TRUE) {
  #show do this
#IF (False) { #SHOW do something}
  #show do some more
}
Code:
#IF (TRUE) {
 #show do this
 #IF (False) {
#SHOW do something
  }
   #show do some more
}
Code:
#IF (TRUE) {
 #show do this
  #IF (False) {
#SHOW do something
  }
  #show do some more
}


It seems the crux of it is when in a statement block, that if there are lines A and B (where B comes after A) B can not be more indented than A unless it's in a new statement block.

Is that detailed enough for you? Very Happy
_________________
Asati di tempari!
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Sat Oct 21, 2006 10:20 pm   
 
I thought Zugg answered this already, saying it was supposed to be like that? While we have more freedom to better lay out our code, there are still rules we need to follow.
_________________
EDIT: I didn't like my old signature
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Mon Oct 23, 2006 7:32 pm   
 
Matt is correct. You still need to watch your indentation. When you un-indent a line, you are resetting the indentation for the block. The line after your un-indented line looks like a continuation line, and therefore causes a proper syntax error. The rule is that if a line is indented compared to the previous line, then it is treated as a continuation line.
Reply with quote
BlackSmith
Apprentice


Joined: 08 Dec 2002
Posts: 152

PostPosted: Thu Oct 26, 2006 2:01 pm   
 
If here is trying to be some real coding to be done, i suggest that the indentation follows the general coding rules thus e.g. this should work in cmud
Code:
#If ("%1" != {Skeleton|Wight|Zombie|Mummy|Ghost}) {
 #If (@Loot) {
  #Send {loot}
  #If (@Floating_disc.Boolean) {
    #Send {put all armour, all weapon, all chest, all vault, all box to my disc}
    }
  #Send {drop Lcoins}
  }
 #If (@Soul.Use) {
  #If (@Soul_Ripper.Boolean) {
   #Send {rip soul from corpse}
  } {
   #If (@Necromatic_Staff.Boolean) {
    #Send {chant arkemile}
   }
  }
 }
}
zMud handelss these just fine, while cmud trips over on the issue. Is there a good reason to construct this on exception on exception.
It could be handled as clearly and simply as in python.

And no, using ; as a separator and making them one line wont do as if someone uses the same code and has different separator char, it wont work.
_________________
BatMUD Best MMORPG around since 1990 telnet://bat.org:23
~ Magic & Mind beats Chrome & Meat anytime ~
Pattern(s) in PERL. Using Cmud 1.34/2.09 & BatClient.
Reply with quote
Larkin
Wizard


Joined: 25 Mar 2003
Posts: 1113
Location: USA

PostPosted: Thu Oct 26, 2006 4:53 pm   
 
You have some indentations in your example that don't line up properly for their scope. Perhaps if you straightened them up, they'd work in CMUD?
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Thu Oct 26, 2006 4:58 pm   
 
Not sure what you are saying BlackSmith. I entered your above example into the settings editor in CMUD and it worked just fine. You said
Quote:
cmud trips over on the issue

but you don't provide any details on what error you are getting. Be sure you are using the latest beta version of CMUD. If it doesn't work, then post more details. And I don't understand your comment
Quote:
Is there a good reason to construct this on exception on exception.
It could be handled as clearly and simply as in python.

It *is* handled as clearly and simply as in python. But the reality is that unlike in Python, we can't get rid of the {} without breaking compatibility with zMUD. But Python has been my model for the new indentation syntax in CMUD.

Also, there is another bug in your script that is unrelated to multiline syntax. In your first line you have "%1". This doesn't work in CMUD like it did in zMUD. In zMUD, adding the " around %1 was a kludge and this has been removed in CMUD. In fact, in CMUD, it works more consistently and *never* expands any variables or functions or parameters that are within " quotes. So in CMUD, your #IF statement is always true since you are comparing the literal string "%1" with the string list. It will never expand the %1. Also, just looking at the script, my guess is that you really want to use something like %ismember to test if %1 is within the string list.
Reply with quote
Seb
Wizard


Joined: 14 Aug 2004
Posts: 1269

PostPosted: Thu Oct 26, 2006 11:12 pm   
 
For me, this multiline syntax doesn't behave or look like Python's. Python's multiline syntax works like this:
If you have no unmatched brackets etc. and no line continuation character at the end of the line then indentation is important on the next line(s). In the other case, identation is irrelevant and is merely for esthetic reasons.

Blacksmith's code, above, in particular does not even appear to be using the new CMUD multiline syntax, since all his IF begin blocks have a { at the end of the line, and his else has } { on the same line. As he said himself, zMUD handles that fine. Therefore it can't be using any new feature...

I didn't have a problem with the old zMUD way of laying out code. I feel that the water is just a little muddier now (and I like Python). I guess time will tell.
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Fri Oct 27, 2006 2:04 am   
 
Seb, I wasn't trying to say that CMUD was like Python (duh!) What I was saying is that CMUD recognizes whitespace and indentation in a formal way like Python does. In Python, spaces *matter* and indentation *matters* (unlike in languages like C, Basic, etc).

As I said, the {} syntax is required for zMUD compatibility. I know that Python doesn't have {}...that wasn't the point. The point was that, like in Python, you have to be careful to indent properly to use multiline syntax in CMUD.
Reply with quote
Seb
Wizard


Joined: 14 Aug 2004
Posts: 1269

PostPosted: Mon Oct 30, 2006 10:41 am   
 
Ah, I see. Thanks for the clarification.
Reply with quote
BlackSmith
Apprentice


Joined: 08 Dec 2002
Posts: 152

PostPosted: Thu Nov 02, 2006 11:43 am   
 
I was using 1.10 and i got "Error prasing script".
Seems to compile fine with 1.12 (with the old format and with %ismember).
_________________
BatMUD Best MMORPG around since 1990 telnet://bat.org:23
~ Magic & Mind beats Chrome & Meat anytime ~
Pattern(s) in PERL. Using Cmud 1.34/2.09 & BatClient.
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