 |
Guinn Wizard
Joined: 03 Mar 2001 Posts: 1127 Location: London
|
Posted: Wed Apr 18, 2007 7:40 am
[1.28] *URGENT* 'Reformat script' still results in broken syntax |
Still having a problem reformatting text
The working alias
| Code: |
#LOCAL $whoLeft
#IF (@whoOld != @whoList) {
#FORALL {@whoOld} {
#IF (!%ismember( %i, @whoList)) {$whoLeft = $whoLeft|%i}
}
#IF (%numitems($whoLeft) && !%ismember( @character, $whoLeft)) {
#SHOW ** Logged off @ %time( hh:mm:ss) : %expandlist($whoLeft, ", ")
}
}
whoOld = @whoList |
When reformatted it looks like
| Code: |
#LOCAL $whoLeft
#IF (@whoOld != @whoList) {#FORALL {@whoOld} {#IF (!%ismember( %i, @whoList)) {$whoLeft = $whoLeft|%i}}
#IF (%numitems( $whoLeft) && !%ismember( @character, $whoLeft)) {#SHOW ** Logged off @ %time( hh:mm:ss) : %expandlist( $whoLeft, ", ")}}
whoOld = @whoList |
Which gives 'Error compiling script: argument expected' |
|
_________________ CMUD Pro, Windows Vista x64
Core2 Q6600, 4GB RAM, GeForce 8800GT
Because you need it for text... ;) |
|
|
 |
Tech GURU

Joined: 18 Oct 2000 Posts: 2733 Location: Atlanta, USA
|
Posted: Wed Apr 18, 2007 2:04 pm |
Confirmed. The #IF on the second line is being indented when it shouldn't be.
|
|
_________________ Asati di tempari! |
|
|
 |
Zugg MASTER

Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Wed Apr 18, 2007 5:02 pm |
Added to bug list. Actually, the indentation of the second #IF is correct. The bug is that the #FORALL should be placed on it's own intended line. So the result is supposed to be like this:
| Code: |
#LOCAL $whoLeft
#IF (@whoOld != @whoList) {
#FORALL {@whoOld} {#IF (!%ismember( %i, @whoList)) {$whoLeft = $whoLeft|%i}}
#IF (%numitems( $whoLeft) && !%ismember( @character, $whoLeft)) {#SHOW ** Logged off @ %time( hh:mm:ss) : %expandlist( $whoLeft, ", ")}}
whoOld = @whoList |
CMUD is supposed to determine the number of commands within a {} block. If there is only one command, then it keeps it all on the same line. If there is more than one command, then it is supposed to put each command on it's own line. Looks like this counter is getting messed up so that the first #IF statement thinks that it only has one command instead of two, so it's putting the #FORALL on the same line instead of putting it on the next line.
Anyway, I'll use this example to clean it up. At least it not munging the text of the script like it was in the previous version. |
|
|
|
 |
charneus Wizard

Joined: 19 Jun 2005 Posts: 1876 Location: California
|
|
|
|
 |
Zugg MASTER

Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Thu Apr 19, 2007 4:58 pm |
Actually, Charneus, your example in the other post that you mentioned works fine for me in 1.28. The bug that was causing it was different than the bug that is causing the problem with the script in this thread. I know they seem similar, but the Reformat option is pretty complicated and still new and a bit buggy. That's why it's always good for me to get as many examples of problem scripts as possible.
|
|
|
|
 |
Zugg MASTER

Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Fri Apr 20, 2007 11:27 pm |
Well, this turned out to be a very interesting problem.
The cause of the problem was actually the #FORALL command. If you entered
| Code: |
#IF (@whoOld != @whoList) {
#FORALL {@whoOld} {#IF (!%ismember( %i, @whoList)) {$whoLeft = $whoLeft|%i}}
#IF (%numitems( $whoLeft) && !%ismember( @character, $whoLeft)) {#SHOW ** Logged off @ %time( hh:mm:ss) : %expandlist( $whoLeft, ", ")}} |
and then did a Reformat, it would put the #FORALL at the end of the previous line and give the indentation problem. But if you entered this:
| Code: |
#IF (@whoOld != @whoList) {
#FORALL @whoOld {#IF (!%ismember( %i, @whoList)) {$whoLeft = $whoLeft|%i}}
#IF (%numitems( $whoLeft) && !%ismember( @character, $whoLeft)) {#SHOW ** Logged off @ %time( hh:mm:ss) : %expandlist( $whoLeft, ", ")}} |
then it would Reformat correctly. Notice the only difference is the {} around the first argument for #FORALL. The parser was seeing the {} and parsing it differently. This uncovered a rather obscure parser bug.
So, I fixed that so that it works with the {} around it. However, then I wanted to make Reformat actually *fix* the indentation problem. Because the #IF statement was indented, it was being considered as a continuation of the previous line. So, from the Reformat perspective, there was nothing to reformat. But this caused a syntax error.
So, I changed how the indentation rules are handled. In the new 1.29 version, if a statement starts with a #command, then it will *never* be treated as a continuation of the previous line, no matter what the indentation is. This fixes the above script so that there isn't any syntax error, and also causes the Reformatter to work properly and put the #FORALL on it's own line.
While I was messing with all of this indentation stuff, I also added a fix so that "standard C" indentation works. So now you can do this:
| Code: |
#IF (true)
{
statements here
} |
In previous versions, this wouldn't work...it required the initial { at the end of the first line. If you Reformat this, it will still indent the final }, which probably isn't what you want. I'll probably add an option for this in the future.
I also added a Ctrl-M shortcut for the Reformat option. Hopefully all of these improvements will really help with the new version, but definitely let me know (in a NEW POST please) if there are any new problems that you find in the Reformatter. |
|
|
|
 |
Guinn Wizard
Joined: 03 Mar 2001 Posts: 1127 Location: London
|
Posted: Fri Apr 20, 2007 11:54 pm |
Glad you got it fixed, I'll do my best to try and break it in 1.29 and let you know
Edit: Oops, didn't see 1.29 was already out. Seems to have fixed things for me so far. Will keep trying. Thanks! |
|
_________________ CMUD Pro, Windows Vista x64
Core2 Q6600, 4GB RAM, GeForce 8800GT
Because you need it for text... ;) |
|
|
 |
|
|
|
|
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
|
|