Dear Jeffrey,

     Further to my last email, I quickly install metakit on Solaris 5.6 with gcc 
2.95.3.
I tested demo and dump, they gave correct results. But when I run your code,
I got

V0 = -268436744
V1 = -268436744

and dump the result gave me the same as on Linux

kdeck.dat: 1 properties
  kdeck[name:S, value:I]

 VIEW     1 rows = kdeck:V
    0: subview 'kdeck'
   VIEW     3 rows = name:S  value:I
      0: 'proc_cdp_first' 0
      1: 'proc_cdp_last' 0
      2: 'proc_cdp_inc' 0

  I cannot figure out what I have done wrong

Best regards

Jim

-----Original Message-----
From: Jim Hu 
Sent: Thursday, May 29, 2003 9:19 AM
To: 'Jeffrey Kay'
Subject: RE: [Metakit] Help on Int property


Dear Jeffrey,

      Thank you so much for your reply. I wonder if my there is anything wrong with
my installation as your code gives the wrong result as well (there is a bug in the
line 20). The running results are

V0 = 134525096
V1 = 134525096

and the dump resluts are

kdeck.dat: 1 properties
  kdeck[name:S, value:I]

 VIEW     1 rows = kdeck:V
    0: subview 'kdeck'
   VIEW     3 rows = name:S  value:I
      0: 'proc_cdp_first' 0
      1: 'proc_cdp_last' 0
      2: 'proc_cdp_inc' 0

would you help me run the code on your system. I am use RedHat 6.1.

Best regards

Jim

-----Original Message-----
From: Jeffrey Kay [mailto:[EMAIL PROTECTED]
Sent: Thursday, May 29, 2003 9:03 AM
To: Jim Hu
Cc: [EMAIL PROTECTED]
Subject: RE: [Metakit] Help on Int property


See if this simplifies what you are trying to do ...

#include "mk4.h" 
#include "mk4str.h" 
#include <stdio.h> 
main() 
{ 
       c4_StringProp pName ("name"); 
       c4_IntProp pValue ("value"); 
       c4_Storage storage("kdeck.dat", true); 
       c4_View kdeck = storage.GetAs("kdeck[name:S, value:I]"); 

         kdeck.Add(pName["proc_cdp_first"] + pValue[1]);
         kdeck.Add(pName["proc_cdp_last"] + pValue[676]);

         storage.Commit();

         for(int j=0;j<kdeck.GetSize();j++) {
                printf("V%d = %d\n",j,pValue(kdeck[j]));
         }

         kdeck.Add(pValue["proc_cdp_inc"] + pValue[1]);
       storage.Commit(); 
       return(0); 
} 

I'm not sure exactly where your logic was heading, but this is the
simplest way to add and retrieve values from rows in a view.  To
dereference a particular row in a view, the syntax is c4_View[rownum].
To dereference a particular value in a particular row, it's
c4_Prop(c4_View[rownum]).  You can assign a particular row to a row
variable also, but for most things I usually use the approach shown
above.  Similarly, if I'm tracking down a particular row, I use Find or
Select and then use the row number to make the property changes as shown
in this example.  There are a couple of things that you need to be aware
of if you use derived views, but we'll cross that bridge when you get to
it.

jeffrey kay
weblog <k2.com> pgp key <www.k2.com/keys.htm> aim <jkayk2>
share files with me -- get shinkuro -- <www.shinkuro.com>

"first get your facts, then you can distort them at your leisure" --
mark twain
"if the person in the next lane at the stoplight rolls up the window and
locks the door, support their view of life by snarling at them" -- a
biker's guide to life
"if A equals success, then the formula is A equals X plus Y plus Z. X is
work. Y is play. Z is keep your mouth shut." -- albert einstein

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf
Of Jim Hu
Sent: Thursday, May 29, 2003 9:50 AM
To: [EMAIL PROTECTED]
Subject: [Metakit] Help on Int property


Hi, all, 
     I am just starting to use Metakit (2.9.4.2). I used the demo.cpp as
an example and wrote 
the following piece of code. When I use the dump to dump the result, the
integer part of values 
are all zeros. Where did I do wrong? Please advise. 

#include "mk4.h" 
#include "mk4str.h" 
#include <stdio.h> 
main() 
{ 
       c4_StringProp pName ("name"); 
       c4_IntProp pValue ("value"); 
       c4_Storage storage("kdeck.dat", true); 
       c4_View kdeck = storage.GetAs("kdeck[name:S, value:I]"); 
       c4_Row row; 
       pName (row) = "proc_cdp_first"; 
       pValue(row) = 1; 
       kdeck.Add(row); 
       pName (row) = "proc_cdp_last"; 
       pValue(row) = 676; 
       storage.Commit(); 
       int v1 = pValue(row); 
       printf("V1 = %d\n", v1); 
       kdeck.Add(row); 
       int v2 (pValue (kdeck[1])); 
       printf("V2 = %d\n", v2); 
       pName (row) = "proc_cdp_inc"; 
       pValue(row) = 1; 
       kdeck.Add(row); 
       storage.Commit(); 
       return(0); 
} 
Sincerely, 
Jim Hu 

_______________________________________________
metakit mailing list  -  [EMAIL PROTECTED]
http://www.equi4.com/mailman/listinfo/metakit

Reply via email to