steveauckly
26th January 2009, 21:37
When a user clicks on the "T"ext button and blanks out all text, standard Baan behavior is to delete the text record and store a 0 in the text field. Is there a way to not delete the record and keep the same text number?

mark_h
26th January 2009, 22:19
I don't see why not. Below is part of a qkey script where I added text. It keeps the same text number. So I can delete, readd, save, delete...etc and it still has the same text number. So I assume you could save off the text number then just update the table if the text number goes back to 0.


choice.text.manager:
before.choice:
set_text_attrs()


field.txta.yn:
before.display:
if tppss990.txtn then
txta.yn = tcyesno.yes
else
txta.yn = tcyesno.no
endif

main.table.io:
after.read:
get_key_code()

after.rewrite:
hold.textn = tppss990.txtn
key_code()

after.delete:
delete_key_code()

functions:
|******************************************************************************
| Set the text keyword attributes.
|******************************************************************************
function set_text_attrs()
{
attr.textkw1$ = tppss961.cprj
attr.textkw2$ = tppss961.cspa
attr.textkw3$ = sprintf$("%d",tppss961.sern)

}
|******************************************************************************
| Update the new table if text of a key code is added.
|******************************************************************************
function key_code()
{
select tppss990.*
from tppss990 for update
where tppss990._index1 = {:tppss961.cprj,:tppss961.cspa,:tppss961.sern,:tppss961.seqn,:tppss961.orno,:tppss961.pono,:tppss961.ponb}
selectdo
tppss990.txtn = hold.textn
tppss990.code = key.code
db.update(ttppss990,db.retry)
commit.transaction()
selectempty
tppss990.cprj = tppss961.cprj
tppss990.cspa = tppss961.cspa
tppss990.sern = tppss961.sern
tppss990.seqn = tppss961.seqn
tppss990.orno = tppss961.orno
tppss990.pono = tppss961.pono
tppss990.ponb = tppss961.ponb
tppss990.code = key.code
db.insert(ttppss990,db.retry)
commit.transaction()
endselect
}
|******************************************************************************
| Get the data to display for MDD.
|******************************************************************************
function get_key_code()
{
key.code = ""
tppss990.txtn = 0
select tppss990.*
from tppss990
where tppss990._index1 = {:tppss961.cprj,:tppss961.cspa,:tppss961.sern,:tppss961.seqn,:tppss961.orno,:tppss961.pono,:tppss961.ponb}
selectdo
key.code = tppss990.code
display("key.code")
endselect

}
|******************************************************************************
| Delete the record if MDD is deleted.
|******************************************************************************
function delete_key_code()
{
long numlines

select tppss990.*
from tppss990 for update
where tppss990._index1 = {:tppss961.cprj,:tppss961.cspa,:tppss961.sern,:tppss961.seqn,:tppss961.orno,:tppss961.pono,:tppss961.ponb}
selectdo
| Hold the text number.
hold.textn = tppss990.txtn
db.delete(ttppss990,db.retry)
commit.transaction()
selectempty
endselect
| Reference deleted, now go delete the text.
if(tppss990.txtn>0) then
numlines = text.delete("tppss990.txtn","2")
endif

}