|
xekon Apprentice
Joined: 11 Oct 2007 Posts: 154
|
Posted: Sun Dec 02, 2007 4:13 am
HELP, Variable which Points to another Variable, Pointer issue, overwriting |
I have a Variable (VAR-@currentzone) that within it contains the name of another Variable (VAR-B) @home, @shop, @farming, etc. depending on where i am.
When I read from VAR-@currentzone I get the contents of VAR-B which is PERFECT!
This is exactely what i wanted, basically a pointer.
The following works PERFECTLY as I intended (loops through the contents of VAR-B and checks for a match):
#LOOPDB @currentzone {
#IF (%item( @testlist, 1)==%key) {#echo Exists} {#echo DONT exist}
}
The problem comes when I try to WRITE to the variable which I am pointing to, instead it copies the data of VAR-B into VAR-@currentzone, and then adds the data to VAR-@currentzone
what I want is to simply add the data to VAR-B, VAR-@currentzone is supposed to be simply a pointer.
Below is the code im having trouble with (I want to add some data to VAR-B):
additem=%1
#if (%yesno( Add @additem to VAR-B?)) {
#PROMPT keyword {what keyword would you like to use?}
currentzone=%addkey( @currentzone, @additem, @keyword)
#echo item added
} {
#echo Chose not to add
} |
|
|
|
xekon Apprentice
Joined: 11 Oct 2007 Posts: 154
|
Posted: Sun Dec 02, 2007 4:21 am |
After looking it over its obvious that the problem is with the following line:
currentzone=%addkey( @currentzone, @additem, @keyword)
this is a over writing the currentzone contents with the contents of what it is pointing to and adding to it. somehow I need to do something crafty that makes it work the way i inteded.
Depending on what im doing i only want to access certain lists..... which is why i made a pointer, that way i have the pointer point at the particular list I want to work with, currently I have each list in different folders and have to manually disable all of them then just enable one.
so for an example if i were exploring I would do the following:
#T- home
#T- shop
#T- farming
#T+ exploring
this is very inneficient and as i get more lists will get simply retarded, however with a pointer variable (@currentzone).
all i have to do is set @currentzone to the list i want to work with
like so:
currentzone=~@exploring |
|
Last edited by xekon on Sun Dec 02, 2007 8:28 pm; edited 1 time in total |
|
|
|
xekon Apprentice
Joined: 11 Oct 2007 Posts: 154
|
Posted: Sun Dec 02, 2007 9:36 am |
Ide use any possible workaround or anything.... i just cant figure it out.... ive tried making a variable named currentzone2 that stores thename of the variable without the @ symbol
currentzone contents are VAR-B ( @home, @shop, @farming, etc. depending on where i am. )
currentzone2 contents are the shortname ( home, shop, farming, etc. depending on where i am. )
currentzone2=%addkey( @currentzone, @additem, @keyword)
this doesnt work either, maybe there is a way i can copy contents or something... there has to be a way to add to the variable that im trying to point to. |
|
|
|
Guinn Wizard
Joined: 03 Mar 2001 Posts: 1127 Location: London
|
Posted: Sun Dec 02, 2007 11:51 am |
I'm not sure why you're trying to add it to @currentzone. Why not just add the value to the sublist.
So that the variable doesn't automatically expand I'd be tempted to remove the @ from within your pointer list
list1 = list1a|list1b|list1c
list2 = list2a|list2b|list2c
masterList = list1|list2
you could still loop then using
Code: |
#FORALL @masterList {
#LOOPDB %eval(@%i) {
#IF (%item( "list1a", 1)==%key) {
#echo Exists} {
#echo Doesn't Exist
}
}
} |
Then when you want to add you'd have the name of the current list in %i of the #FORALL loop, and could add to that list using %eval(@%i) |
|
_________________ CMUD Pro, Windows Vista x64
Core2 Q6600, 4GB RAM, GeForce 8800GT
Because you need it for text... ;) |
|
|
|
xekon Apprentice
Joined: 11 Oct 2007 Posts: 154
|
Posted: Sun Dec 02, 2007 8:26 pm |
Well depending on what im doing i only want to access certain lists..... which is why i made a pointer, that way i have the pointer point at the particular list I want to work with, currently I have each list in different folders and have to manually disable all of them then just enable one.
so for an example if i were exploring I would do the following:
#T- home
#T- shop
#T- farming
#T+ exploring
this is very inneficient and as i get more lists will get simply retarded, however with a pointer variable (@currentzone).
all i have to do is set @currentzone to the list i want to work with
like so:
currentzone=~@exploring |
|
|
|
Guinn Wizard
Joined: 03 Mar 2001 Posts: 1127 Location: London
|
Posted: Sun Dec 02, 2007 9:18 pm |
If I understand right then my example should work. strip the @ from the names of each list inside currentzone (currentzone = exploring) then use the code in my first post to cycle through the items.
|
|
_________________ CMUD Pro, Windows Vista x64
Core2 Q6600, 4GB RAM, GeForce 8800GT
Because you need it for text... ;) |
|
|
|
|
|