Sign up on the Revelation Software website to have access to the most current content, and to be able to ask questions and get answers from the Revelation community

At 07 JAN 2002 07:24:48PM S Bell wrote:

Hello,

I have a entry form with an edit table which has a

symbolic field called QTY_REC. The code is below.

CNT=COUNT({THRU_RTC}, @VM) + ({THRU_RTC} ) ONE=' FOR K=1 TO CNT ONE=1 NEXT K @ANS={THRU_RTC} — {FROM_RTC} +++ ONE The edit table looks like this …. From_Rtc Thru_Rtc Qty_Rec Rec_Date Book # 1 000 004 5 01/07/2002 12 2 1 3 1 4 1 5 1 Total Rec 9 My problem is I can't get this to work in OI as it did in Arev. On the first line it's OK but it fills the Qty_Rec column, rows 2 to 5 in with ones. If I change the code to ONE=0, it fills the column in with 0's but then the book range Qty Rec is off by 1. This all worked OK in Arev but I guess I don't understand fully how OI's Edit-tables work. I also have a symbolic field that sums the Qty_Rec column for a Total Recived. This total is also off until I save the record and read it back. Then its OK. Can any one out there give me a little code coaching. Steve Illinois State Lottery </QUOTE> —- === At 07 JAN 2002 07:53PM Paul Rule wrote: === <QUOTE>What I think is happening is that the edittable is already populated with a number of @vm's even though you may only have one line filled in. If you can see grid lines in the edittable then there will be a blank @vm delimetered line there. What we do is to strip the blank lines from the data taken from the edittable before doing any processing on it. Your line that returns the number of lines in the edittable CNT=COUNT({THRU_RTC}, @VM) + ({THRU_RTC} )

could be changed to something like

THRU_RTC=trim_array(get_property(ctrlentid,"INVALUE")) ;create your own trim_array function.

then use

CNT=COUNT(THRU_RTC, @VM) + (THRU_RTC ) ;*remove {} </QUOTE> —- === At 09 JAN 2002 11:38AM S Bell wrote: === <QUOTE>Thanks Paul, I can't seem to get the trim thing to work for me. Part of the problem is the debuger doesn't work with symbolic field code. I'm not sure if that's just the way it is or if it's the way I'm doing it. Anyway, here's where I am now. I change my symbolic code to this …..DECLARE FUNCTION GET_PROPERTY ONE=' TAB1=GET_PROPERTY(@WINDOW:".TABLE_1","DEFPROP") CNT=COUNT(TAB1,@VM) + (TAB1 )

FOR K=1 TO CNT

IF TAB1=' THEN

ONE=0

END ELSE

ONE=1

END

NEXT K

@ANS={THRU_RTC} — {FROM_RTC} +++ ONE

This works great when you key in the record for the first time.

BUT! When you save it and read it agin, it shows you that you're

still not out of the woods. You have to tab through the table to

get the counts to what they should be. Its always something.

Any ideas? I guess I'm not eating enought brain food.

Steve


At 09 JAN 2002 07:50PM Paul Rule wrote:

I'm guessing here, but maybe the symbolic needs recalculation.

I would have thought it would have calculated after the read.

Just as a stab in the dark, try

val=send_event(@window:".TABLE_1","CALCULATE")

after then read.


At 10 JAN 2002 11:56AM S Bell wrote:

Hi Paul,

I put the Send_Event in my forms Read event and got an

error loading my files table_1 dictionary item. ???

When I key in my test record's two part key, the data

comes into the form, the table's totals are uncorrect,

then if I click on my Read button the table recalculates

and the totals are fine.

Am I puting the Send_Event in the wrong place?


At 10 JAN 2002 12:37PM Simon Wilmot wrote:

Steve,

Are you putting it in the body of the Read event finishing with a Return 1 ??

If so, you want to do a Forward_Event on the Read first before your send_event.

Alternatively, you could try a Post_Event instead, although I'm not sure how effective that would be.

Simon

RebusHR


At 10 JAN 2002 02:05PM S Bell wrote:

Hi Simom,

Yes, that is what I did.

I looked up forward_Event sub and I not sure how to code

the parameters.

Here's my first shot ……

DECLARE FUNCTION SEND_EVENT

DECLARE SUBROUTINE FORWARD_EVENT

FORWARD_EVENT(CALCULATE)

status=SEND_EVENT(@WINDOW:".TABLE_1", "CALCULATE")

RETURN 1

BULLS EYE !!!

Thanks ALOT !


At 10 JAN 2002 02:34PM Simon Wilmot wrote:

Steve,

Thats not quite what I meant.

The Forward_Event shouldn't need any parameters - you are trying to forward the Read event to populate the window prior to running the calculate.

After that, you want to end with a Return 0 so it doesn't re-read at the end of it.

Best of luck,

Simon


At 11 JAN 2002 02:41PM S Bell wrote:

Hi Simon,

I changed the code and took Calculate out of the Foward_Event

and then Return 0.

It does'nt work. Table_1 does'nt recalc.

I thought when you type in you're Key, the form does the read, then

you would Foward_Event to the Calculate Event, then send Calculate

Event to Table_1 and Return 1 to get the recalc. That seem to work.

I always have been confused about when to Return 1 or Return 0.

Not sure what to do now. Will what I've got now, (that seems to work),

do some harm somewhere else later?

Steve


At 13 JAN 2002 05:18PM Oystein Reigem wrote:

S,

Try the following.

First put your window and formula back to their original state, like they were when you made your original posting.

Here's your original formula:

CNT=COUNT({THRU_RTC}, @VM) + ({THRU_RTC}  '')
ONE='
FOR K=1 TO CNT
    ONE=1
NEXT K
@ANS={THRU_RTC} --- {FROM_RTC} +++ ONE

I like that formula. It doesn't get or set properties of controls. That's good. A symbolic field should be independent of controls and windows. It should just calculate its value from the values of other table fields. That way you can use the symbolic in queries and reports too.

Your formula is not perfect, though. The problem is what Paul pointed out in his first response: At the bottom of the edit table there are empty rows that will be included in your formula's calculation. Your edit table has five rows, but even when only the first row has been filled in, there are null values (i.e, the null string ) in all the cells of the rest of the rows: <code> From_Rtc Thru_Rtc … 1 000 004 … 2 … 3 … 4 … 5 … </code> So when your formula works on the edit table's content, {FROM_RTC} becomes not one value 0 like you think, but the five (multi)values 0, , , , . Or stated differently - {FROM_RTC} becomes 0:@VM:@VM:@VM:@VM. Similarly your {THRU_RTC} becomes not the lone value 4 but the five (multi)values 4, , , , , or 4@VM:@VM:@VM:@VM. So your CNT becomes not 1 but 5, and you get five calculated values. The first value from the calculation <code> @ANS={THRU_RTC} — {FROM_RTC} +++ ONE </code> is 4 - 0 + 1=5 But the other four are - + 1 which Basic+ interprets as 0 - 0 + 1=1 So now you see where your unwanted 1's come from. This is why you get <code> From_Rtc Thru_Rtc Qty_Rec 1 000 004 5 2 1 3 1 4 1 5 1 </code> I should stress that these extra null values are not stored to your table when you save. They are just present while the data is in the edit table. But as you can see with the way you've written your formula they make problems for you. In his first response Paul suggested you write a function that can strip null values from the end of a @VM-delimited array, and use that function in the formula. That's a good suggestion. Here's a different one, equally valid: Instead of calculating all values at once with the +++ and — operators, do one at a time. Then you can handle values individually. Where there are proper filled-in values do the necessary thru-from+1 calculation. Where there aren't let the calculated value be null. Like <code> CNT=COUNT({THRU_RTC}, @VM) + ({THRU_RTC} ) THRU={THRU_RTC} FROM={FROM_RTC} QTY=' FOR K=1 TO CNT

  IF FROM  '' AND THRU  ''
      * PROPER, FILLED IN FROM AND THRU VALUES.
      * CALCULATE QTY VALUE
      QTY=THRU - FROM + 1
      * ELSE AT LEAST ONE OF THE VALUES ISN'T FILLED IN.
      * LET QTY VALUE REMAIN NULL.
      * (NOT NECESSARY TO DO ANYTHING FOR THIS TO HAPPEN)
  END

NEXT K @ANS=QTY </code>

Good luck!

- Oystein -


At 16 JAN 2002 07:19AM Simon Wilmot wrote:

Steve,

Probably not, but the only way to find out will probably when you get a problem (if you do).

I don't know the way all your events are channelled, so I assume that is why it isn't working in the same way as I would have expected.

Generally, Return 0 is intended to stop the event chain, so if you have completed your read processing, then Return 0 would stop the event chain going through any forwarded events in your application or any Sysprog events that have already been done.

Best of luck,

Simon

View this thread on the forum...

  • third_party_content/community/commentary/forums_nonworks/ce6fc56f64997a8688256b3b00024565.txt
  • Last modified: 2024/01/04 21:00
  • by 127.0.0.1