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
darmir
Sorcerer


Joined: 10 Oct 2000
Posts: 706
Location: USA

PostPosted: Thu Sep 16, 2010 5:29 pm   

Reformat Script
 
I have noticed that when you reformat a script it adds extra open braces to the script.
Select Editor -- Reformat Script

Script before reformatting:
Code:

#variable channel %1
#variable input %params( 2)
#variable person ""
#variable sentence ""
#variable emph ""
#variable loopcount 0
#variable s_word ""
#local $matched//This IF is to check for Proper words.
    #IF %begins( %i, %proper($matched)) {
      #IF (%random( 1, 3)=1) {
        #IF (%i = "I" ) {#SHOW Should make this proper case.}
        #VARIABLE s_word %concat( %proper($matched), "-", %proper($matched), "-", %i)
        #VARIABLE sentence %replaceitem( @s_word, @loopcount, @sentence)
        }
      }

;Check to see if the channel is a member of the sayto list
#if (%ismember( @channel, @sayto)) {
  // Assign person variable and remove person from input variable
  #variable person %concat( %word( @input, 1), " ")
  #variable input %remove( @person, @input)
  }

;Check for a space a begining of input and remove
#variable input %trim(@input)

;Next check for an emphasis
#if (%begins( @input, "(") ) {
  #call %match( @input, "(~(*~))(*)", emph, sentence)
;Remnove space at begining of sentence to prepare to change into string list
  #variable sentence %trim( @sentence )
  } {
  #variable sentence @input
  }

;Change sentence into string list. 
  #VARIABLE sentence %replace( @sentence, " ", "|")

;Now check the remaining input variable and make it stutter
 #FORALL @sentence {
  #ADD loopcount 1
  #IF (%match(%i,%concat("^({",@stutterlist,"})*"),$matched)) {
    #IF (%random( 1, 3)=1) {
      #IF (%i = "I" ) {#SHOW Should make this proper case.}
      #VARIABLE s_word %concat( $matched, "-", $matched, "-", %i)
      #VARIABLE sentence %replaceitem( @s_word, @loopcount, @sentence)
      }
     }
  }

;Replace pipe symbols with space to display remaining input
#variable sentence %expandlist(@sentence," ")

;********* Display the finished output ***********************
#if (@channel =~ "shout" || @channel =~ "yell")
{#print You can't use emphasis with shout.
 @channel @sentence}
 {@channel @person %quote( @emph) @sentence}


Script after reformatting, See the extra open braces:
Code:

#variable channel %1
#variable input %params( 2)
#variable person ""
#variable sentence ""
#variable emph ""
#variable loopcount 0
#variable s_word ""
#local $matched//This IF is to check for Proper words.
    #IF %begins( %i, %proper( $matched)) {{ <-- extra brace here
  #IF (%random( 1, 3)=1) {
  { <-- extra brace here
    #IF (%i = "I" ) {#SHOW Should make this proper case.}
    #VARIABLE s_word %concat( %proper( $matched), "-", %proper( $matched), "-", %i)
    #VARIABLE sentence %replaceitem( @s_word, @loopcount, @sentence)
    }}

;Check to see if the channel is a member of the sayto list
#if (%ismember( @channel, @sayto)) {
  // Assign person variable and remove person from input variable
  #variable person %concat( %word( @input, 1), " ")
  #variable input %remove( @person, @input)
  }

;Check for a space a begining of input and remove
#variable input %trim( @input)

;Next check for an emphasis
#if (%begins( @input, "(") ) {
  #call %match( @input, "(~(*~))(*)", emph, sentence)
  ;Remnove space at begining of sentence to prepare to change into string list
  #variable sentence %trim( @sentence )
  } {#variable sentence @input}

;Change sentence into string list. 
  #VARIABLE sentence %replace( @sentence, " ", "|")

;Now check the remaining input variable and make it stutter
 #FORALL @sentence {
{ <-- extra brace here
  #ADD loopcount 1
  #IF (%match( %i, %concat( "^({", @stutterlist, "})*"), $matched)) {[color=red]{[/color]
    #IF (%random( 1, 3)=1) {
    { <-- extra brace here
      #VARIABLE s_word %concat( $matched, "-", $matched, "-", %i)
      #VARIABLE sentence %replaceitem( @s_word, @loopcount, @sentence)
      }}
  }

;Replace pipe symbols with space to display remaining input
#variable sentence %expandlist( @sentence, " ")

;********* Display the finished output ***********************
#if (@channel =~ "shout" || @channel =~ "yell")
{#print You can't use emphasis with shout.
 @channel @sentence}
 {@channel @person %quote( @emph) @sentence}
_________________
Run as hard as a wild beast if you will, but you won't get any reward greater than that destined for you.
Source: (Egyptian)
Reply with quote
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Thu Sep 16, 2010 6:17 pm   
 
It's done this for a long long time, but it doesn't always do it. I've been unable to isolate why and when it does it, which is why I've never been able to report it.
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
Zugg
MASTER


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

PostPosted: Thu Sep 16, 2010 6:42 pm   
 
Yeah, I couldn't reproduce it either. When I pasted your script into a new alias in a blank session and then did a Reformat, I got this:
Code:
#variable channel %1
#variable input %params( 2)
#variable person ""
#variable sentence ""
#variable emph ""
#variable loopcount 0
#variable s_word ""
#local $matched//This IF is to check for Proper words.
    #IF %begins( %i, %proper( $matched)) {#IF (%random( 1, 3)=1) {
    #IF (%i = "I" ) {#SHOW Should make this proper case.}
    #VARIABLE s_word %concat( %proper( $matched), "-", %proper( $matched), "-", %i)
    #VARIABLE sentence %replaceitem( @s_word, @loopcount, @sentence)
    }}

;Check to see if the channel is a member of the sayto list
#if (%ismember( @channel, @sayto)) {
  // Assign person variable and remove person from input variable
  #variable person %concat( %word( @input, 1), " ")
  #variable input %remove( @person, @input)
  }

;Check for a space a begining of input and remove
#variable input %trim( @input)

;Next check for an emphasis
#if (%begins( @input, "(") ) {
  #call %match( @input, "(~(*~))(*)", emph, sentence)
  ;Remnove space at begining of sentence to prepare to change into string list
  #variable sentence %trim( @sentence )
  } {#variable sentence @input}

;Change sentence into string list.
  #VARIABLE sentence %replace( @sentence, " ", "|")

;Now check the remaining input variable and make it stutter
 #FORALL @sentence {
  #ADD loopcount 1
  #IF (%match( %i, %concat( "^({", @stutterlist, "})*"), $matched)) {#IF (%random( 1, 3)=1) {
      #IF (%i = "I" ) {#SHOW Should make this proper case.}
      #VARIABLE s_word %concat( $matched, "-", $matched, "-", %i)
      #VARIABLE sentence %replaceitem( @s_word, @loopcount, @sentence)
      }}
  }

;Replace pipe symbols with space to display remaining input
#variable sentence %expandlist( @sentence, " ")

;********* Display the finished output ***********************
#if (@channel =~ "shout" || @channel =~ "yell")
{#print You can't use emphasis with shout.
 @channel @sentence}
 {@channel @person %quote( @emph) @sentence} 

No extra braces. If you can track down the difference between doing this in your session and doing it in a blank session, that might help.
Reply with quote
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Thu Sep 16, 2010 7:08 pm   
 
Well, I can attest that it does happen, Zugg, I just don't know how to get it to reproduce. However, I'll see if I can try to figure it out since I haven't actively tried to, that is, if the original poster doesn't first.
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
darmir
Sorcerer


Joined: 10 Oct 2000
Posts: 706
Location: USA

PostPosted: Thu Sep 16, 2010 11:51 pm   
 
Zugg wrote:
Yeah, I couldn't reproduce it either. When I pasted your script into a new alias in a blank session and then did a Reformat, I got this:
Code:
#variable channel %1
#variable input %params( 2)
#variable person ""
#variable sentence ""
#variable emph ""
#variable loopcount 0
#variable s_word ""
#local $matched//This IF is to check for Proper words.
    #IF %begins( %i, %proper( $matched)) {#IF (%random( 1, 3)=1) {
    #IF (%i = "I" ) {#SHOW Should make this proper case.}
    #VARIABLE s_word %concat( %proper( $matched), "-", %proper( $matched), "-", %i)
    #VARIABLE sentence %replaceitem( @s_word, @loopcount, @sentence)
    }}

;Check to see if the channel is a member of the sayto list
#if (%ismember( @channel, @sayto)) {
  // Assign person variable and remove person from input variable
  #variable person %concat( %word( @input, 1), " ")
  #variable input %remove( @person, @input)
  }

;Check for a space a begining of input and remove
#variable input %trim( @input)

;Next check for an emphasis
#if (%begins( @input, "(") ) {
  #call %match( @input, "(~(*~))(*)", emph, sentence)
  ;Remnove space at begining of sentence to prepare to change into string list
  #variable sentence %trim( @sentence )
  } {#variable sentence @input}

;Change sentence into string list.
  #VARIABLE sentence %replace( @sentence, " ", "|")

;Now check the remaining input variable and make it stutter
 #FORALL @sentence {
  #ADD loopcount 1
  #IF (%match( %i, %concat( "^({", @stutterlist, "})*"), $matched)) {#IF (%random( 1, 3)=1) {
      #IF (%i = "I" ) {#SHOW Should make this proper case.}
      #VARIABLE s_word %concat( $matched, "-", $matched, "-", %i)
      #VARIABLE sentence %replaceitem( @s_word, @loopcount, @sentence)
      }}
  }

;Replace pipe symbols with space to display remaining input
#variable sentence %expandlist( @sentence, " ")

;********* Display the finished output ***********************
#if (@channel =~ "shout" || @channel =~ "yell")
{#print You can't use emphasis with shout.
 @channel @sentence}
 {@channel @person %quote( @emph) @sentence} 

No extra braces. If you can track down the difference between doing this in your session and doing it in a blank session, that might help.


This is really weird.
I am using version: 3.36, but it is a trial version for now.
I used the reformat script option on both a session connecting to Shadows of Isildur mud and an blank session and I still get the extra open braces.
Not sure what I can do to help reproduce this, but it happens every time I try to reformat this script. Is there any steps you want me to take and any way to capture this?
_________________
Run as hard as a wild beast if you will, but you won't get any reward greater than that destined for you.
Source: (Egyptian)
Reply with quote
Zugg
MASTER


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

PostPosted: Fri Sep 17, 2010 1:12 am   
 
Try making a backup and then deleting your CMUD.INI file to restore the default preferences in case you have changed something that is effecting this. Then post the exact step-by-step procedure that you used with a blank session.
Reply with quote
darmir
Sorcerer


Joined: 10 Oct 2000
Posts: 706
Location: USA

PostPosted: Fri Sep 17, 2010 1:33 am   
 
1) Uninstall Communication package.
2) Created back up of cmud.ini file.
3) Delete cmud.ini file
4) Start CMUD.
5) Select open session offline
6) Click Library button
7) Search for Communication in Name field
8) Select Communication Package and install
9) Click Setting Button
10) File -- open - package Communication
11) Once installed select the stutter alias
12) Select Editor - Reformat Script
13) Select Editor -- Check Syntax

You will see the syntax is messed up. If you cancel and then do a check syntax it is perfect.
_________________
Run as hard as a wild beast if you will, but you won't get any reward greater than that destined for you.
Source: (Egyptian)
Reply with quote
Zugg
MASTER


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

PostPosted: Fri Sep 17, 2010 4:07 pm   
 
OK, I was able to reproduce it with that procedure. And I actually narrowed it down to a very simple script that fails:
Code:
#forall @sentence {
  #add loopcount 1
  }

Now, if You just type that into an alias, it WON'T fail. The trick is to put an extra space at the end of the first line after the { character. With the extra space the Reformat command will now fail and generate this:
Code:
#forall @sentence {{
  #add loopcount 1}

So that explains why this was hard to track down. It's the extra trailing whitespace that can screw up the reformatter. Thanks for helping to track down this problem. I'll have it fixed in the next version.
Reply with quote
darmir
Sorcerer


Joined: 10 Oct 2000
Posts: 706
Location: USA

PostPosted: Fri Sep 17, 2010 6:13 pm   
 
Fantastic. Like I said You are the man Zugg!
_________________
Run as hard as a wild beast if you will, but you won't get any reward greater than that destined for you.
Source: (Egyptian)
Reply with quote
darmir
Sorcerer


Joined: 10 Oct 2000
Posts: 706
Location: USA

PostPosted: Fri Sep 17, 2010 6:20 pm   
 
Hey Zugg,
I just noticed that sometime the comments also get a little messed up when you reformat the script. If you look at my script and reformat it (after removing the extra space after the open braces. Then go done to where this comment is:
Code:

  ;Remove space at beginning of sentence to prepare to change into string list


It puts a few spaces in front the semi-colon. It still works, but it doesn't make it look like a comment, which is italicized and blue.
_________________
Run as hard as a wild beast if you will, but you won't get any reward greater than that destined for you.
Source: (Egyptian)
Reply with quote
Zugg
MASTER


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

PostPosted: Fri Sep 17, 2010 6:27 pm   
 
That was another side effect of the bug. Once the Reformatter gets confused then it's a mess. Give me a short example showing the problem with the extra space removed if you can reproduce it. But I am not seeing any change in the comments here.
Reply with quote
darmir
Sorcerer


Joined: 10 Oct 2000
Posts: 706
Location: USA

PostPosted: Fri Sep 17, 2010 6:34 pm   
 
I just did the following alias, making sure there is no space after each line and it moved the comment.
Code:

#variable test
#variable test2

#if (@test =~ @test2) {
;Testing the comment.
#print Hello World
  }

Here is the format after the reformat ran
Code:

#variable test
#variable test2

#if ( @test =~ @test2) {
  ;Testing the comment.
  #print Hello World
  }


Notice the space before the semi-colon. I figured this one out if there is no empty line before a comment is adds a space. If you put a empty line above the comment it formats it correctly.

Also if you put a period at the end of the comment it give you the red line underneath for spelling check too.
_________________
Run as hard as a wild beast if you will, but you won't get any reward greater than that destined for you.
Source: (Egyptian)
Reply with quote
Zugg
MASTER


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

PostPosted: Fri Sep 17, 2010 8:24 pm   
 
Yep, I see the problem. Thanks for the simpler script to show the problem.
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