dbTalk Databases Forums  

memo field handling

comp.databases.paradox comp.databases.paradox


Discuss memo field handling in the comp.databases.paradox forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Frank Cutre
 
Posts: n/a

Default memo field handling - 07-15-2006 , 10:40 PM






Hi,

I have a form1 containing several alpha fields (of the "memo" type). For
design reasons I've restricted the display size of those form1.memoField(s).

When I move into a form1.memoField I'd like to trigger the opening of a
form2 to use as a data entry window (when the form2 closes it updates the
form1.memoField for the currentRecord.

Since I'm dealing with many memoFields (in currentTable and others) I'd like
form2 to be generic so I can apply it as needed around my application (to
reduce opal tweaking).

I'm guessing tCursors need to be involved but it's been so long since I've
coded... anything... I've forgotten how to code for common, basic tasks.

How do I get this done? Any help would be appreciated.

THANX for your time... (^_^)



Reply With Quote
  #2  
Old   
Egbert Babst
 
Posts: n/a

Default Re: memo field handling - 07-16-2006 , 04:20 AM






Frank,
here is an example how to do it. But note: There are a lot more
possibilities to do the same thing. Maybe another will jump in with a
simpler idea.
Put the code into the arrive-event on the form-level:
Quote:
;|| Putting the declaration here makes the loByPass-var method-global
var
loByPass logical
endVar

method arrive(var eventInfo MoveEvent)
var
stRetValue string
mmRet memo
foInput form
ui UIObject
endVar
if eventInfo.isPreFilter() then
;// This code executes for each object on the form

doDefault
;|| Check first whether ui is a memo-field. If necessary you can apply
some more restrictions
;|| To control with loByPass is necessary to avoid recursive calls.
loByPass is method-global to keep the value.
eventInfo.getTarget(ui)
switch
case ui.class <>"Field": RETURN
case ui.fieldType <> "MEMO": RETURN
case NOT loByPass.isAssigned():
loByPass=TRUE
case loByPass: RETURN
otherwise:
loByPass=TRUE
endSwitch

;|| Open the input-form which contains a memofield 'textbuffer' bound
to a table with only one record
;|| and memofield (also named) 'textbuffer'.
;|| The input-form would probably be a dialog form with an OK-button,
a CANCEL-button and a titlebar.
;|| Set in the arrive-event of the textbuffer-field:
;-------------------------------------------------
;|| if NOT self.isEdit() then self.Edit() endIf
;|| self.postAction(EditEnterMemoView)
;-------------------------------------------------
;|| open the input-form. The focus goes to the only field:
'textbuffer'
if NOT foInput.open("Input") then
ErrorShow("Could not open then input-form.")
loByPass=FALSE
RETURN
endIf
;|| Set the field's name into the titlebar to control better what
you're editing
foInput.setTitle("Enter text for ["+ui.name+"]")

;|| Get the actual fieldvalue into the buffer
foInput.Textbuffer'value=ui'value
stRetValue=string(foInput.wait())
;|| Assuming a OK-pushButton: Formreturn("OK")
;|| and another to cancel: Formreturn("False")
TRY
foInput.textbuffer.unlockRecord()
mmRet=foInput.textbuffer
foInput.close()
if stRetValue<>"OK" then
loByPass=FALSE
RETURN
endIf
onFail
;|| The input-form was closed anyhow (e.g. Alt F4))
ErrorShow()
loByPass=FALSE
RETURN
endTRY

;|| Make sure your memofield is in edit-mode:
if NOT ui.isEdit() then ui.Edit() endIf
;|| Blank values don't change anything - you can do this of course
another way.
if NOT mmRet.isBlank() then
ui.value=mmRet
ui.postRecord()
endIf
;|| Reset loByPass, so you can enter again this method with the next
memofield you arrive at.
loByPass=FALSE
else
;// This code executes only for the form

endIf

endMethod
<<<
HTH

Egbert, 11:19 AM temp. in Germany




Reply With Quote
  #3  
Old   
Frank Cutre
 
Posts: n/a

Default Re: memo field handling - 07-16-2006 , 05:02 PM



Hi Egbert (again),

I just noticed I did not "reply to group" (it's been a while since I've
practiced "newsgroup etiquette")... sorry for the extra send.

Frank
=============================


Hi Egbert,

Wow!!!!... WAY COOOOOL! "Set the field's name into the titlebar to control
better what you're editing"... I like the way you think!

Although I've been using Pdox since 1987, I'm far from being any kind of an
accomplished developer (only write snipits here and there to help me in the
way I work).

When I <Ctrl><F4> the memoBufferForm I'm getting an error (of course I've
changed some things).

THE ERROR:
"An error ocurred when trying to get the property named 'Value' of the
object named 'MemoBuffer' of the type 'Field'. Document is not in run
mode."

FYI:
1) I'm using Pdox7.patch4 (if that matters).
2) I changed your foInput to my "fInput" (and all refs to it).
3) I changed all your textbuffer to my "memoBuffer" (and all refs to it).
4) I don't want to use a dialog box (I hate buttons) so I used a custom form
instead.
5) Your arriveMethod code is added to some of my existing arriveMethod code
(if that matters).

The following code is formatted for 60 chars wide (I hope this is convenient
for you), also the stuff "you" suggested is remarked with a ";X" at
codeLineEnd:

currentVersionCallingForm.arriveMethod
;xxxxxxxx1xxxxxxxxx2xxxxxxxxx3xxxxxxxxx4xxxxxxxxx5 xxxxxxxxx6
; Open form defaults
;
; Frank J. Cutre
;
; 10/29/05 doDefault, size and place form window
; 07/16/06 memo field handling per newsgroup reply
; (comp.database.paradox Egbert Gabst), companion
; code also in arrive method of
; sfMemoBufferForm.memoBufferField
;================================================= ==========
;
method arrive(var eventInfo MoveEvent)

var
mainMenu Menu
x, y, w, h LongInt
selfP, sysTwips, thisSysTwips Point
thisSys DynArray[] AnyType
stRetValue string ;X
mmRet memo ;X
fInput form ;X
ui UIObject ;X
endVar ;X

if eventInfo.isPreFilter() then
;// This code executes for each object on the form

doDefault ;X
;|| Check first whether ui is a memo-field. If ;X
;|| necessary youcan apply some more restrictions. ;X
;|| To control with loByPass is necessary to avoid ;X
;|| recursive calls. loByPass is method-global to ;X
;|| keep the value. ;X
eventInfo.getTarget(ui) ;X
switch ;X
case ui.class <>"Field": RETURN ;X
case ui.fieldType <> "MEMO": RETURN ;X
case NOT loByPass.isAssigned():loByPass=TRUE ;X
case loByPass: RETURN ;X
otherwise: loByPass=TRUE ;X
endSwitch ;X
;X
;|| Open the input-form which contains a memofield ;X
;|| 'memoBuffer' bound to a table with only one ;X
;|| record and memofield (also named) 'memoBuffer'. ;X
;|| The input-form would probably be a dialog form ;X
;|| with an OK-button, a CANCEL-button and a ;X
;|| titlebar. ;X
;|| Set in the arrive-event of the ;X
;|| memoBuffer-field: ;X
;------------------------------------------------- ;X
;|| if NOT self.isEdit() then self.Edit() endIf ;X
;|| self.postAction(EditEnterMemoView) ;X
;------------------------------------------------- ;X
;|| open the input-form. The focus goes to the only ;X
;|| field: 'memoBuffer' ;X
;X
if NOT fInput.open(":fcc:sfMemoBuffer.fsl") then ;X
ErrorShow("Could not open then sfMemoBuffer ;X
input-form.") ;X
loByPass=FALSE ;X
RETURN ;X
endIf ;X
;X
;|| Set the field's name into the titlebar to ;X
;|| control better what you're editing ;X
;X
fInput.setTitle("Enter text for ["+ui.name+"]") ;X
;X
;|| Get the actual fieldvalue into the buffer ;X
;X
fInput.memoBuffer'value=ui'value ;X
stRetValue=string(fInput.wait()) ;X
;X
;|| Assuming a OK-pushButton: Formreturn("OK") ;X
;|| and another to cancel: Formreturn("False") ;X
;X
TRY ;X
fInput.memoBuffer.unlockRecord() ;X
mmRet=fInput.memoBuffer ;X
fInput.close() ;X
if stRetValue<>"OK" then loByPass=FALSE ;X
RETURN ;X
endIf ;X
onFail ;X
;|| The input-form was closed anyhow ;X
;|| (e.g. Alt F4)) ;X
ErrorShow() ;X
loByPass=FALSE ;X
RETURN ;X
endTRY ;X
;X
;|| Make sure your memofield is in edit-mode: ;X
;X
if NOT ui.isEdit() then ui.Edit() endIf ;X
;X
;|| Blank values don't change anything - you can ;X
;|| do this of course ;X
;|| another way. ;X
;X
if NOT mmRet.isBlank() then ;X
ui.value=mmRet ;X
ui.postRecord() ;X
endIf ;X
;X
;|| Reset loByPass, so you can enter again this ;X
;|| method with the next ;X
;|| memofield you arrive at. ;X
;X
loByPass=FALSE ;X


else
;// This code executes only for the form

; fill dynamic array with system information, fill
; in a "global" variable, calc X value EAST of center,
; calc Y value NORTH of center, form width,
; form height & place form

selfP = self.Position
sysInfo(thisSys)
sysTwips = Point(thisSys["FullWidth"],
thisSys["FullHeight"])
sysTwips = pixelsToTwips(sysTwips)
thisSysTwips = sysTwips
x = int(sysTwips.x()/2) - 9600
y = int(sysTwips.y()/2) - 7320
w = 19140
h = 14030
setPosition(x, y, w, h)

endIf

endMethod
;xxxxxxxx1xxxxxxxxx2xxxxxxxxx3xxxxxxxxx4xxxxxxxxx5 xxxxxxxxx6


"Egbert Babst" <EgbertBabst (AT) BabstSoft (DOT) com> wrote

Quote:
Frank,
here is an example how to do it. But note: There are a lot more
possibilities to do the same thing. Maybe another will jump in with a
simpler idea.
Put the code into the arrive-event on the form-level:

;|| Putting the declaration here makes the loByPass-var method-global
var
loByPass logical
endVar

method arrive(var eventInfo MoveEvent)
var
stRetValue string
mmRet memo
foInput form
ui UIObject
endVar
if eventInfo.isPreFilter() then
;// This code executes for each object on the form

doDefault
;|| Check first whether ui is a memo-field. If necessary you can
apply some more restrictions
;|| To control with loByPass is necessary to avoid recursive calls.
loByPass is method-global to keep the value.
eventInfo.getTarget(ui)
switch
case ui.class <>"Field": RETURN
case ui.fieldType <> "MEMO": RETURN
case NOT loByPass.isAssigned():
loByPass=TRUE
case loByPass: RETURN
otherwise:
loByPass=TRUE
endSwitch

;|| Open the input-form which contains a memofield 'textbuffer' bound
to a table with only one record
;|| and memofield (also named) 'textbuffer'.
;|| The input-form would probably be a dialog form with an OK-button,
a CANCEL-button and a titlebar.
;|| Set in the arrive-event of the textbuffer-field:
;-------------------------------------------------
;|| if NOT self.isEdit() then self.Edit() endIf
;|| self.postAction(EditEnterMemoView)
;-------------------------------------------------
;|| open the input-form. The focus goes to the only field:
'textbuffer'
if NOT foInput.open("Input") then
ErrorShow("Could not open then input-form.")
loByPass=FALSE
RETURN
endIf
;|| Set the field's name into the titlebar to control better what
you're editing
foInput.setTitle("Enter text for ["+ui.name+"]")

;|| Get the actual fieldvalue into the buffer
foInput.Textbuffer'value=ui'value
stRetValue=string(foInput.wait())
;|| Assuming a OK-pushButton: Formreturn("OK")
;|| and another to cancel: Formreturn("False")
TRY
foInput.textbuffer.unlockRecord()
mmRet=foInput.textbuffer
foInput.close()
if stRetValue<>"OK" then
loByPass=FALSE
RETURN
endIf
onFail
;|| The input-form was closed anyhow (e.g. Alt F4))
ErrorShow()
loByPass=FALSE
RETURN
endTRY

;|| Make sure your memofield is in edit-mode:
if NOT ui.isEdit() then ui.Edit() endIf
;|| Blank values don't change anything - you can do this of course
another way.
if NOT mmRet.isBlank() then
ui.value=mmRet
ui.postRecord()
endIf
;|| Reset loByPass, so you can enter again this method with the next
memofield you arrive at.
loByPass=FALSE
else
;// This code executes only for the form

endIf

endMethod

HTH

Egbert, 11:19 AM temp. in Germany





Reply With Quote
  #4  
Old   
Egbert Babst
 
Posts: n/a

Default Re: memo field handling - 07-16-2006 , 08:05 PM



Hi Frank,
thank you for your personal mail.
I'll answer here, so other guys may follow and add perhaps good ideas.
Quote:
Wow!!!!... WAY COOOOOL! "Set the field's name into the titlebar to control
better what you're editing"... I like the way you think!
<<<
Glad to read this ;-)

<<<
<snip>
When I <Ctrl><F4> the memoBufferForm I'm getting an error (of course I've
changed some things).

THE ERROR:
"An error ocurred when trying to get the property named 'Value' of the
object named 'MemoBuffer' of the type 'Field'. Document is not in run
mode."
<snip>
4) I don't want to use a dialog box (I hate buttons) so I used a custom form
instead.
<<<
Yes, keys may be faster to handle, and of course, the error is the
consequence of not using buttons which return via formReturn the values "OK"
resp. "False". If you use to close windows via Ctrl F4 you close the input
form before the method can detect whether you wanted to cancel or to use the
input.
The (easily soluble) main problem is, that the method then can not get the
input value this way, because it tries to read it from the yet open input
form - and can't if the window is still closed.
TRY
Quote:
foInput.textbuffer.unlockRecord()
mmRet=foInput.textbuffer <<< this gets the value from the open
form
foInput.close()
if stRetValue<>"OK" then
loByPass=FALSE
RETURN
endIf
onFail
;|| The input-form was closed anyhow (e.g. Alt F4))
ErrorShow()
loByPass=FALSE
RETURN
endTRY
If you try to get a value from a closed form (Ctrl F4) then the method
branches to the onFail block.
I did no further error handling in the example, only ErrorShow(). And that
showed you the error message.
The work around:
Let all as it is, but change the code in the onFail-block:
Quote:
onFail
;|| The input-form was closed anyhow (e.g. Alt F4))
;ErrorShow() <<< delete it
ErrorClear()
dmGet("textbuffer","textbuffer",mmRet)
;loByPass=FALSE <<< delete it
;RETURN<<< delete it
endTRY
<<<
Therefore you *must* add the "textbuffer.db" - or what ever name fits better
for you - into the data-model of the main form.
The dmGet(...) avoids a TCursor and you'll get the input-value directly from
the table bound to the input memofield.
If you do so, your code will be more universal. You can work with buttons or
close the input-form in any other way.

By the way:
As the code resides in the arrive-method on form's level, you only need it
once. If you don't apply more restriction it will automatically work with
all memo fields on your main form. This was, I remember, what you intended,
isn't it?

Feel free to change or use my example. As always in our common programming
field nothing is coming only from one brain. It's the stuff influenced by a
lot of good willed people here since long time.
HTH!

Egbert, 03:04 AM. At about 05:00 PM I'll go back to Spain.






Reply With Quote
  #5  
Old   
Frank Cutre
 
Posts: n/a

Default Re: memo field handling - 07-17-2006 , 09:20 AM



Hi Egbert,

YEEEEEEEES BABY !!! ... just what the doctor ordered!... we be happening!

Had to do a little more tweaking to allow for various data entry scenarios.
Also had to read up on dmGet() (reference table MUST be in the form's data
model for dmGet() to work).

Boy did I learn alot with the help of your pointers!

THANK YOU very much for your time... and patience... with me.

Frank (^_^)



"Egbert Babst" <EgbertBabst (AT) BabstSoft (DOT) com> wrote

Quote:
Hi Frank,
thank you for your personal mail.
I'll answer here, so other guys may follow and add perhaps good ideas.

Wow!!!!... WAY COOOOOL! "Set the field's name into the titlebar to
control
better what you're editing"... I like the way you think!

Glad to read this ;-)


snip
When I <Ctrl><F4> the memoBufferForm I'm getting an error (of course I've
changed some things).

THE ERROR:
"An error ocurred when trying to get the property named 'Value' of the
object named 'MemoBuffer' of the type 'Field'. Document is not in run
mode."
snip
4) I don't want to use a dialog box (I hate buttons) so I used a custom
form
instead.

Yes, keys may be faster to handle, and of course, the error is the
consequence of not using buttons which return via formReturn the values
"OK" resp. "False". If you use to close windows via Ctrl F4 you close the
input form before the method can detect whether you wanted to cancel or to
use the input.
The (easily soluble) main problem is, that the method then can not get the
input value this way, because it tries to read it from the yet open input
form - and can't if the window is still closed.
TRY
foInput.textbuffer.unlockRecord()
mmRet=foInput.textbuffer <<< this gets the value from the open
form
foInput.close()
if stRetValue<>"OK" then
loByPass=FALSE
RETURN
endIf
onFail
;|| The input-form was closed anyhow (e.g. Alt F4))
ErrorShow()
loByPass=FALSE
RETURN
endTRY
If you try to get a value from a closed form (Ctrl F4) then the method
branches to the onFail block.
I did no further error handling in the example, only ErrorShow(). And that
showed you the error message.
The work around:
Let all as it is, but change the code in the onFail-block:

onFail
;|| The input-form was closed anyhow (e.g. Alt F4))
;ErrorShow() <<< delete it
ErrorClear()
dmGet("textbuffer","textbuffer",mmRet)
;loByPass=FALSE <<< delete it
;RETURN<<< delete it
endTRY

Therefore you *must* add the "textbuffer.db" - or what ever name fits
better for you - into the data-model of the main form.
The dmGet(...) avoids a TCursor and you'll get the input-value directly
from the table bound to the input memofield.
If you do so, your code will be more universal. You can work with buttons
or close the input-form in any other way.

By the way:
As the code resides in the arrive-method on form's level, you only need it
once. If you don't apply more restriction it will automatically work with
all memo fields on your main form. This was, I remember, what you
intended, isn't it?

Feel free to change or use my example. As always in our common programming
field nothing is coming only from one brain. It's the stuff influenced by
a lot of good willed people here since long time.
HTH!

Egbert, 03:04 AM. At about 05:00 PM I'll go back to Spain.







Reply With Quote
  #6  
Old   
Egbert Babst
 
Posts: n/a

Default Re: memo field handling - 07-17-2006 , 04:25 PM



Frank,
glad I could help :-)

Egbert, 11:25 PM in Spain

"Frank Cutre" <frankc (AT) fjcwest (DOT) com> schrieb im Newsbeitrag
news:O4CdneuDvdweASbZnZ2dnUVZ_smdnZ2d (AT) adelphia (DOT) com...
Quote:
Hi Egbert,

YEEEEEEEES BABY !!! ... just what the doctor ordered!... we be happening!



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.