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


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Thu Sep 23, 2010 1:58 am   

[3.28-3.29] (Reformatting Issues) #SWITCH Illegal Token Error
 
Code:

<alias name="test_reformat" id="1651">
  <value>$val=0
#SWITCH (%params="test1") {#LOCAL $test
$val=1
$test="This is a test"
#show %concat($test, $val)}
   (%params="test2") {#LOCAL $test
$val=2
$test="This is a test"
#show %concat($test, $val)}
   (%params="test3") {#LOCAL $test
$val=3
$test="This is a test"
#show %concat($test, $val)}
   (%params="test4") {#LOCAL $test
$val=4
$test="This is a test"
#show %concat($test, $val)}
   {#show "Oh no!"}</value>
</alias>


The above gives you:
Code:

$val=0
#SWITCH (%params="test1") {#LOCAL $test
$val=1
$test="This is a test"
#show %concat($test, $val)}
   (%params="test2") {#LOCAL $test
$val=2
$test="This is a test"
#show %concat($test, $val)}
   (%params="test3") {#LOCAL $test
$val=3
$test="This is a test"
#show %concat($test, $val)}
   (%params="test4") {#LOCAL $test
$val=4
$test="This is a test"
#show %concat($test, $val)}
   {#show "Oh no!"}


Re-format and you get:

Code:

$val=0
#SWITCH (%params="test1") {
#LOCAL $test
  $val=1
  $test="This is a test"
  #show %concat( $test, $val)
  }
   (%params="test2") {
#LOCAL $test
  $val=2
  $test="This is a test"
  #show %concat( $test, $val)
  }
   (%params="test3") {
#LOCAL $test
  $val=3
  $test="This is a test"
  #show %concat( $test, $val)
  }
   (%params="test4") {
#LOCAL $test
  $val=4
  $test="This is a test"
  #show %concat( $test, $val)
  }
   {#show "Oh no!"}


BOOM! Illegal token error...

re-format again and you get:
Code:

$val=0
#SWITCH(%params="test1") {
#LOCAL $test
  $val=1
  $test="This is a test"
  #show %concat( $test, $val)
  }
   (%params="test2") {
#LOCAL $test
$val=2
  $test="This is a test"
#show %concat( $test, $val)
  }
   (%params="test3") {
#LOCAL $test
$val=3
  $test="This is a test"
#show %concat( $test, $val)
  }
   (%params="test4") {
#LOCAL $test
$val=4
  $test="This is a test"
  #show %concat( $test, $val)
  }
   {#show "Oh no!"}


(Notice how #SWITCH (%params="test1") {, changes to: #SWITCH(%params="test1") {)
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
Zugg
MASTER


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

PostPosted: Thu Sep 23, 2010 3:21 am   
 
#SWITCH is *very* picky about how it is formatted, and I'm not going to be able to change/fix that this close to the release.

This is related to the previous issue about the #LOCAL not getting indented. You'll notice after you do the first Reformat that if you do a Syntax Check, it will fail. Reformat *requires* the script to pass the syntax check or else it will fail and make things worse. Maybe I should add a popup confirmation to Reformat so that it doesn't work when there is a syntax error.
Reply with quote
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Thu Sep 23, 2010 3:22 am   
 
Don't know! I'm just looking for errors, as requested. Most of these are easily fixable manually and so aren't a major concern really. I trust that you know how you can deal with it and if you can't. Smile
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
oldguy2
Wizard


Joined: 17 Jun 2006
Posts: 1201

PostPosted: Thu Sep 23, 2010 6:39 pm   
 
Not to nitpick but you don't even need #local or the $var = 0 because you are declaring and initializing at the same time. Both variables are also local to their own code block and only matter within that scope. Unless you are using $val somewhere else you don't need to declare it before the switch.

Code:
#SWITCH (%params="test1") {
  $val=1
  $test="This is a test"
  #show {%concat( $test, $val)}
  }
  (%params="test2") {
  $val=2
  $test="This is a test"
  #show {%concat( $test, $val)}
  }
  (%params="test3") {
  $val=3
  $test="This is a test"
  #show {%concat( $test, $val)}
  }
  (%params="test4") {
  $val=4
  $test="This is a test"
  #show {%concat( $test, $val)}
  }
  {#show "Oh no!"}


You could also simply do #local $val $test before the switch statement, but it isn't necessary if they are never used outside of the block they are used in.
Reply with quote
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Thu Sep 23, 2010 6:52 pm   
 
Oldguy, I was only using LOCAL in that switch for purposes of testing it, since I had noticed the error elsewhere but wanted to make an easy test alias to reproduce the bug. This alias isn't actually useful in any way.
_________________
Listen to my Guitar - If you like it, listen to more
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