|
charneus Wizard
Joined: 19 Jun 2005 Posts: 1876 Location: California
|
Posted: Wed Jan 26, 2011 11:54 am
[3.33a]BUG: %literal not working properly |
According to %stripq KB, you should be able to do:
Code: |
a=123
#FUNC test {%literal(%1)}
#SHOW @test("@a"@a"@a")
|
and expect it to return:
Despite the obvious "error" in that it should be #RETURN %literal(%1), the coding does NOT work as described. Instead, it returns, literally, %1.
This presents a problem as we can't really use %literal in any scripting syntax because normally, parameters are used. It's been a problem for ages now, but I hadn't realized it was a bug (just honestly thought it was a useless function) until I read the %stripq help file. Yes, I do know that %literal does state it returns without expansion or evaluation... but then these two contradict themselves...
Please fix! Thanks! |
|
|
|
Rahab Wizard
Joined: 22 Mar 2007 Posts: 2320
|
Posted: Wed Jan 26, 2011 2:12 pm |
That documentation is old. It is referring to the old #FUNC command, which has been renamed #VARFUNC. Try it with #VARFUNC. Zugg will have to tell us whether that is supposed to work with the new #FUNC command. And I guess the documentation needs to be corrected. At first glance, it does appear that %literal is not working correctly.
|
|
|
|
charneus Wizard
Joined: 19 Jun 2005 Posts: 1876 Location: California
|
Posted: Wed Jan 26, 2011 3:47 pm |
Yeah, #FUNC has nothing to do with the issue, to be honest, and the documentation came directly from the CMUD help database (which I realize may not be completely up-to-date). I was just using that as reference in there.
There's no need to try %literal with anything else, since it simply will not return what should be proper. |
|
|
|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Wed Jan 26, 2011 6:22 pm |
Yeah, the documentation is wrong. Using %literal is like putting " quotes around it. So %literal(%1) is the same as "%1".
Also, the syntax in your #SHOW command is wrong. If you want to put a " within an existing quote, you need to double it. So the correct line would be:
Code: |
#SHOW @test("@a""@a""@a") |
|
|
|
|
charneus Wizard
Joined: 19 Jun 2005 Posts: 1876 Location: California
|
Posted: Wed Jan 26, 2011 10:31 pm |
What is the point of %literal, then? What scripting purpose does it have? Obviously cannot capture something and have it literal, so I'd have to do a %replace to replace " with "". Just curious on this.
|
|
|
|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Thu Jan 27, 2011 6:34 pm |
It's a left-over from zMUD I think. I never use it myself.
|
|
|
|
|
|