 |
Rahab Wizard
Joined: 22 Mar 2007 Posts: 2320
|
Posted: Sat Jun 05, 2010 3:20 pm
[3.18d] Converting old nested db variables |
I have some old database variables which contained string lists as values, created under 3.17 or earlier. My scripts were set up to add new items to the string lists, and display them in a convenient manner. After upgrading to 3.18d, I found that the scripts did not work any more. The values were no longer recognized as string lists. So I wrote up the following script to convert them:
Code: |
<alias name="convertdb" id="288">
<value>#local $db $value
$db = %eval(%concat("@",%1))
#forall (%dbkeys($db)) {
$value = %db($db,%i)
#addkey $db %i %list($value)
}
#var %1 $db
</value>
</alias>
|
If you have a db variable named @keyword, then "convertdb keyword" will convert it to the new format. My scripts appear to be working great now. I'll continue testing over the weekend.
Zugg, I'm not sure whether you intended old db variables containing string lists to be converted automatically. If you didn't, I don't mind. I knew when I wrote these scripts that I was doing something that wasn't supported, and I'm happy to convert them myself. (Thanks for the %list() function!). But at the least, I want to let other people know about this potential issue, and a solution. |
|
|
 |
Zugg MASTER

Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Sat Jun 05, 2010 4:41 pm |
Actually, the new version should have converted your old nested lists correctly if they were properly formed with quotes in the write places. It worked for mine here, but post the exact XML of the variable that didn't convert so I can look at it.
Btw, the better way to do the third line instead of the %eval is just:
$db = @{%1} |
|
|
 |
charneus Wizard

Joined: 19 Jun 2005 Posts: 1876 Location: California
|
Posted: Sat Jun 05, 2010 5:01 pm |
Yeah, I reported this issue when I found out about it in an earlier post.
The problem is, if this was intended, I have over 300 db variables that need to be converted, and I shouldn't be forced to do a workaround for each one...
Thanks for the script, though!
Charneus |
|
|
 |
Zugg MASTER

Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Sat Jun 05, 2010 5:10 pm |
As I said above, please post the XML of the *original* (old version) db variables that are not getting converted properly so I can test them here to fix this.
|
|
|
 |
charneus Wizard

Joined: 19 Jun 2005 Posts: 1876 Location: California
|
Posted: Sat Jun 05, 2010 5:49 pm |
Code: |
<?xml version="1.0" encoding="ISO-8859-1" ?>
<cmud>
<var name="casevalues" type="Record" json="true" copy="yes">{"lowgamemyst":"?:25|?:50|?:100|?:200|?:300|?:400|?:500|?:750|?:1000|?:5000|?:7500|?:10000|?:25000|?:50000|?:75000|?:100000|?:200000|?:300000|?:400000|?:500000|?:750000|?:1000000|?:2000000|?:3000000|?:4000000|?:5000000","lowgame":"25:25|50:50|100:100|200:200|300:300|400:400|500:500|750:750|1,000:1000|5,000:5000|7,500:7500|10,000:10000|25,000:25000|50,000:50000|75,000:75000|100,000:100000|200,000:200000|300,000:300000|400,000:400000|500,000:500000|750,000:750000|1,000,000:1000000|2,000,000:2000000|3,000,000:3000000|4,000,000:4000000|5,000,000:5000000","midgame":"1:1|100:100|250:250|500:500|750:750|1,000:1000|2,500:2500|5,000:5000|7,500:7500|10,000:10000|25,000:25000|50,000:50000|75,000:75000|100,000:100000|200,000:200000|300,000:300000|400,000:400000|500,000:500000|750,000:750000|1,000,000:1000000|2,000,000:2000000|3,000,000:3000000|4,000,000:4000000|5,000,000:5000000|7,500,000:7500000|10,000,000:10000000","qpgame":"1:1|2:2|5:5|10:10|25:25|50:50|75:75|100:100|150:150|200:200|250:250|300:300|350:350|400:400|450:450|500:500|550:550|600:600|650:650|700:700|750:750|800:800|850:850|900:900|950:950|1,000:1000","highgame":"1:1|100:100|250:250|500:500|750:750|1,000:1000|2,500:2500|5,000:5000|7,500:7500|10,000:10000|20,000:20000|40,000:40000|50,000:50000|75,000:75000|100,000:100000|250,000:250000|500,000:500000|1,000,000:1000000|2,000,000:2000000|3,000,000:3000000|5,000,000:5000000|7,500,000:75000000|10,000,000:10000000|15,000,000:15000000|20,000,000:20000000|25,000,000:25000000","default":"1:1|3:3|5:5|10:10|25:25|50:50|75:75|100:100|200:200|300:300|400:400|500:500|750:750|1,000:1000|5,000:5000|10,000:10000|25,000:25000|50,000:50000|75,000:75000|100,000:100000|200,000:200000|300,000:300000|400,000:400000|500,000:500000|750,000:750000|1,000,000:1000000"}</var>
</cmud>
|
Here's one instance of a dbvariable that didn't get converted properly.
Charneus |
|
|
 |
Rahab Wizard
Joined: 22 Mar 2007 Posts: 2320
|
Posted: Sat Jun 05, 2010 7:52 pm |
Here is one instance of mine:
Code: |
<var name="keywords" type="Record" sorted="true" json="true" id="287">{"blocky piece of dark stone":"basalt","blocky piece of grey stone":"granite","fleshy, faded-orange fruit":"kutai","hand-sized chunk of dark stone":"basalt","hand-sized chunk of grey stone":"granite","hand-sized chunk of red stone":"jasper","handful of aromatic seeds":"sivifi","handful of deep-red leaves":"makras","handful of thick-shelled nuts":"cunyati","head-sized chunk of dark stone":"basalt","head-sized chunk of grey stone":"granite","head-sized chunk of red stone":"jasper","large chunk of rock":"granite","long, segmented tail":["rat","tusk"],"lopsided yellow fungus":"opsala","rough chunk of bluish rock":"turquoise","round hunk of grey stone":"granite","shriveled black fruit":"kaya","small grey hide":"rat","small shimmering skin":"jozhal","small strip of meat":"rat","small, curved tusk":"rat","small, shimmering skin":"jozhal","sprig of blue-green leaves":"arunca","tan strip of hide":"chalton","veiny, deep-red root":"bloodroot"}</var> |
Note that in this case, only one value happens to be a stringlist, but in other cases I've found, almost all of the values were stringlists.
The following commands show the problem:
Code: |
#show %item(%list(%db(@keywords,"long, segmented tail")),1)
#show %item(%db(@keywords,"long, segmented tail"),1)
|
|
|
|
 |
Zugg MASTER

Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Sat Jun 05, 2010 7:56 pm |
Quote: |
Here's one instance of a dbvariable that didn't get converted properly. |
I need to see the XML generated by the *old* version of CMUD. The one you posted has the "json=true" attribute, so it was generated by 3.18.
Same problem with the example from Rahab. |
|
|
 |
charneus Wizard

Joined: 19 Jun 2005 Posts: 1876 Location: California
|
Posted: Sat Jun 05, 2010 8:17 pm |
The following is one that did not get converted over properly. This is from 3.17.
Code: |
<?xml version="1.0" encoding="ISO-8859-1" ?>
<cmud>
<var name="Portals" type="Record" sorted="true" copy="yes">Adaldar="Permanent Peace|1|bag1|150|0|1|43645"|Aiighialla="teleport device denali|1|bag1|140|0|1|40037"|AllinaFaykeDay="Wizards Prism|1|bag1|10|0|1|40269"|AmazonNation="queen melosa mirror|1|bag1|100|0|1|4137"|Angband="black darkness angband|1|bag1|130|0|1|12099"|ArisianRealm="arisian portal dolphin|1|bag1|150|0|1|15189"|ArtificersMayhem="compendium fal shara royal history q6|1|bag1|180|0|1|12424"|AstralPlanes="strange metal amulet planes|1|bag1|25|0|1|42854"|AylorianAcademy="academy portal|1|bag1|1|0|1|42362"|BlackLagoon="black lagoon pendant|1|bag1|160|0|1|12518"|CallofHeroes="aura sage portal whirlwind vortex|1|bag1|5|0|1|41344"|Casino="chip poker|1|bag1|90|0|1|9737"|Cataclysm="golden crown laurels victor|1|bag1|147|0|1|9280"|CougarianQueendom="trust cowlina cougarian|1|bag1|100|0|1|16450"|Crecall="vortex light Charneus|1|bag1|1|0|1|45680"|DarkElf="glowing sphere enchanted dreams|1|bag1|75|0|1|9971"|DarkLight="orb star|1|bag1|85|0|1|6884"|Deadlights="Seal Timeless Ages serpents dimensional infinitely|1|bag1|160|0|1|8802"|DeathGate="entrance death gate|1|bag1|180|0|1|11315"|Deneria="mirror deneria past|1|bag1|70|0|1|43399"|DesertDoom="Desert Doom|1|bag1|141|0|1|14136"|DesertPrison="gate rune|1|bag1|130|0|1|10498"|DiamondReach="heliodor shard portal|1|bag1|60|0|1|9150"|DrageranAudience="ornate scroll royal audience|1|bag1|142|0|1|8525"|DrageranBackstage="backstage pass|1|bag1|132|0|1|8502"|DragonMountain="dragon amulet warding|1|bag1|98|0|1|9329"|DreadTower="Broken Curse|1|bag1|140|0|1|13449"|Dune="Muad'dib's thoughts visions|1|bag1|152|0|1|7094"|EighteenthDynasty="Hatshepsut cartouche|1|bag1|120|0|1|12700"|Entropy="lemniscate|1|bag1|121|0|1|40066"|EternalAutumMap="map woods eternal map_woods_autumn|1|bag1|170|0|1|40215"|Falcovnia="crystal ball|1|bag1|98|0|1|6033"|Fens="dreary hole despair|1|bag1|200|0|1|17281"|FlyingCitadel="majestic orb|1|bag1|50|0|1|13469"|GiantsPetStore="employee entrance pet collar|1|bag1|10|0|1|40870"|Gilda="Sir Lauren Despair|1|bag1|120|0|1|2489"|GladiatorsArena="lifetime pass gladiator arena|1|bag1|80|0|1|28783"|GoblinFortress="portal hopefully Goblin warplans|1|bag1|60|0|1|13966"|GoldRush="train ticket|1|bag1|42|0|1|2443"|Hades="golden obol hadesportal|1|bag1|190|0|1|13294"|Helegear="ice portal helegear gvozd|1|bag1|130|0|1|41416"|Horath="dragon amulet warding|1|bag1|98|0|1|9329"|HouseofCardsTrump="card benedict trump portal|1|bag1|100|0|1|43727"|Illoria="sigul illoria|1|bag1|60|0|1|16529"|ImmortalHomes="amulet aardwolf (294217)|1|bag1|1|0|1|13299"|ImperialNation="dark crystal|1|bag1|83|0|1|7925"|Insanitaria="flower Cedria preserved portal|1|bag1|85|0|1|40124"|Kearvek="dark orb vampires|1|bag1|160|0|1|6533"|KillingFields="trip forbidden|1|bag1|60|0|1|12795"|Knossos="passport knossos portal|1|bag1|61|0|1|13720"|Labyrinth="yoke wooden|1|bag1|15|0|1|13571"|LandofLegend="portal apple press|1|bag1|10|0|1|16252"|LostTime="time capsule timegold interesting item|1|bag1|80|0|1|12154"|MarshlandsofAgroth="chip willow bark portal|1|bag1|105|0|1|16545"|MasqueradeIsland="masquerade mask|1|bag1|100|0|1|41459"|Mossflower="joseph bell|1|bag1|150|0|1|12221"|MYST="white page|1|bag1|1|0|1|7360"|Nanjiki="magic banana|1|bag1|140|0|1|12651"|Pompeii="pompeii black volcanic glass|1|bag1|85|0|1|16206"|Qong="Wok Qong|1|bag1|201|0|1|41592"|Reme="mirror two|1|bag1|30|0|1|1862"|SchoolofHorror="book demon school handbook|1|bag1|150|0|1|1441"|SchoolofHorrorBox="jewelry box|1|bag1|190|0|1|1440"|ShadarLogoth="mists mashadar portal misty|1|bag1|99|0|1|6433"|ShadarLogothSwords="book crown swords|1|bag1|190|0|1|6528"|ShayolGhul="ivory horn valere|1|bag1|140|0|1|10970"|SnucklesVillage="Enchanted Spellbook|1|bag1|80|0|1|17062"|SoulbladeCheat="computer disk cheat code|1|bag1|150|0|1|2216"|STTNGHotel="share ownership royale|1|bag1|100|0|1|7805"|STTNGLock="transporter lock brooch|1|bag1|100|0|1|7827"|STTNGTasha="tasha hologram device button sasha|1|bag1|100|0|1|7816"|TakedasWarcamp="tiger kai ivory|1|bag1|182|0|1|9827"|TalsaCosmic="cosmic calling|1|bag1|150|0|1|45179"|TalsaEvil="evil intentions|1|bag1|100|0|1|2643"|TalsaIrresistible="irresistible calling|1|bag1|60|0|1|2697"|TheLabyrinth="yoke wooden|1|bag1|15|0|1|13571"|TirnanOg="fairy ring portal pale mushrooms|1|bag1|100|0|1|13496"|TreeOfLife="starburst|1|bag1|170|0|1|12326"|UnearthlyBonds="DIS badge|1|bag1|130|0|1|13769"|Verdure="holy well clay figurine wellfigurine|1|bag1|120|0|1|13897"|WaroftheWizards="honeycomb|1|bag1|15|0|1|14651"|XylsMosaic="Envelope xyl_mosaic_item|1|bag1|100|0|1|41177"|Yggdrasil="tree crystal yggdrasil|1|bag1|185|0|1|11505"|YurgachDomain="kali's kalis necklace pendant chain silver|1|bag1|85|0|1|7963"|Zyian="Medallion Daemon Zyian|1|bag1|110|0|1|12374"</var>
</cmud>
|
Charneus |
|
|
 |
Rahab Wizard
Joined: 22 Mar 2007 Posts: 2320
|
Posted: Sun Jun 06, 2010 6:20 pm |
Here is one of my variables that did not get converted automatically. I had to reload 3.17, because even looking at the XML of the variable in 3.18d was enough to cause it to add "json=true", even though the content of the variable itself did not change.
[quote]
<var name="keywords" type="Record" sorted="true" id="272">blocky piece of dark stone=basalt|blocky piece of grey stone=granite|fleshy, faded-orange fruit=kutai|handful of aromatic seeds=sivifi|handful of deep-red leaves=makras|hand-sized chunk of dark stone=basalt|hand-sized chunk of grey stone=granite|hand-sized chunk of red stone=jasper|head-sized chunk of dark stone=basalt|head-sized chunk of grey stone=granite|head-sized chunk of red stone=jasper|large chunk of rock=granite|long, segmented tail="rat|tusk"|lopsided yellow fungus=opsala|rough chunk of bluish rock=turquoise|round hunk of grey stone=granite|shriveled black fruit=kaya|small grey hide=rat|small shimmering skin=jozhal|small strip of meat=rat|small, curved tusk=rat|small, shimmering skin=jozhal|tan strip of hide=chalton</var>
[/code] |
|
|
 |
Rahab Wizard
Joined: 22 Mar 2007 Posts: 2320
|
Posted: Sun Jun 06, 2010 6:32 pm |
Here is an even simpler example. In a blank session in version 3.17, I created a new package which contained only the following:
Code: |
<var name="testvar" type="Record" id="1">a="1|2|3"</var> |
I then installed 3.18d. In a blank session, I loaded the package. Without doing anything else, I examined the XML of the variable:
Code: |
<var name="testvar" type="Record" json="true" id="1">{"a":"1|2|3"}</var> |
Then I tested and verified that neither of the following worked:
Code: |
#show @testvar.a.1
#show %item(%db(@testvar,a),1)
|
|
|
|
 |
Zugg MASTER

Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Mon Jun 07, 2010 5:16 pm |
Yep, confirmed and added to bug list.
|
|
|
 |
|
|
|
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
|
|