Page 1 of 1

Using data from one stack to update another stack

Posted: Wed Mar 26, 2008 10:23 pm
by Tom
2 substacks: "Detail" and "Summary"
Detail contains one card for each entry.
Summary contains only 1 card.
I want to read a card from Detail and then add a field content from the Detail record into a field in the Summary.
When Summary opens, in an openCard handler (note, ALL of the following is done in the openCard handler), I initialize all the fields in the Summary card to zero... that works.
I then open Detail invisible...
A repeat loop (from 0 to number of cards in Detail) then executes.
In that repeat loop is code that reads data from the card and sets an index... this works.
Then I add 1 to a 'counter' field in the Summary. And that's where it always dies.
The actual code to add is add 1 to field("YTNR" & i) where i is the index mentioned above. (There are 4 fields named YTNR1, YTNR2, YTNR3 and YTNR4... the index resolves to a 1, 2, 3 or 4).
It looks like it's not recognizing the field... I've tried everything (except the right answer :-)

Thanks in advance....Tom

Posted: Thu Mar 27, 2008 1:11 am
by BvG
From your description I have no idea what you're actually doing, so here some general hints:
  • "field xyz" always refers to the current card of the defaultstack (most often that is the topstack)
  • if you open a stack (even invisible) it'll be the stack "field xyz" refers to
  • you can refer to stuff in stacks when they're not the current stack, it's easiest (and fastest) to do this by using a full description: field "voltage" of group "emp" of card "doomsday" of stack "device"
  • storing (and especially retrieving) data in fields is very slow , I suggest custom properties in all cases where a relational database is not yet needed (and sufficient knowledge of cprops is available)
Interesting documentation entries:
defaultstack property
topstack function
mode property
of keyword
go command

Posted: Thu Mar 27, 2008 3:48 am
by Tom
Thanks, BvG... now I understand why it didn't recognize the field in the "Summary" stack... it was not the 'default' stack.

So, I assume I can either make it the default stack, continueing to make each stack default as required... flopping back and forth.

OR, I can put in the full description, (which I tried, but I left out the 'card' reference)

I'll hold off on custom properties for awhile... I've got to learn to walk before I can run.

Thanks again...

Tom