 |
TGH Beginner
Joined: 22 Nov 2025 Posts: 18
|
Posted: Mon Mar 30, 2026 9:08 am
Adding path to variable |
What am I doing wrong that I cannot get a variable path added to a local variable?
| Code: |
// fmob $MOB $area
// Find a MOB in an area. If no area given use current area.
#LOCAL $zone
$MOB=%1
#SWITCH (%numparam())
(0) {
#WIN MobLocation "MOB is mandatory."
#WIN MobLocation " "
#WIN MobLocation "USAGE: fmob MOB [zone]"
#WIN MobLocation "Current zone used if not specified."
#EXIT
}
(1) {
$zone=%gmcp.room.info.zone
}
(2) {
$zone=%2
}
$roomNums=%dbkeys(@MOBDB_VARS/$zone)
#FORALL $roomNums {
#IF (%isvalue(%i,$MOB)) {
#WIN MobLocation " "
#WIN MobLocation $MOB "is in room" %i
#EXIT
}
} |
I have tried
@MOBDB_VARS/$zone
@{MOBDB_VARS/$zone}
@MOBDB_VARS/{$zone}
@MOBDB_VARS/${zone}
%concat(classpath,"/",$zone)
but nothing produces a working result.
Any suggestions? |
|
|
|
 |
shalimar GURU

Joined: 04 Aug 2002 Posts: 4797 Location: Pensacola, FL, USA
|
Posted: Tue Mar 31, 2026 10:28 pm |
Have you tested that any of your local variables have a value, much less the correct one, with #ECHO #SAY or #PRINT?
if $zone itself is null you will get a false negative result even with correct syntax. |
|
|
|
 |
shalimar GURU

Joined: 04 Aug 2002 Posts: 4797 Location: Pensacola, FL, USA
|
Posted: Tue Mar 31, 2026 10:31 pm |
and try: %db(@mobdb_vars, $zone)
|
|
|
|
 |
TGH Beginner
Joined: 22 Nov 2025 Posts: 18
|
Posted: Thu Apr 02, 2026 6:38 pm |
MOBDB_VARS is a class note a variable and $zone will reference either current zone or a supplied zone.
Eg.
MOBDB_VARS/aardington
MOBDB_VARS/siege
each zone var will consist of room numbers (keys) and each room will have mobs I encountered (stringlist) |
|
|
|
 |
shalimar GURU

Joined: 04 Aug 2002 Posts: 4797 Location: Pensacola, FL, USA
|
Posted: Tue Apr 07, 2026 1:49 pm |
Its not a matter of what the value should be.
In an ideal world things are always what they should be.
Testing is to verify that it is what it should be. |
|
|
|
 |
shalimar GURU

Joined: 04 Aug 2002 Posts: 4797 Location: Pensacola, FL, USA
|
Posted: Tue Apr 07, 2026 1:52 pm |
as to the pathing issue, local variables dont have a path, they are stored in memory and only exisit within the code block they are called from, as soon as the relevant } is parsed, they are thrown away.
so trying to use a path at all is improper |
|
|
|
 |
TGH Beginner
Joined: 22 Nov 2025 Posts: 18
|
Posted: Thu Apr 23, 2026 7:07 pm |
Maybe you got it wrong as I may have worded it badly.
I have a variable ($zone) made from %gmcp.room.info.zone which I want to add to the classpath zoneX to make zoneX/$zone. Then search each dbvar in the classpath (zoneX/$zone/dbvar) to locate a mob value in one of the vars. |
|
|
|
 |
shalimar GURU

Joined: 04 Aug 2002 Posts: 4797 Location: Pensacola, FL, USA
|
Posted: Sun Apr 26, 2026 5:19 pm |
If it is a standalone variable, then your issue is syntax
$ = local variable, required for referencing and declaring
@ = normal variable, only used to reference, not to define
to define it in a zone you can do:
#VAR zone {%gmcp.room.info.zone} {} {zoneX}
then you can reference it with: @zoneX/zone |
|
|
|
 |
|
|
|