Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
patryn
Apprentice


Joined: 26 Sep 2001
Posts: 124

PostPosted: Thu Mar 08, 2007 8:53 am   

Not compiling
 
Hiyas

Im in the process of converting all my zmud settngs to Cmud and so far so good.
I've been able make almost all of the scripts compile by getting rid of spaces here and there, and adding line breaks before and after comments
The following two examples are my only compilation errors left.


I have a lot of child windows for logging various club channels, and the list of channels is dynamic.
In Zmud I was able to make use of a variable to store the name of the window and then use that in turn to change focus to different child windows using the script below

Code:
#alias {WindowFocusBack} {
wfocus=%item( @windowlist, %eval( %ismember( @wfocus, @windowlist)-1))
#IF %null( @wfocus) {wfocus=%item( @windowlist, %numitems( @windowlist))}
@wfocus:#noop
Main:#noop
}


There is no way I can get CMud to compile when i try to use a variable to specifiy the window name


The other thing I am unable to compile is default buttons in the #YesNo command. It seems that the compiler really does't like the * character.

Code:
#YesNo "This is a test" {Button1:#echo 1} {*Button2:#echo 2}


I suppose I can just change the buttons around and have whatever the default is as the first button, but that looks messy, especially when you're used to Yes being on the left and No on the right.

Any ideas?

Thanks
_________________
That which does not kill us, makes us stronger.
Reply with quote
Arminas
Wizard


Joined: 11 Jul 2002
Posts: 1265
Location: USA

PostPosted: Fri Mar 09, 2007 12:13 am   
 
Code:
#YesNo "This is a test" {"Button1:#echo 1"} {"*Button2:#echo 2"}


That was the easy one.

Try this for the first issue. UNTESTED

Code:
#alias WindowFocusBack {
wfocus=%item( @windowlist, %eval( %ismember( @wfocus, @windowlist)-1))
#IF (%null( @wfocus))
 {wfocus=%item( @windowlist, %numitems( @windowlist))}
 {#exec {@wfocus:#noop}}
Main:#noop
}
_________________
Arminas, The Invisible horseman
Windows 7 Pro 32 bit
AMD 64 X2 2.51 Dual Core, 2 GB of Ram
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Fri Mar 09, 2007 8:15 am   
 
You should use the #WINDOW command to set focus. I am pretty sure that it won't have any problems with the variable reference, but I can't really check right now. If it does have problems then it is likely something that should be bug reported.

Basically it is a good idea to avoid the use of #EXECUTE whenever possible. Although what Arminas posted should work as well, it will be slightly slower.
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
patryn
Apprentice


Joined: 26 Sep 2001
Posts: 124

PostPosted: Sat Mar 10, 2007 10:31 am   
 
Thanks that all works really well. However in a very similar piece of code, I may have found a problem.

When wanting to use a variable to specify the window name to send multiple executable commands to that window I now have to do this:

Code:
#exec {@test:%exec"#show blah;#echo blah 2"}
This Works

I would have thought that the proper syntax is:

Code:
#exec {@test:%exec("#show blah;#echo blah 2")}
This doesn't work

but this executes the code in the main window rather then the child windows.
It would probably be a good idea to add this peculiarity to the CMUD documentation if this is how %exec is supposed to function.
_________________
That which does not kill us, makes us stronger.
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Sat Mar 10, 2007 3:01 pm   
 
This is because it won't let you use a variable for the window name at the moment. Or at least, nobody else managed to get it to - it's really bizarre that that works :|

The workaround people are using is to use the #window command to change focus.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Sat Mar 10, 2007 7:38 pm   
 
Your usage %exec"#SHOW blah;#ECHO blah 2" is appearing to work because the %exec is doin nothing. It has no parameters and is doing nothing.

The correct way to do this sort of wierd expansion things is with %concat
#EXEC {%concat(@test,":#SHOW blah;#ECHO blah 2")}

A better method is to create an alias in the other window and then call that through the #EXEC if needed. Also if all you are going to do is display some stuff then you should use the #WINDOW command instead of a sloppy mess of #EXEC.
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
patryn
Apprentice


Joined: 26 Sep 2001
Posts: 124

PostPosted: Sun Mar 11, 2007 1:46 am   
 
The addition of the %exec must be doing something. I have tested and verified that it doesn't seem to matter what function is used before the string, it forces the string to be executed in the child window. Below are some examples just for the sake of interest. (I certainly found it interesting)

Code:
#exec {@test:"#show blah;#echo blah 2"}
E.g 1 -- This just displays "#show blah;#echo blah 2" as a string in the windows specified by @test. As expected.
Code:
#exec {%concat(@test:"#show blah;#echo blah 2")}
E.g 2 -- Same as example 1

Code:
#exec {@test:%concat("#show blah;#echo blah 2")}
E.g 3 -- This executes #show blah;#echo blah 2, in the child window. This is what i was aiming for
Code:
#exec {@test:%concat"#show blah;#echo blah 2"}
E.g 4 -- But so does this
Code:
#exec {@test:%exec"#show blah;#echo blah 2"}
E.g 5 -- and this
Code:
#exec {@test:%eval"#show blah;#echo blah 2"}
E.g 6 -- this too.

Code:
#exec {@test:%exec("#show blah;#echo blah 2")}
E.g 7-- This executes in the main window... not entirely sure that it should??

I will definately use #window to simply display things in child windows or change focus, but for now #exec solves the issue of referencing child windows through a variable when wanting to send executable code to them.

The reason why Im not a fan of creating settings for the other windows is because it gets a bit hard to maintain. (Sometimes I have 20+ child windows so its easier to control their settings dynamically through the main window)

It may be a good idea to prevent the parser from accepting the format showing in examples 4,5 and 6 to reduce the possibility of things going wrong in future. Like Xian Fang said, it is really bizarre that this works and from what I understand one of the negatives of ZMud was that its parser wasn't too strict on syntax.

(PS: Can someone move this to the Beta Forum as its probably best suited there)
_________________
That which does not kill us, makes us stronger.
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Sun Mar 11, 2007 2:22 am   
 
None of those examples actually match what Vijilante has suggested, though. His way works just fine:

#exec {%concat(":",@test,":#show blah")}

Highlighted part is optional.


Last edited by Fang Xianfu on Sun Mar 11, 2007 2:26 am; edited 1 time in total
Reply with quote
patryn
Apprentice


Joined: 26 Sep 2001
Posts: 124

PostPosted: Sun Mar 11, 2007 2:25 am   
 
Too true. That's what I get for not using copy paste :P
_________________
That which does not kill us, makes us stronger.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD General Discussion 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