|
Leitia Adept
Joined: 04 May 2007 Posts: 292 Location: Boston
|
Posted: Fri May 11, 2007 4:11 am
Impending Doom |
I just read: @VarName.@FieldName WILL NOT WORK! which I had found out to my dogged surprise.
I did manage to work this though: @{allactions.@{warflags.nextrun}} before I read that. I would not have persisted otherwise.
I am putting it out there, yell at me please if I am hazarding distaster. I am interested if anyone knows why this works. My #showdb @allactions has never worked though, and I did not concat anything. |
|
|
|
Leitia Adept
Joined: 04 May 2007 Posts: 292 Location: Boston
|
Posted: Fri May 11, 2007 4:41 am This looks better too |
%db( @allactions, @warflags.nextrun)
I taught myself to do code, so a lot of things I try imitations of other's techniques and my own odd implementation. My first attempt to use %db() had not worked, but at the time I did not know about the magical dodads which delimit key value pairs. Maybe that was it. Am glad I found this page on DB variables. I must have missed it. |
|
|
|
Arminas Wizard
Joined: 11 Jul 2002 Posts: 1265 Location: USA
|
Posted: Fri May 11, 2007 1:50 pm |
@{allactions.@{warflags.nextrun}}
Is an ok implementation, and perfectly legal. You are expanding and concatenating strings before you are trying to expand the full variable.
This is very different than the straight @var.@var2 that is marked WILL NOT WORK!
Here is why.
#addkey vVar {vKey1=vVal1}
#addkey vVar {vKey2=vVal2}
#addkey wVar {wKey1=vKey1}
#addkey wVar {wKey2=vKey2}
When you do @Vvar.@wVar this is what zMud sees.
vKey1|vVal1[]vkey2|vVal2.wKey1|vKey1[]wKey2|vKey2
And does not know what to do with it.
The above [] stand for a control code that I don't think the forums would like so I substituted it for something that looks like a square.
If you use the {} the way you did above a lot more goes on behind the scenes.
@{vVar.@{wVar.wKey1}}
Think of math. In math you do the inner set of braces first. The @ before the {} tells zMud that the results, @wVar.wKey1, need to be expanded right away. So you get vKey1.
Next you have the outer set of braces and they see this vVar.vKey1. There is a @ before the {} so now it expands the results of @vVar.vKey1 and you get vVal1.
String lists for the second variable work much the same way. |
|
_________________ Arminas, The Invisible horseman
Windows 7 Pro 32 bit
AMD 64 X2 2.51 Dual Core, 2 GB of Ram |
|
|
|
Leitia Adept
Joined: 04 May 2007 Posts: 292 Location: Boston
|
Posted: Sun May 13, 2007 12:24 am Thanks |
I like things much better when I know what they are doing. The working of the computer are as much fun as the mud sometimes, today my mind shouted in a heroic voice, "This looks like a job for @Paramit!"
|
|
|
|
|
|