Post by Paige CotcampWe have an old VDB 5.7 legacy app that I would like to make a minor modification to.
Question: Can anyone offer up a simple solution to place a time stamp character string in a memo field?
Specificaly, I would like to map Date()+Time() to a simple keystroke such as Ctrl+T or F12 so that when a user enters a comment, they can automatically time stamp it.
Any suggestions would be greatly appreciated.
I don't have 5.7 available but the little example program below works in dBase Plus and you may be able to do something similar in 5.7.
As it stands I have only made provision for adding a record but a little more work will allow existing records to be edited. When the editor control for the memofield gets focus a time stamp is saved to a custom property of the form. Ctrl-q enters the time stamp at the end of whatever is in the memofield and then moves the cursor to the end.
Mervyn
********* Start of example program *******
** END HEADER -- do not remove this line
//
// Generated on 2008/10/23
//
parameter bModal
local f
f = new _memfldtestForm()
if (bModal)
f.mdi = false // ensure not MDI
f.readModal()
else
f.open()
endif
class _memfldtestForm of FORM
set procedure to :FormControls:DATABUTTONS.CC additive
with (this)
height = 16.0
left = 48.1429
top = 6.5
width = 40.0
text = ""
endwith
this.MEMFLDTEST1 = new QUERY()
this.MEMFLDTEST1.parent = this
with (this.MEMFLDTEST1)
left = 5.0
top = 14.0
sql = 'select * from "memfldtest.dbf"'
active = true
endwith
this.BARDATAEDIT1 = new BARDATAEDIT(this)
with (this.BARDATAEDIT1)
left = 6.0
top = 1.0
width = 27.4286
height = 1.4545
endwith
this.ENTRYFIELD1 = new ENTRYFIELD(this)
with (this.ENTRYFIELD1)
dataLink = form.memfldtest1.rowset.fields["data"]
height = 1.0
left = 6.0
top = 8.0
width = 22.0
endwith
this.EDITOR1 = new EDITOR(this)
with (this.EDITOR1)
onGotFocus = class::EDITOR1_ONGOTFOCUS
key = class::EDITOR1_KEY
height = 4.5
left = 6.0
top = 9.5
width = 25.0
dataLink = form.memfldtest1.rowset.fields["memfield"]
endwith
this.BARDATAVCR1 = new BARDATAVCR(this)
with (this.BARDATAVCR1)
left = 11.0
top = 4.0
width = 18.2857
height = 1.4545
endwith
this.rowset = this.memfldtest1.rowset
function EDITOR1_key(nChar, nPosition,bShift,bControl)
if nChar = 17
form.editor1.value += form.timestamp
form.editor1.keyboard("{ctrl+RightArrow}{ctrl+RightArrow}")
endif
return
function EDITOR1_onGotFocus
form.timestamp = date()+' '+time()
return
endclass
********* End of example program **********