|
forren Novice
Joined: 26 Apr 2007 Posts: 44
|
Posted: Sun Jul 01, 2007 6:04 pm
[1.34] #VAR, local variables, and data records |
Here's code that works:
#VAR possAffDB.%i 1
Here's code that doesn't work:
#VAR possAffDB.$aff 1
Using local variables instead of a regular wildcard somehow changes my data record into an autotyped array. I was able to use #addkey successfully with data records and local variables, so my problem is fixed for now, but this seems like a bug. |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Sun Jul 01, 2007 6:17 pm |
I don't know whether it's me that's on an implicit concat trip today or if it's everyone else, but this is another example of it, I think.
#var %concat("possAffDB.",$aff) 1
is working fine for me.
If you're using this for what I think you are (a database variable where keys are afflictions you have, or might have, and values are irrelevant) you might find it easier, at least for now, to use a string list. Database variables are currently implemented in exactly the same way as string lists and are no faster. This might change in the future when CMUD includes Lua scripting, since Lua tables use hashing, but for now it's no better and leads to problems like this one. |
|
|
|
Fuego Ledrey Wanderer
Joined: 09 May 2007 Posts: 64 Location: Dustin Acres, California
|
Posted: Sun Jul 01, 2007 6:20 pm |
Concat is a great feature, but if not using it results in a bug then shouldn't that be taken note of? Just a thought.
at Fang,
EDIT: Don't hate me. |
|
_________________ EDIT: Image moved to Avatar FINALLY. |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Sun Jul 01, 2007 6:25 pm |
Sometimes :P But Zugg has said in the past that for CMUD to compile scripts, it needs to be a bit more strict about syntax. One of the things that CMUD doesn't do like zMUD is this sort of implicit concatenation - I guess it's just because you haven't told the compiler what you want it to do and it's left guessing.
|
|
|
|
Fuego Ledrey Wanderer
Joined: 09 May 2007 Posts: 64 Location: Dustin Acres, California
|
Posted: Sun Jul 01, 2007 6:27 pm |
Makes perfect sense. I don't want the compiler left guessing when it's compiling my scripts, thanks for the advice, Fang.
|
|
_________________ EDIT: Image moved to Avatar FINALLY. |
|
|
|
forren Novice
Joined: 26 Apr 2007 Posts: 44
|
Posted: Sun Jul 01, 2007 8:16 pm |
This is not concat - this is another way to access entries in data records.
@dataRecord.keyname
I use %concat to concat. |
|
|
|
Fuego Ledrey Wanderer
Joined: 09 May 2007 Posts: 64 Location: Dustin Acres, California
|
Posted: Sun Jul 01, 2007 8:18 pm |
%concat will work in this situation though. It is a very useful function.
|
|
_________________ EDIT: Image moved to Avatar FINALLY. |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Sun Jul 01, 2007 9:10 pm |
forren wrote: |
This is not concat |
But it is. When you write "#var posAffDB.$aff" you mean for CMUD to expand the $aff variable and add the results to the end of the string and then reference the name that results. It's the difference between "#var $aff something" and "#var ($aff) something". |
|
|
|
forren Novice
Joined: 26 Apr 2007 Posts: 44
|
Posted: Sun Jul 01, 2007 9:16 pm |
Ah, I think I understand. Thanks for the help.
I've never used #VAR ($aff) before - what is the difference? |
|
|
|
Fuego Ledrey Wanderer
Joined: 09 May 2007 Posts: 64 Location: Dustin Acres, California
|
Posted: Sun Jul 01, 2007 9:48 pm |
It's just a different way of doing the same exact thing, my friend.
|
|
_________________ EDIT: Image moved to Avatar FINALLY. |
|
|
|
MattLofton GURU
Joined: 23 Dec 2000 Posts: 4834 Location: USA
|
Posted: Sun Jul 01, 2007 10:08 pm |
Quote: |
I've never used #VAR ($aff) before - what is the difference?
|
I'm not sure that it really matters in this case since I don't think #VAR allows you to assign to local variables, but the parentheses force evaluation (it's a shortcut for the %eval() function). So without parentheses you might be assigning a value to the temporary variable named aff, whereas with parentheses you are assigning a value to a persistent variable named whatever the value of $aff is. |
|
_________________ EDIT: I didn't like my old signature |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Sun Jul 01, 2007 10:49 pm |
Matt's explanation's exactly right - I've never used it that way with #var but it makes a difference to #addkey and #additem. Without brackets adds an item to the local variable itself.
|
|
|
|
|
|