Coding problem

Discussion of Inner Space

Moderators: Lavish Software Team, Moderators

Post Reply
linkmaster
GamingTools Subscriber
Posts: 39
Joined: Tue Jul 13, 2004 8:00 am

Coding problem

Post by linkmaster » Sat Oct 27, 2007 6:53 am

Not sure this is the right area for this...but am I missing something...

this piece of code

Code: Select all

function main()
{
	LavishSettings:AddSet[myprices]
	LavishSettings[myprices]:AddSet[General]
	LavishSettings[myprices]:AddSet[Sell]
	LavishSettings[myprices]:AddSet[Buy]

	variable settingsetref General=${LavishSettings[myprices].FindSet[General]}
	variable settingsetref Buy=${LavishSettings[myprices].FindSet[Buy]}
	variable settingsetref Sell=${LavishSettings[myprices].FindSet[Sell]}

	General:AddSetting[Buy Enabled,1]
	General:AddSetting[Sell Enabled,1]
	Sell:AddSetting[Name,Totem of the Chameleon]
	Sell:AddSetting[MinPrice,77.0000]
	Buy:AddSetting[Name,Totem of the Chameleon]
	Buy:AddSetting[MinPrice,50.0000]
	LavishSettings[myprices]:Export[myprices.xml]
}
returns

<?xml version='1.0' encoding='UTF-8'?>
<!-- Generated by LavishSettings v2 -->
<InnerSpaceSettings>
</InnerSpaceSettings>

in myprices.xml

linkmaster
GamingTools Subscriber
Posts: 39
Joined: Tue Jul 13, 2004 8:00 am

Post by linkmaster » Sat Oct 27, 2007 5:38 pm

Never mind a lot more research and I discovered the problem...

agitated
GamingTools Subscriber
Posts: 30
Joined: Sat Apr 28, 2007 5:05 pm

Post by agitated » Tue Jan 15, 2008 4:36 pm

I'm having this problem with code based entirely off the wiki and getting the same result...what was the solution?

I see in myprices.iss there are no AddSetting statements. Is the LavishSettings wiki incorrect?

Lax
Owner
Posts: 6634
Joined: Fri Jun 18, 2004 6:08 pm

Post by Lax » Wed Jan 16, 2008 9:43 am

The wiki is not incorrect. The code the guy used above was not working because "variable" statements are executed BEFORE other statements in the function, regardless of their position. Without knowing this, the OP put the statements after other initialization, thinking that the LavishSettings[x]:AddSet[y] would happen before creating the settingsetref variables. However, they did not, and therefore General, Buy, and Sell did not reference a real set, and therefore no settings were added to LavishSettings (note: this is why most of the "variable" statements in the LavishSettings wiki do not initialize the variable with the set on the same line! I just edited one in the LavishSettings LavishScript Usage Walkthrough to help with this potential source of confusion -- additionally, I have updated the Variables section of the LavishScript language and engine overview http://www.lavishsoft.com/wiki/index.ph ... #Variables to explain in detail the behavior of the variable keyword). Empty sets are not written in LavishSettings exports, and therefore the General, Sell and Buy sets, which were successfully created, were not written to file.

Now... what code are you having trouble with, so I can explain to you why it is not working? Without your code I can't really guess, unless you made the same mistake.

agitated
GamingTools Subscriber
Posts: 30
Joined: Sat Apr 28, 2007 5:05 pm

Post by agitated » Wed Jan 16, 2008 10:26 am

Thanks for the info Lax.

I made exactly the same mistake. The info in the wiki before you updated was in fact all there, just subtly so.

My code is working now.

Post Reply