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


Joined: 25 Mar 2003
Posts: 1113
Location: USA

PostPosted: Thu Jun 15, 2006 7:09 pm   

[1.01] Variable path specifications
 
I decided to see if I could reference a variable in a specific package and/or class folder. I'm finding that the @/path/var syntax does not produce the expected results. The migration guide gives examples of using #VAR /path/var value to set the value, but there is no mention of how to retrieve a value using a full path specification.

1. In a package named Testing, I made a variable "blah" with value 42.
2. In a package named Tester, I made another variable named "blah" with value 56.
3. In Tester, I made an alias "showblah" to display the values of both variables. It simply does #show "Value is "@/Tester/blah" and also "@/Testing/blah.

From that, I get the output "Value is and also " with no numbers at all. If I just use @blah, I get the value from @Testing, even though the alias is in Tester and there's a variable right beside it there.

Interestingly, the compiled code for the alias looks like this:

Code:
0000   LINE   0   ; #say "Value is "@/Tester/blah" and also "@/Testing/blah
0012   LITERAL   "Value is "
0040   VARREF   @/Tester/blah <?>   (class Testing)   
0072   CONCAT   
0076   LITERAL   " and also "
0104   CONCAT   
0108   VARREF   @/Testing/blah <?>   (class Testing)   
0140   CONCAT   
0144   CMD   say   (1)


No matter what sort of path I try for the variable reference, it always seems to want to reference it in my Testing package (the default package for my Testing session).
Reply with quote
edb6377
Magician


Joined: 29 Nov 2005
Posts: 482

PostPosted: Thu Jun 15, 2006 8:59 pm   
 
Testing with the following structure
PACKAGE -> Default Settings
PACKAGE -> Tracker
ALIAS -> Testing
SUBFOLDER ------->Extender
PACKAGE -> Untitled
Code:

#var /test %1
#var ./test %2
#var /extender/test %3
#var ./untitled/test %4
#show "Current Test "@/test
#show "Root Test "@./test
#show "Current Sub "@/extender/test
#show "Root Sub "@./untitled/test


Testing 4 3 2 1

4 is the tracker package var
3 is the value of test in untitled.
2 is the extender sub folder
1 doesnt set at all it seems

Shows
Code:

Current Test 3
Root Test 3
Current Sub 2
Root Sub


it would appear sub folder under the current class work just fine.
however anything involving the root doesnt properly return to the root of the entire structure. so package calls dont work properly. Root seems to take you to the root of the package. ill play with this more and see what else i can come up with.
Reply with quote
Larkin
Wizard


Joined: 25 Mar 2003
Posts: 1113
Location: USA

PostPosted: Fri Jun 16, 2006 12:41 pm   
 
I think you have the current and root path syntaxes backwards, though it doesn't mean the code works as it should, obviously. The old way was to use . for the root, which is not the standard UNIX way to specify a path. CMUD now uses . for the current folder and / for the root folder.

If your Extender folder is in the Tracker package, shouldn't you have to use @/Tracker/Extender/test to access the variable? I'm not sure if package names are used in the full path or not, but I would expect it to work that way. It would make things a lot easier when designing packages that rely on other packages.
Reply with quote
edb6377
Magician


Joined: 29 Nov 2005
Posts: 482

PostPosted: Fri Jun 16, 2006 6:37 pm   
 
its an old test i used for zmud still use it to make sure certain variables get set properly.
./varname references the varname in the current class and /varname references the varname in the root class now.

Now as to the other part of your message. I am hoping this is something zugg will address.

To me it should be

<ROOT>
-------> Package
-----------> Class/sub package etc.

so yes to me it should be the way you say as well. However right now it appears that it only lives the current default package not as it should be. It doesnt seem to be doing that right now. Hopefully zugg can take a look and make better definement of how that should work as i will use it a lot as well.
Reply with quote
chris-74269
Magician


Joined: 23 Nov 2004
Posts: 364

PostPosted: Fri Jun 16, 2006 9:30 pm   
 
i figure i would post this in something about variables. it seems that my aliases that would set variables no longer work, such as: #alias find1 {#var lrooms {};#var prooms {};...} and so on. I get an error about this
Reply with quote
Larkin
Wizard


Joined: 25 Mar 2003
Posts: 1113
Location: USA

PostPosted: Fri Jun 16, 2006 10:45 pm   
 
I would typically use the #var name {} syntax to clear variables, too. CMUD seems to only accept the #var name "" syntax. Not sure yet if that's a bug or a feature of the stricter scripting engine.
Reply with quote
Zugg
MASTER


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

PostPosted: Wed Jul 05, 2006 7:18 pm   
 
Right now, variables can only be referenced within their own package. In other words, @/classname/varname ... there isn't any way to reference variables in another package yet.

In general, packages are supposed to be self-contained...you are not supposed to need to specifically reference something in another package. However, I can certainly see the need for this, so I'll try to think of a way to handle this.

But there is a compatibility issue with zMUD stuff to deal with since zMUD didn't have packages.
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