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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
Leitia
Adept


Joined: 04 May 2007
Posts: 292
Location: Boston

PostPosted: 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.
Reply with quote
Leitia
Adept


Joined: 04 May 2007
Posts: 292
Location: Boston

PostPosted: 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.
Reply with quote
Arminas
Wizard


Joined: 11 Jul 2002
Posts: 1265
Location: USA

PostPosted: 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
Reply with quote
Leitia
Adept


Joined: 04 May 2007
Posts: 292
Location: Boston

PostPosted: Sun May 13, 2007 12:24 am   Thanks
 
I like things much better when I know what they are doing. Surprised 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!"
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD 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