Yet another how do I do this question...

Discussion of Inner Space

Moderators: Lavish Software Team, Moderators

Post Reply
jojotheslug
GamingTools Subscriber
Posts: 25
Joined: Sat Nov 18, 2006 9:25 pm

Yet another how do I do this question...

Post by jojotheslug » Thu Aug 29, 2013 8:07 pm

Sorry if this is extremely simple, but I cannot get this to work for the life of me. I've tried for the last 4 hours.

First, I've got a simple xml file that I'm using to keep track of whether or not my login app has completed it's in the following format:

Code: Select all

<?xml version='1.0' encoding='UTF-8'?>
<!-- Generated by LavishSettings v2 -->
<InnerSpaceSettings>
	<Set Name="Account1">
		<Setting Name="LoginStatus">LoggedIn</Setting>
	</Set>
</InnerSpaceSettings>
And here's the script I'm using for testing:

Code: Select all

function main&#40;&#41;
&#123;
     ;DECLARE/SET VARIABLES
     declare LoginFilePath filepath local "Account1LoginStatus.xml"
     LavishSettings&#58;Import[$&#123;LoginFilePath&#125;]
     declare LoginStatus string local
     LoginStatus&#58;Set[$&#123;LavishSettings[Account1].FindSetting[LoginStatus].String&#125;]
     
     Echo "---"
     Echo "The Login Status is $&#123;LoginStatus&#125;!!!"
     Echo "---"
     
     ;WRITE TO THE LOGIN FILE
     LavishSettings[Account1].FindSetting[LoginStatus]&#58;Set["LoggedOut"]
     LavishSettings[Account1]&#58;Export[$&#123;LoginFilePath&#125;]

     LavishSettings&#58;Import[$&#123;LoginFilePath&#125;]
     LoginStatus&#58;Set[$&#123;LavishSettings[Account1].FindSetting[LoginStatus].String&#125;]

     Echo "The Login Status is $&#123;LoginStatus&#125;!!!"
     Echo "---"
&#125;
All I'm trying to do at this point is just read in the value from my xml, echo it so I can check it's right, change it, write it back to the same file and then read it in and echo it again. But, when I export, it strips out the "Account1" set and just writes this:

Code: Select all

<?xml version='1.0' encoding='UTF-8'?>
<!-- Generated by LavishSettings v2 -->
<InnerSpaceSettings>
	<Setting Name="LoginStatus">LoggedIn</Setting>
</InnerSpaceSettings>
So, what on Earth am I doing wrong?

Thanks!
-J

jojotheslug
GamingTools Subscriber
Posts: 25
Joined: Sat Nov 18, 2006 9:25 pm

And Jesus wept!!!

Post by jojotheslug » Thu Aug 29, 2013 8:09 pm

Nevermind, whatever minor changes I made to clean up stuff for posting on here has now made the script work properly!


AGGGH!

:roll:

jojotheslug
GamingTools Subscriber
Posts: 25
Joined: Sat Nov 18, 2006 9:25 pm

Nope, it's still broken...

Post by jojotheslug » Thu Aug 29, 2013 8:13 pm

I was looking at the wrong xml.

jojotheslug
GamingTools Subscriber
Posts: 25
Joined: Sat Nov 18, 2006 9:25 pm

And the other wierd thing is...

Post by jojotheslug » Thu Aug 29, 2013 8:19 pm

It seems to write out the file before it imports it? What?

Because both echoes have the LoggedOut value instead of LoggedIn?

Ok? Huh? Who? :? :lol:

I'm in the TARDIS and I'm starting to lose my grip on the time-space continuum...

jojotheslug
GamingTools Subscriber
Posts: 25
Joined: Sat Nov 18, 2006 9:25 pm

Finally got it working...

Post by jojotheslug » Thu Aug 29, 2013 11:03 pm

I went ahead and changed it to this (in case anyone needs help in the future):

Code: Select all

function main&#40;&#41;
&#123;
     ;DECLARE/SET VARIABLES
     declare LoginFilePath filepath local "Account1LoginStatus.xml"
     declare LoginStatus string local
     LavishSettings&#58;AddSet[Account1Settings]
     LavishSettings[Account1Settings]&#58;Import[$&#123;LoginFilePath&#125;]
     LoginStatus&#58;Set[$&#123;LavishSettings[Account1Settings].FindSet[Account1].FindSetting[LoginStatus].String&#125;]
     
     Echo "---"
     Echo "The Login Status is $&#123;LoginStatus&#125;!!!"

     ;RESET THE LOGIN FILE
     LavishSettings[Account1Settings].FindSet[Account1].FindSetting[LoginStatus]&#58;Set["LoggedOut"]
     LavishSettings[Account1Settings]&#58;Export[$&#123;LoginFilePath&#125;]
     
     LavishSettings[Account1Settings]&#58;Remove

     LavishSettings&#58;AddSet[Account1Settings]
     LavishSettings[Account1Settings]&#58;Import[$&#123;LoginFilePath&#125;]
     LoginStatus&#58;Set[$&#123;LavishSettings[Account1Settings].FindSet[Account1].FindSetting[LoginStatus].String&#125;]

     Echo "The Login Status is $&#123;LoginStatus&#125;!!!"
     Echo "---"
&#125;

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

Post by Lax » Fri Aug 30, 2013 10:08 am

when I export, it strips out the "Account1" set and just writes this
That's because you're exporting the Account1 set as the XML file with

Code: Select all

LavishSettings[Account1]&#58;Export[$&#123;LoginFilePath&#125;]
... but importing directly into the LavishSettings root with

Code: Select all

LavishSettings&#58;Import[$&#123;LoginFilePath&#125;]
And then your solution, of course, imports it into Account1Settings instead of the root. Which is better. ;)

Post Reply