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
GeneralStonewall
Magician


Joined: 02 Feb 2004
Posts: 364
Location: USA

PostPosted: Fri Jun 04, 2010 11:44 pm   

[3.18d] BUG: Broken script -FIXED-
 
When trying to use my shell sort script for database variables, I get this error:

Quote:
Error parsing command:
Access violation at address 00649402 in module 'cMUD.exe' Read of address 00000000


Obviously, this means nothing to me.

I've yet to duplicate this error outside of this script, even when duplicating the apparent problem area almost exactly. I'll continue to search for it, but in the meantime, here's the script with a bit of debugging info added to it:

Code:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<cmud>
  <alias name="testsort" copy="yes">
    <value>#print ""
#print {Adding keys to testvar}
#addkey $testvar key8 5
#addkey $testvar key7 1
#addkey $testvar key6 9
#addkey $testvar key5 6
#addkey $testvar key4 3
#addkey $testvar key3 1
#addkey $testvar key2 2
#addkey $testvar key1 3
#print {Running sort function}
#print @shell_sort_db_keys_by_val($testvar)</value>
  </alias>
  <func name="shell_sort_db_keys_by_val" copy="yes">
    <value>#local $tempkey $tempval $inc $keys $vals $numkeys $j
$keys = %dbkeys( $database)
$vals = %dbvalues( $database)
$numkeys = %numitems( $keys)
$inc = %eval( $numkeys / 2)
#while ($inc > 0) {
  #print {start while-a}
  #loop ($inc + 1),$numkeys {
    #print {start loop-a}
    $tempkey = %item( $keys, %i)
    $tempval = %item( $vals, %i)
    $j = %i
    #while ($j >= $inc + 1 and %item( $vals, $j - $inc) > $tempval) {
      #print {start while-b}
      #print {Printing important variables}
      #print {keys: $keys}
      #print {j: $j}
      #print {inc: $inc}
      #print {keys.j: $keys.$j}
      #print {item( keys, j - inc): %item( $keys, $j - $inc)}
      #print {vals.j: $vals.$j}
      #print {item( vals, j - inc): %item( $vals, $j - $inc)}
      #print {Assigning keys.j to item( keys, j - inc)}
      $keys.$j = %item( $keys, $j - $inc)
      #print {Assigning vals.j to item( vals, j - inc)}
      $vals.$j = %item( $vals, $j - $inc)
      #print {Assignment successful}
      $j = $j - $inc
      #print {end while-b}
      }
    #print {end loop-a}
    }
  $inc = %round( $inc / 2.2)
  #print {end while-a}
  }
#return $keys</value>
    <arglist>$database</arglist>
  </func>
</cmud>


This is the line it seems to fail on:
Code:
$keys.$j = %item( $keys, $j - $inc)


Though, if I use that same line, with the same values in another script, there's no error.


Last edited by GeneralStonewall on Tue Jun 15, 2010 6:48 am; edited 1 time in total
Reply with quote
Zugg
MASTER


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

PostPosted: Sat Jun 05, 2010 5:38 pm   
 
I get the same crash so I might have a chance to find the problem and fix it.

Also, I'm curious whether you still need this script or not given the improved sorting in the newer version. Using "#SORT @db" should sort the database and keep it sorted as you add new values. Still working on adding an additional argument to #SORT to tell it exactly how to sort. Also still looking at how to handle custom sorting without killing performance by having it calling zScript functions when comparing each item in the list all the time.

Edited: Oh, nevermind, I see now that you are sorting on the *values* and not the *keys* which even the new custom sorting code doesn't do.
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