rduncan10
10th November 2015, 17:42
I'm trying to write a session that will add or update the item text (tiitm001.txta) when the user changes the signal code.
This works fine if there is already text in tiitm001.txta, but not if there is no text.
This is a type 1 form, main table is tiitm001.
The code I'm using:
choice.update.db:
after.choice:
do.update()
functions:
function do.update()
{
nr.lines = text.read("tiitm001.txta", language$,
kw1, kw2, kw3, kw4, tg, topt, new.txt, 0)
.... CODE TO UPDATE TEXT ....
if tiitm001.txta > 0 then
nr.lines = text.rewrite("tiitm001.txta", language$,
kw1, kw2, kw3, kw4, tg, topt, new.txt)
else
nr.lines = text.write("tiitm001.txta", language$,
kw1, kw2, kw3, kw4, tg, topt, new.txt)
endif
}
I thought text.rewrite() was supposed to add new text or replace existing, but that didn't work if there was no existing text, so I tried using both, but that did not work.
I tried changing "after.choice" in "choice.update.db" to "before.choice", but this caused a "TRANSACTION ON" error.
I wanted to use main.table.io instead, but that isn't working in this session at all.
This works fine if there is already text in tiitm001.txta, but not if there is no text.
This is a type 1 form, main table is tiitm001.
The code I'm using:
choice.update.db:
after.choice:
do.update()
functions:
function do.update()
{
nr.lines = text.read("tiitm001.txta", language$,
kw1, kw2, kw3, kw4, tg, topt, new.txt, 0)
.... CODE TO UPDATE TEXT ....
if tiitm001.txta > 0 then
nr.lines = text.rewrite("tiitm001.txta", language$,
kw1, kw2, kw3, kw4, tg, topt, new.txt)
else
nr.lines = text.write("tiitm001.txta", language$,
kw1, kw2, kw3, kw4, tg, topt, new.txt)
endif
}
I thought text.rewrite() was supposed to add new text or replace existing, but that didn't work if there was no existing text, so I tried using both, but that did not work.
I tried changing "after.choice" in "choice.update.db" to "before.choice", but this caused a "TRANSACTION ON" error.
I wanted to use main.table.io instead, but that isn't working in this session at all.