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