| 
	
		|  |  
		| draean Newbie
 
 
 Joined: 04 May 2009
 Posts: 9
 
 
 | 
			
			  |  Posted: Wed Feb 13, 2013 9:30 pm 
 Database spell list crash issue
 
 |  
				| Hi there! 
 I'm running Cmud 3.34, and am trying to write myself a handy little script. I'm trying to use a database, thinking that having a separate file storing a large part of the data will help prevent the program from eating my script from time to time, so I've been trying to figure that out, but I have a sortof strange crash going on.
 
 I have a database with the following columns
 name, in, out, duration
 
 each contains the name of a spell, the line(or | delimited list of lines) that may be shown when the spell is cast, same for when the spell runs out, and then the duration, in seconds, that the spell lasts.
 
 first I run this alias:
 #DBLOAD affectslist.db
 #dbfirst
 affinlist=""
 affin=""
 affoutlist=""
 affout=""
 affnames=""
 afflist=""
 affdur=""
 #WHILE (!%null(%rec)) {
 affinlist=%additem(&in, @affinlist)
 affoutlist=%additem(&out, @affoutlist)
 affin=%addkey(affin, &in, &affectname)
 affout=%addkey(affout, &out, &affectname)
 affnames=%additem(&affectname, @affnames)
 #DBNEXT
 }
 
 I have this trigger:
 ^({@affinlist})$
 
 #say meep
 #DBGET %find(%1,afintonames,in)
 affectslist.&affectname....
 
 
 Except, as soon as I type the & symbol on that last line, the program crashes. not when it's run even, just when I type the character. the view afintonames has column 1 be in, and column 2 be affectname.
 
 I'm running window 7 64 bit.
 
 I'm wondering if there's a way around this, or if anyone has any advice for the common crashes I've been experiencing other than, 'backup your scripts'
 
 Thanks!
 |  |  
	  |  |  
		|  |  
		| shalimar GURU
 
  
 Joined: 04 Aug 2002
 Posts: 4774
 Location: Pensacola, FL, USA
 
 | 
			
			  |  Posted: Wed Feb 13, 2013 9:56 pm 
 |  
				| what are you using the & symbol for? 
 variables are referenced via the @varName
 local variables use $varName
 
 Have you tried using a dbVar?
 |  |  
	  | 
		    
			  | _________________ Discord: Shalimarwildcat
 |   |  |  
		|  |  
		| draean Newbie
 
 
 Joined: 04 May 2009
 Posts: 9
 
 
 | 
			
			  |  Posted: Wed Feb 13, 2013 10:08 pm 
 |  
				| the help file shows this line as an example: 
 #DBFIRST;#WHILE (!%null(%rec)) {#SHOW &Name;#DBNEXT}
 
 using & to reference the value in a field of the current db record
 |  |  
	  |  |  
		|  |  
		| Daern Sorcerer
 
 
 Joined: 15 Apr 2011
 Posts: 809
 
 
 | 
			
			  |  Posted: Thu Feb 14, 2013 2:56 am 
 |  
				| What is your last line (affectslist.&affectname....) supposed to do exactly? It looks like you cut it short, which kinda makes it hard to figure that out... 
 I'm gonna guess affectslist is a db variable, and you're trying to get the item with the key &affectname, in which case you would do %db(@affectslist, &affectname). Of course, you don't have an affectname field in your database, so that could cause problems - should that be &name instead?
 |  |  
	  |  |  
		|  |  
		| Rahab Wizard
 
 
 Joined: 22 Mar 2007
 Posts: 2320
 
 
 | 
			
			  |  Posted: Thu Feb 14, 2013 1:43 pm 
 |  
				| 
 
	  | Code: |  
	  | affectslist.&affectname.... |  has a big problem.  You are trying to specify a variable at the beginning of a command line without a leading @.  The only time you can do that is if you are setting a variable with the syntax
 
 But you have a period after affectslist, which means you are specifying an item or database key within the @affectslist variable.  You can only use the varname=value syntax for the variable itself, not an item or database within the variable.  So whatever you are trying to do here must be done a different way.  If you explain what you are trying to do, we can help figure out the correct syntax.
 |  |  
	  |  |  
		|  |  
		| Rahab Wizard
 
 
 Joined: 22 Mar 2007
 Posts: 2320
 
 
 | 
			
			  |  Posted: Thu Feb 14, 2013 1:48 pm 
 |  
				| That said, it is very odd that simply typing the character crashes the system.  Are you saying that it actually crashes Cmud?  While you are editing the trigger in the Package Editor?  What exactly happens?  Do you get an error message?  Does Cmud freeze?  Or does Cmud close unexpectedly? 
 |  |  
	  |  |  
		|  |  
		| Daern Sorcerer
 
 
 Joined: 15 Apr 2011
 Posts: 809
 
 
 | 
			
			  |  Posted: Thu Feb 14, 2013 5:51 pm 
 |  
				| I didn't test it, but I imagine it doesn't like the & character after the dot. I'm pretty sure when using the dot notation, it only uses literal keys, it doesn't expand anything. That's what %db is for - I suggested using it above. 
 |  |  
	  |  |  
		|  |  
		|  |  
		|  |  
  
	| 
 
 | 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
 
 |  |