Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simply append to a memo field?

Status
Not open for further replies.

mep1

IS-IT--Management
Joined
Jun 18, 2003
Messages
67
Location
US
Hi all,

Once again I am baffled attempting to perform what I thought would be a very simple task.

I have a memo field in a table, I would like to simply append a line of text to this field when the user performs certain functions, but I cannot seem to find the proper method to do so.

I see it is easy to append a .txt file for example, but it seems like too much work to write to a temp .txt file, then update the memo field, then delete the .txt file... and the MODIFY MEMO command doesn't seem to have what I need.

Am I overlooking something simple?

Thanks for the help!

MEP
 
HI

APPEND BLANK
REPLACE myMemoField WITH CHR(13)

or

SCATTER MEMVAR MEMO BLAMK
m.myMemoField = CHR(13) && carriage return
INSERT INTO myAlias FROM MEMVAR

I dont know why you need a line in memo... may be a certain number of spaces... then..
REPLACE myMemoField WITH SPACE(20).. whatever.

:-)

ramani :-)
(Subramanian.G),FoxAcc, ramani_g@yahoo.com

 
I appologize I may not have worded my question correctly.

I am looking to build an audit trail of information in this memo field, for example... when a user performs a function such as logging in, the memo field will be appended with the users login information, a timestap, etc...

myString = "MEP Logged in @ 12:00:00:00"

I would like this string appended to the end of the memo field while retaining all the information in it...

Thanks again

 
Do you mean you want to add additional text to a
memo field when the user performs the said action?

If so, then just add the info to the information
already there.

i.e.

replace memofield with memofield + chr(13)+ ;
"additional info" in "table"


You could also use the SQL update command if many
records need to be updated, but for single records,
the replace command will be faster.

i.e.

UPDATE Table SET table.memofield = table.memofield + ;
chr(13)+ "additional info" where (condition == .t.)

Darrell



'We all must do the hard bits so when we get bit we know where to bite' :-)
 
REPLACE MyTable.MyMemo WITH MyLine ADDITIVE

Slighthaze = NULL
 
mep1,

For audit trail, you can use:

replace memofield with memofield + chr(13) + TTOC(DATE())+" : " + myString

Peping
 
I must be missing something here...
Why would:

replace memofield with memofield + chr(13)+ ;
"additional info" in "table"


...be used instead of:

MyAddition = chr(13)+ "additional info"
replace memofield with Myaddition in "table" ADDITIVE


...the first way of concatenating onto the end of a memo field (I've seen it suggested twice here) by replacing the entire memo field with it's contents and an additional string seems highly inefficient to me...is there a compatibility issue or some reason to use it instead? I am not meaning to be critical, I am seriously wondering if I am indeed missing something. Anyone that can shed some light on this for me I would appreciate it. Thanks.


Slighthaze = NULL
 
My 2cents
I have found from time to time that memo fields can sometimes be easily corruptable considering the amount of traffic, using this for audit trail along with searchability after the fact. I use a simple table with timestamp and an array calling a function to complete the data collected with insert into audit_tab from array MyAudit

Steve Bowman
steve.bowman@ultraex.com

 
Yes it appears the buzzword ADDITIVE was what I was looking for... of course after reading the help files on the MEMO field and not seeing anything.... who would have thought I needed to read the help for REPLACE while my goal was to not replace but append a line of text :)

Anyway, thanks for the help everyone.

RE: Steveb7...

You feel it is better to build an array comprised of the audit information, then add this array to your audit table? I thought of this but I wanted to avoid adding a new record for each individual audit item... could you perhaps elaborate a little more on your preferred method?

Thanks!

MEP
 
a quick audit trail


FUNCTION audit
PARAMETERS cAuditString,cUserInfo


IF !USED("AuditTab")
IF !FILE("AuditTab.dbf")
cOldWorkArea=SELECT(0)
CREATE TABLE AuditTab (AuditInf C(30), TimeStamp T(10), UserName C(20))
USE IN AuditTab
SELECT (cOldWorkArea)
ENDIF
USE AuditTab IN 0 SHARED
ENDIF

IF TYPE("aAuditData")="U"
PUBLIC aAuditData
dimension aAuditData[3]
ENDIF
IF TYPE(&quot;cAuditString&quot;)<>&quot;C&quot;
cAuditString=&quot;No String Passed&quot;
ENDIF
IF TYPE(&quot;cUserInfo&quot;)<>&quot;C&quot;
cUserInfo=&quot;No User Passed&quot;
ENDIF


aAuditData[1]=ALLTRIM(cAuditString)
aAuditData[2]=DATETIME()
aAuditData[3]=ALLTRIM(cUserInfo)

INSERT INTO AuditTab FROM ARRAY aAuditData

return
ENDFUNC


you then can call
=Audit(cAuditString,cUserInfo)
like
=Audit(&quot;User Logon&quot;,&quot;Steve&quot;)

the process may have more overhead (minimal) but gives you a searchable audit trail. With some minor changes you could add some more fields to contain other info about the audited process


Steve Bowman
steve.bowman@ultraex.com

 
steveb7
Thanks for the example! We are still in the planning phase and are still trying to decide on the best data structure for the audit trail.

Cheers,
E
 
My suggestion is to create an audit log using a separate table. Forget the memo field. Avoid the flakiness inherent in memo fields, and avoid memo file bloat.
You can append a record to a separate table when a user logs in, changes a record whatever. For a log in, add a record with the appropriate info. For a record change, save off the old values and compare with new ones. Then throw a record in the audit table with for instance, table name, field name, old and new values. Granted, the audit file can grow pretty fast, but it will be more stable and easier to query than say, a substring search of a memo field later on.



-Dave S.-
[cheers]
Even more Fox stuff at:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top