Symbolic recalc - dependant on EditTable rows (OpenInsight Specific)
At 18 MAR 1999 08:07:26PM Barry Stevens wrote:
I have a window that inculdes an edittable with columns of values, also have another symbolic controls (outside of ediitable) that are totals of the columns in the edit table - all table bound.
When when user changes column value, or delete key entered and row deleted, the sysmbolic controls recalculate ok.
Sometimes the program will fill values in the table and I issue a CALCULATE event and recalcs ok.
BUT
I put a 'delete row' button on the window and programmatically deleted the row from LIST and reset, then issued CALCULATE events to the sysbolic controls, BUT, they are not changing.
Any clues as to why or should I be doing something different.
Barry
At 19 MAR 1999 06:45AM Tony Marler @ Prosolve wrote:
Barry
Is the symbolic working of @RECORD ? If so maybe it is not getting updated by the delete line. Check RECORD Property of @WINDOW instead of @RECORD to see what is happening.
Tony
At 19 MAR 1999 07:02AM Oystein Reigem wrote:
Barry,
Try to use DEFPROP instead of LIST. (Except edit table's DEFPROP is like ARRAY, so you have to switch columns and rows in your processing.)
Here's some of what the docs say about DEFPROP: "If control is database linked, then setting this property also sets SAVEWARN property for a window and updates the database-bound structures, like the DataSet Object, and enables field recalculation for Native Tables." Probably gives you whiter teeth and saves a few rain forests as well.
- Oystein -
PS. Just discovered I have a problem with DEFPROP and CALCULATE myself. E.g I have a one-column edit table with values "aaa", "bbb" and "ccc". My calculated field strings together these values - "aaa; bbb; ccc". I programmatically delete the second value using DEFPROP to put the changed content back. Then when I send CALCULATE I don't get "aaa; ccc" but "aaa; ccc; ccc".
I helped you - now you help me!
At 19 MAR 1999 11:58PM Barry Stevens wrote:
I changed to DEFPROP (ala ARRAY) , still no good.
@record shows only the first column cell is deleted. ???
I am doing get_property(EditTable,"DEFPROP")
.....delete the required rowset_property(EditTable,"DEFPROP")Display of new EditTable data on Window is correct.
Barry
PS; What is your code in the symbolic.
At 20 MAR 1999 12:01AM Barry Stevens. wrote:
Tony, see response to Oystein
At 22 MAR 1999 06:41AM Oystein Reigem wrote:
Barry,
My problem first (and I don't mean to be selfish):
In my test window I have a one-column edit table with a databound data field. In the form I also have a symbolic edit line showing all the values from that field stringed together.
Next I have a button that deletes the second row programmatically with
<code> EditTable=@Window : "..." RowNo=2 Array=Get_Property( EditTable, "DEFPROP" ) NumCols=count(Array, @FM) + (Array "") NewArray=" for C=1 to NumCols NewArray := delete( Array, 1, RowNo, 0 ) : @FM next C if NumCols then NewArray-1, 1=" UnUsed=Set_Property( EditTable, "DEFPROP", NewArray ) debug</code>
The edit table shows the changes fine.
And since I used DEFPROP, I thought @Record would be updated and my symbolics would calculate correctly too, at least if I asked them to calculate (see below). But the debugger shows me an unchanged @Record.
Let's say I start with the values
<code> aaa bbb ccc</code>
in the edit table. The symbolic then shows
<code> aaa; bbb; ccc</code>
After pressing the button the edit table becomes
<code> aaa ccc</code>
But @Record still contains all the three values. And the symbolic still shows
<code> aaa; bbb; ccc</code>
Further, I have a second button that asks the symbolic field to recalculate, with the following script:
<code> debug Symbolic=@Window : "..." call Send_Event( Symbolic, "CALCULATE" )</code>
The debugger now tells me that @Record has changed after all, but in @Record the multi-valued field is not
<code> aaa ccc</code>
but
<code> aaa ccc ccc</code>
And after CALCULATE the symbolic becomes
<code> aaa; ccc; ccc</code>
which of course is in agreement with the funny @Record.
What fixes my problem is to change the window RECORD property after I have reset DEFPROP (see the documentation of the RECORD property):
<code> Record=Get_Property( @Window, "RECORD" ) Record =NewArray UnUsed=Set_Property( @Window, "RECORD", Record )</code>
As I said before I didn't think that should be necessary since I used DEFPROP. But it might just be my lack of knowledge. I might simply have been lucky in my development work so far. In forms I have stayed away from using @Record as much as possible e.g since it doesn't always reflect the content of the databound controls.
Now to your problem:
I changed to DEFPROP (ala ARRAY) , still no good. @record shows only the first column cell is deleted. ???
I think it's odd you seem to get @Record only partly changed - only one out of the edit table's several fields. But at least try what I did (update the window RECORD property) and see what happens then.
- Oystein -
At 26 MAR 1999 12:39AM Barry Stevens wrote:
]]And after CALCULATE the symbolic becomes
]]aaa; ccc; ccc
You might need to use @mv in the sysmbolic…like in Arev for amvs sometimes.
If you haven't come across this , then show me your symbolic code.
Barry
At 26 MAR 1999 06:38AM Oystein Reigem wrote:
Barry,
@MV?? Don't recognize it. Or let me check online help… …perhaps I do. Certainly must have used it in Arev back in Paleozoic times…
My symbolic's formula is:
<code> declare function Make_NameString @ans=Make_NameString("")</code>
The the very simple function called is:
<code> function Make_NameString( Dummy ) /* A function that takes multi-valued field NAME in table PERSON (each person can have several names) and strings together all the (non-null) values, delimited with a semicolon and a space */ "") NameString=" for N=1 to NumNames if Name "" then if NameString "" then NameString := "; " NameString := Name end next N return NameString</code>
I don't quite see where @MV comes in. Sure I would get a wrong value back from the function if @MV for some reason was ] 0 (i.e, just one of the names). I'd be grateful if you have an explanation.
- Oystein -
At 31 MAR 1999 05:26PM Barry Stevens wrote:
Sorry about the late reply.
Try this: - added the transfer lines…if works, dont ask me to explain.
![]()
function Make_NameString( Dummy )
/*
A function that takes multi-valued field NAME in table PERSON
(each person can have several names)
and strings together all the (non-null) values,
delimited with a semicolon and a space
*/
transfer @mv to mv"")NameString="for N=1 to NumNamesif Name "" thenif NameString "" then NameString := "; "NameString := Nameendnext Ntransfer mv to @mvreturn NameString
Barry
At 06 APR 1999 05:22AM Oystein Reigem wrote:
Barry,
Sorry about the late reply.
No problem. Even if I'm totally mystified I think the problem only appears in a window I made to test the stuff you posted. I've never seen it in my app proper.
Try this: - added the transfer lines…if works, dont ask me to explain.
![]()
Didn't help. (Where did you get that code from? Should it help to have @MV=" when doing a {}?)
Well, as long as the problem is contained to the test window I'll shelve this for now. Thanks!
- Oystein -
At 06 APR 1999 09:33PM Barry Stevens wrote:
I did a test myself to try out a few ideas because of problems I was haveing.
I can get your delete row to work but I cannot get insert row ('un-delete') to work.
What you need in your code is the DELETEROW send_event
Here is my code on the Click event for the 'Delete' button:
declare function msg
EditTableId=@Window:".CLAIM_TABLE"
SelPos=.CLAIM_TABLE-]SELPOS
RowNum=SelPos
LIST=get_property(EditTableId,"LIST")
RowData=List
LIST=delete(LIST,RowNum,0,0)
.CLAIM_TABLE-]LIST=LIST
call send_event(EditTableId,"DELETEROW",RowNum)
Ok=msg(@Window,"Are you sure you want to delete line ":RowNum:@fm:"BNY":@fm:@fm:"?")
if Ok else
LIST=insert(LIST,RowNum,0,0,RowData).CLAIM_TABLE-]LIST=LISTcall send_event(EditTableId,"INSERTROW",RowNum)call send_event(EditTableId,"LOSTFOCUS")@record=@@Window-]RECORDcall send_event(@Window:"CC_TOTAL","CALCULATE")end
RETURN 0
Barry
At 07 APR 1999 07:35AM Oystein Reigem wrote:
Barry,
I can get your delete row to work but I cannot get insert row ('un-delete') to work.
You seem to delete the row before you ask the user if he really wants to. Why don't you ask him first? Then you don't have to repair the damage.
(Your approach reminds me of something else: Last year somebody (Chris …) wanted to know how to disable the delete key for an edit table. It seems it's hard to avoid the deletion from taking place. Jim Weir, Algo, had the following simple solution: "In the INSERTROW event handler send a DELETE message and in the DELETEROW event handler send an INSERT message. That is, execute send_message(CtrlEntId,'DELETE',RowNum) in the INSERTROW event handler and execute send_message(CtrlEntId,'INSERT',RowNum,RowData) in the DELETEROW event handler.")
What you need in your code is the DELETEROW send_event
I'll be damned! You're right - that works!
Mind you, I use DEFPROP instead of LIST, and I thought DEFPROP was powerful enough to update everything.
- Oystein -
At 07 APR 1999 08:31PM Barry Stevens wrote:
"You seem to delete the row before you ask the user if he really wants to. Why don't you ask him first? Then you don't have to repair the damage."
Thought you would pick up on that.
That is what I am doing (from a delete button), but, I was trying to kill two birds with the one stone.
I originally had a promoted event for DELETEROW where I needed to reinsert the row, I just couldnt get that to work, which is why I was testing it here.
BTW I disable the delete key by setting protect in the More… section and having an insert button…bit of a pain for the user…cant press enter for a new line.
I will try the idea you passed on.
Glad I was able to help with your problem.
Barry