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
Guinn
Wizard


Joined: 03 Mar 2001
Posts: 1127
Location: London

PostPosted: Sun Oct 15, 2006 10:13 pm   

[1.10] Local variables and #ADDITEM & Multiline formatti
 
Two things...

Firstly, Can't seem to use #ADDITEM to add to a local variable within an alias. To get around it I've had to kludge using
$localvar = $localvar|%i

Secondly, I've had to put ; at the end of a few lines to force CMUD to realise they're the end of a statement, otherwise I get compilation errors - the end of the #IF statements are where it was happening.

To put into context, the alias in full is (for maintaining a wholist and people who join and leave):

Code:
#LOCAL $whoJoined
#LOCAL $whoLeft

#IF (@whoOld != @whoList) {
   #FORALL {@whoList} {
      #IF (!%ismember( %i, @whoOld)) {
         $whoJoined = $whoJoined|%i}};
   #FORALL {@whoOld} {
      #IF (!%ismember( %i, @whoList)) {
         $whoLeft = $whoLeft|%i}};
   #IF (%numitems($whoJoined)) {
      #SHOW *** Logged on @ %time( hh:mm:ss) : %expandlist($whoJoined, ", ")};
   #IF (%numitems($whoLeft)) {
      #SHOW ** Logged off @ %time( hh:mm:ss) : %expandlist($whoLeft, ", ")};
   }

whoOld = @whoList
_________________
CMUD Pro, Windows Vista x64
Core2 Q6600, 4GB RAM, GeForce 8800GT
Because you need it for text... ;)
Reply with quote
Arminas
Wizard


Joined: 11 Jul 2002
Posts: 1265
Location: USA

PostPosted: Mon Oct 16, 2006 12:03 am   
 
Confirmed the #additem problem

The problem with adding a ; at the end of the line is the same as I mentioned in another thread. But I didn't think actually adding the ; would help.
This works too.

Code:
#class who
#LOCAL $whoJoined
#LOCAL $whoLeft
#IF (@whoOld != @whoList)
   {
 #FORALL {@whoList}
  {
 #IF (!%ismember( %i, @whoOld))
  {
 $whoJoined = $whoJoined|%i
  }
  }
 #FORALL {@whoOld}
  {
 #IF (!%ismember( %i, @whoList))
  {
 $whoLeft = $whoLeft|%i
  }
  }
 #IF (%numitems($whoJoined))
  {
 #SHOW *** Logged on @ %time( hh:mm:ss) : %expandlist($whoJoined, ", ")
  }
 #IF (%numitems($whoLeft))
  {
 #SHOW ** Logged off @ %time( hh:mm:ss) : %expandlist($whoLeft, ", ")}
  }
whoOld = @whoList
#class 0
_________________
Arminas, The Invisible horseman
Windows 7 Pro 32 bit
AMD 64 X2 2.51 Dual Core, 2 GB of Ram
Reply with quote
Arminas
Wizard


Joined: 11 Jul 2002
Posts: 1265
Location: USA

PostPosted: Mon Oct 16, 2006 2:34 pm   
 
I didn't think to try it but, %additem does work. and as long as you are using, "$whoLeft|%i" anyway you could use that.
_________________
Arminas, The Invisible horseman
Windows 7 Pro 32 bit
AMD 64 X2 2.51 Dual Core, 2 GB of Ram
Reply with quote
Zugg
MASTER


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

PostPosted: Tue Oct 17, 2006 12:07 am   
 
None of the commands that use the name of a variable (like #ADDITEM) currently accept local variable names yet. The only command that handles local variables is #VAR. I'll try to fix this in a future version.

And yes, please see the other topic for problems with multiline syntax. It's broken in 1.10.
Reply with quote
Arminas
Wizard


Joined: 11 Jul 2002
Posts: 1265
Location: USA

PostPosted: Tue Oct 17, 2006 1:17 am   
 
Quote:
None of the commands that use the name of a variable (like #ADDITEM) currently accept local variable names yet. The only command that handles local variables is #VAR. I'll try to fix this in a future version.


Code:
#class Find
 #if (%1 = "go")
  {
 #noop %roommode( 1)
 #walk %item( @ExactResults, %2)
 #noop %roommode( 0)
  }
  {
 $ExactResults = %null
 $ExactMatches = %null
 $lostroom = %-1
 $sqlquery = %concat( "Name Like ", ~"%, %trimright( $lostroom), %~")
 #noop %roommode( 1)
 $FindQuery = %mapquery( $sqlquery)
 ExactResults = %null
 ExactMatches = %null
 #FORALL $FindQuery
  {
 $ExactResults =  %addItem( %i, $ExactResults)
 $ExactMatches = %addItem( %concat( "  ", %roomname( %i), " ", %numitems( $ExactResults)), $ExactMatches)
  }
 $ExactMatches = %push( %concat( %ansi(12), "Room Name Matches ",%numItems( $ExactResults)) , $ExactMatches)
 #noop %roommode( 0)
 #forall $ExactMatches
  {
 #show %i
  }
 #exec %lf
 ExactResults = $ExactResults
 ExactMatches = $ExactMatches
  }
 #class 0


This code works.....
_________________
Arminas, The Invisible horseman
Windows 7 Pro 32 bit
AMD 64 X2 2.51 Dual Core, 2 GB of Ram
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