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


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: Wed Mar 11, 2009 8:46 pm   

[3.04 Bug] ansi variables and xml will not copy/paste
 
This probably happens in earlier versions, though I never really attempted to verify because I hadn't noticed this until when I tried to copy a database variable to a friend's computer.

1. #VAR test {%ansi(red)abcd}
2. Open package editor.
3. Select the variable, then copy using right-click/copy or Ctrl+C.
4. Go ahead and delete the variable.
5. Try pasting the copied text. It will come up with an error.

If you look at the xml code, you'll see where the ansi is, it's horrible, and won't conform to xml standard. My guess is that the escape codes aren't recognized or being properly parsed.

If I'm doing something wrong, please let me know. It sucks when you have a database that holds a lot of information copied only to find out you no longer can paste it. I don't know if there is something that can be done, though, and I haven't tested it with export/import yet. If no answers before I get home, I'll test it then.

Charneus
Reply with quote
Zugg
MASTER


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

PostPosted: Wed Mar 11, 2009 9:26 pm   
 
In general, variables do not support storing control codes like that. It's also possible that when these control codes are saved to the database that there might be problems. So it might not just be an XML issue. Variables are meant to hold string values and not control code. But I'll add it to the bug list to look at in the future.

Export/Import will have the same problem since it uses the same XML format as the copy/paste
Reply with quote
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: Wed Mar 11, 2009 9:50 pm   
 
I figured it would, but wasn't sure.

As far as control codes and variables go, I suppose I could write a function to colorize the outptut the way I want it to be, probably a regex of some sort. Thanks for the info regarding this, though. I'm glad it will be on the bug list, though.

Charneus
Reply with quote
Zugg
MASTER


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

PostPosted: Wed Mar 11, 2009 10:00 pm   
 
Actually, I just looked into this and I can't get it to fail. The XML encoding is working fine for control codes. If I type your example on the command line:

#VAR test {%ansi(red)abcd}

and then open the settings editor, click on the "test" variable, and look in the XML tab, it properly shows:

Code:
<var name="test" type="String" id="2">abcd</var>


which shows the proper encoding for the ESC character. If I right-click on "test" in the tree view and select Copy, and then delete it, and then right-click and Paste, it works fine without any error.

The only real problem with the control code is that when you have the normal "Text" tab selected, the ESC character will show as a little left-pointing arrow. And other control characters might not display in the normal Text view if they are not printable characters. But the data is there and the XML is fine.

You need to tell me exactly what error message you are getting since I cannot reproduce your problem.
Reply with quote
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: Thu Mar 12, 2009 2:41 am   
 
Interesting. It only appears to be this certain database...

Code:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<cmud>
  <var name="raceresists" type="Record" copy="yes"><![CDATA[Centaur="Resists: Pierce (116)
Vulns: Bash (-76) Fire (-32)"]]></var>
</cmud>



When I do that, it tells me invalid XML character at line 3, col 71, so I'm not sure what's going on here... hmmm.

Charneus

To get the above database, use this:
Code:

#ADDKEY raceresists Centaur {%ansi( high, green)"Resists: Pierce ("%ansi( Bright, cyan)"116"%ansi( high, green)")"%cr%ansi( high, red)"Vulns: Bash ("%ansi( Bright, cyan)"-76"%ansi( high, red)") Fire ("%ansi( Bright, cyan)"-32"%ansi( high, red)")"}
#ADDKEY raceresists Drow {%ansi( high, Green)"Resists: Negative ("%ansi( Bright , cyan)"156"%ansi( high, Green)") Shadow ("%ansi( Bright , cyan)"124"%ansi( high, Green)") Disease ("%ansi( Bright , cyan)"28"%ansi( high, Green)") Poison ("%ansi( Bright , cyan)"36"%ansi( high, Green)")"%cr%ansi( high, red)"Vulns: Light ("%ansi( Bright , cyan)"-236"%ansi( high, red)") Holy ("%ansi( Bright , cyan)"-136"%ansi( high, red)") Water ("%ansi( Bright , cyan)"-68"%ansi( high, red)")"}


Edited above to make things a bit more simpler.


Last edited by charneus on Thu Mar 12, 2009 3:15 am; edited 2 times in total
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Thu Mar 12, 2009 2:59 am   
 
Examining both your code and the produced variable I see a mismatched quote on this line:
Code:
#ADDKEY raceresists Eldar {%ansi( high, Green)"Resists: All ("%ansi( Bright , cyan)"+28"%ansi( high, Green)") except Bash ("%ansi( Bright , cyan)"0"%ansi( high, Green)") and Pierce ("%ansi( Bright , cyan)"0"%ansi( high, Green)")%cr%ansi( high, red)"Vulns: Slash ("%ansi( Bright , cyan)"-168"%ansi( high, red)") Disease ("%ansi( Bright , cyan)"-116"%ansi( high, red)") Poison ("%ansi( Bright , cyan)"-92"%ansi( high, red)")"}

It should be
Code:
#ADDKEY raceresists Eldar {%ansi( high, Green)"Resists: All ("%ansi( Bright , cyan)"+28"%ansi( high, Green)") except Bash ("%ansi( Bright , cyan)"0"%ansi( high, Green)") and Pierce ("%ansi( Bright , cyan)"0"%ansi( high, Green)")"%cr%ansi( high, red)"Vulns: Slash ("%ansi( Bright , cyan)"-168"%ansi( high, red)") Disease ("%ansi( Bright , cyan)"-116"%ansi( high, red)") Poison ("%ansi( Bright , cyan)"-92"%ansi( high, red)")"}


The related portion of the XML which seems to be the problem
Code:
Eldar="Resists: All (+28) except Bash (0) and Pierce (0"")%cr%ansi( high, red)""Vulns: Slash (""%ansi( Bright , cyan)""-168""%ansi( high, red)"") Disease (""%ansi( Bright , cyan)""-116""%ansi( high, red)"") Poison (""%ansi( Bright , cyan)""-92""%ansi( high, red)"")"""


This seems to be replicated further in the variable and I am not about to check all the relevant code lines against the variable to determine which are possible problems.
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: Thu Mar 12, 2009 3:19 am   
 
I simplified the above because it turns out just one line is all that's needed to replicate this.

Thanks for pointing out the missing quotes, though. I went through and found about 4 others I had missed. However, even getting it down to the barebones, I still have the problem, and this one is quoted out perfectly.

I thought it might be that the values were not holding quotes, so I doubled up the quotes so that the value would contain them. Still didn't work.

Charneus
Reply with quote
Zugg
MASTER


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

PostPosted: Thu Mar 12, 2009 4:57 pm   
 
I'll add this to the bug list, but what you are doing is a *really* bad idea. It's bad enough putting control characters into variables, but now you are storing control characters into hashed string list database variables?? All variables must be stored as plain string values to be stored into the database. So database variables are stored as "key1=value1|key2=value2|...etc". When CMUD reads a database variable from the database, it gets this string value and then has to parse it to create the hash table for the key/value lookup. This is when CMUD parses for quotes, the | delimiter, and the = delimiter. Adding control characters to the mix adds even more complications. These string lists were never designed to hold control characters.

You really just need to convert your script to use MXP colors instead of ansi colors. That will allow you to use even more different colors and gets away from all of the control code issues.

As I said, I'll still add this to the bug list, but this problem is so specific to your scripts that it's not something the vast majority of users will even encounter. So it's not going to be a big priority unless it turns out to be a trivial fix.
Reply with quote
gamma_ray
Magician


Joined: 17 Apr 2005
Posts: 496

PostPosted: Thu Mar 12, 2009 6:06 pm   
 
Hey Zugg, I haven't ever actually experienced this problem, but I do definitely store ANSI stuff in variables (sometimes even db vars). Imperian uses colors to differentiate between different kinds of messages, so for example:

<grey>line of room description
<grey>continuation of room description
<grey>continuation of room description
<grey>continuation of room description <pink>written description of items in the room
<pink>continuation of items
<pink>continuation of items <brown>special notes about the room

And so on. Since nothing is guaranteed (any section may start on the previous line of another section, and you may have any number of lines per section) I just grab every line from the last line that I know (the room name) until the next prompt, store it all in a variable, and then parse through the variable to get the things I want, formatted how I want.

Anyway, just sayin' it's used for things.
Reply with quote
gamma_ray
Magician


Joined: 17 Apr 2005
Posts: 496

PostPosted: Thu Mar 12, 2009 6:08 pm   
 
P.S. I am deep in a Java project at the moment, and it just struck me that what CMud really needs is a profiler for scripts. With pretty graphs, like NetBeans uses.
Reply with quote
Zugg
MASTER


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

PostPosted: Thu Mar 12, 2009 6:25 pm   
 
Dream on.

Sorry, but for a one-person project that only costs $30, you are already getting more functionality and value than with most any other software I can think of. Give me millions of customers like Java has, with businesses who are willing to pay for support for open-source software (like NetBeans, Eclipse, etc), with hundreds of developers to help write the code, and then we can talk.

Back on the original topic: All I was saying is that storing control codes is generally a bad idea, and you might encounter problems. It might work fine for you and what you are doing, but obviously Charneus ran into a problem with the xml import/export that you might not have been doing. This is just a case of people using a feature in CMUD for something that it wasn't designed or intended to handle, so you might run into issues with it.
Reply with quote
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: Thu Mar 12, 2009 10:37 pm   
 
Hmmm... I should have learned by now with the %ansi and mxp stuff. *shrug*

I guess I just get lazy at times and then forget about mxp, especially since I have to have the closing tag on it. Thanks for pointing that out, though. I'll definitely be rewriting some scripts now.

Charneus
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