Register to post in forums, or Log in to your existing account
 

Post new topic  Reply to topic     Home » Forums » General zApp Discussion
Castaway
GURU


Joined: 10 Oct 2000
Posts: 793
Location: Swindon, England

PostPosted: Wed Sep 07, 2005 7:16 pm   

Problems using "zStore"
 
More problems..

I'm trying to use a bare "zStore" to store some data in memory for the duration of the program, yet whatever I store I seem not to be able to retrieve it at all..

I'm declaring it like:
Code:

<store name='data1' />


filling it later using:
Code:

           my $store = $MainObj->data1;
           $core->MsgBox($store->Open);
....
              $store->Put($item->{id}, $attrib, $item->{$attrib});

and at the end of that same piece of script I try:
Code:

           $store->Flush();
           $core->MsgBox("stored:" . $store->Get(191, 'name'));
           $store->Close();

(thats a random one of the IDs that does exist) .. yet I just get "stored:" in the message box and nothing else..

...

Anything I'm missing? I should probably try a small example with vbscript I guess... ;)

Lady C.
Reply with quote
Zugg
MASTER


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

PostPosted: Fri Sep 09, 2005 6:39 pm   
 
Yeah, check with vbscript. This could be related to all of the other problems you have had with perlscript not being able to get references to any objects. Until I have a chance to fix that, then a lot of stuff probably won't work correctly.

If you still have a problem with vbscript, let me know. You might also test with a hard-coded example like your Get statement and change your Put statement to:
Code:
$store->Put( 191, 'name', 'zugg')

and see if that helps at all.
Reply with quote
Castaway
GURU


Joined: 10 Oct 2000
Posts: 793
Location: Swindon, England

PostPosted: Fri Sep 09, 2005 8:22 pm   
 
hmm, no luck there either:

Code:

<?xml version='1.0' encoding='ISO-8859-1' ?>
<!DOCTYPE zapp []>

<zapp>
 <head>
 </head>
 <store name='mystore' />
 <window name='mainwindow' caption='Store Test' width='500' height='500'>
  <button caption='testme' name='mybutton'>
   <script>
    Set S = mystore
    S.Put 100, "id", 200
    Dim val
    val = S.Get(100, "id")
    Core.MsgBox "Val is:" &amp; val
   </script>
  </button>
 </window>

</zapp>


no workee :(
Reply with quote
Castaway
GURU


Joined: 10 Oct 2000
Posts: 793
Location: Swindon, England

PostPosted: Sat Sep 10, 2005 10:01 pm   
 
Hmm, doesnt "work" with sqlstore either.. *sniff*, exchanging this for the store tag above:

Code:

 <sqlstore name='mystore' connection='teststore.db' filter='data' keyfield='id'/>


Gets the same non-result, and creates no teststore.db file.. :(

Lady C.
Reply with quote
Zugg
MASTER


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

PostPosted: Sat Sep 10, 2005 10:54 pm   
 
If the basic zstore object isn't working, then none of the descendants are probably going to work either.

I should be able to start looking at these problems in about a week. I'll be fixing these issues and releasing a new zApp before embarking on the zMUDXP project.
Reply with quote
Castaway
GURU


Joined: 10 Oct 2000
Posts: 793
Location: Swindon, England

PostPosted: Sun Sep 11, 2005 8:15 am   
 
/me crosses fingers... ;)

Ok, will try the XML thingy then, and see if that wants to play.

Lady C.
Reply with quote
Castaway
GURU


Joined: 10 Oct 2000
Posts: 793
Location: Swindon, England

PostPosted: Sun Sep 11, 2005 8:57 pm   
 
Hrrm.. was worth a try.. Am I doing something wrong here?

Code:

<?xml version='1.0' encoding='ISO-8859-1' ?>
<!DOCTYPE zapp []>

<zapp>
 <head>
 </head>
<!-- <store name='mystore' /> -->
<!-- <sqlstore name='mystore' connection='teststore.db' filter='data' keyfield='id'/> -->
 <xml name='testxml' />
 <window name='mainwindow' caption='Store Test' width='500' height='500'>
  <button caption='testme' name='mybutton'>
   <script>
<!--    Set X = testxml -->
    Set X = xml.NewDoc
    Set C = X.AppendChild(X.CreateElement("testelement"))
    C.SetAttribute "id", 200
    X.SaveToFile "testxml.xml"
    items = X.GetElementsByTagName("testelement")
    Core.MsgBox "Got: " &amp; items.Item(1).Name
   </script>
  </button>
 </window>
</zapp>


Lady C.
Reply with quote
Zugg
MASTER


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

PostPosted: Thu Sep 29, 2005 7:18 pm   
 
OK, fixed some problems, but also found some problems with your syntax.

1) The zStore problem is fixed in v2.33.

2) With the SQL Store, their was a problem in your code:

You can't just create a database on the fly with SQLStore. It has no way to know what table structure you want. In your example, you reference a table called "data" with the Filter property. But this table doesn't exist yet. The proper way to handle this is to define a CONNECTION object and do something like this:
Code:
<connection name='MyDB' filename='teststore.db'>
  <script event='OnCreate'>
    CREATE TABLE data (id INTEGER PRIMARY KEY);
  </script>
</connection>
<sqlstore name='mystore' connection='MyDB' filter='data' keyfield='id'/>
...

After that there was a problem in zApp itself. When you do the:

S.Put 100, "id", 200

it tells the database to look up the record with the keyfield (id) of 100, and then set the "id" field of that record to 200. Since there aren't any records in the database yet, the initial lookup of id=100 fails. Basically, the above statement is equal to the SQL:

UPDATE data SET id=200 WHERE id=100

which is a bit confusing since you are setting the "id" field which is also the same as the KeyField that you specified for the connection.

What I'll do in zApp 2.33 is have it automatically do an INSERT if the record isn't found. However, even with this your code would have a problem because after using the PUT command, you then try to retrieve the ID value for record 100, even though you just changed the ID key to 200. So I think you really intended to have a different database structure here. You need to add some sort of Data field that is different from the Key field for the database.

3) Regarding the XML example, there were several problems in your code. You should consult either the zApp documentation or some good reference on the XML DOM model.

a) The AppendChild method is a method of an XML NODE, not the main XML DOM object. To append a child to the top-level DOM object, you need to reference the DOCUMENT property of the DOM. So the correct line is:

Set C = X.Document.AppendChild(X.CreateElement("testelement"))

b) The GetElementsByTagName method returns a Collection, which is an OBJECT, so you need a SET VBScript assignment here:

SET items = X.GetElementsByTagName("testelement")

c) There is no NAME property for nodes. The correct property name as documented is NODENAME, so your final line should be:

Core.MsgBox "Got: " & items.Item(1).NodeName

Now, there *were* a couple of problems in zApp also. First, the X.Document wasn't returning the correct object. Second, the C.SetAttribute wasn't initializing the attributes object correctly for the first time, so adding the first attribute to a record wasn't working. I've fixed this in 2.33

Anyway, this stuff can get complicated, and I appreciate you posting these examples to test. It's nearly impossible to test everything like this without help. And, of course, things like SQL and XML can be complicated enough on their own.

The new zApp version should be out within the next couple of days. I want to also investigate some of the Perl problems you reported before releasing something.
Reply with quote
Castaway
GURU


Joined: 10 Oct 2000
Posts: 793
Location: Swindon, England

PostPosted: Thu Sep 29, 2005 9:17 pm   
 
Yippee!

Just when I was getting impatient too :) Thanks! Awaiting new version to play with with eagerness!

And thanks for the corrections to my examples too.. I'm glad it turns out the strangeness wasnt all my converting to VBscript ;)

(I've been polishing the Perl parts of my code.. woohoo ;)

Lady C.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » General zApp Discussion 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 on Wolfpaw.net