Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Fields that values are changed by user input
Message
From
01/08/2008 04:52:59
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
01/08/2008 04:24:31
Luis Santos
Biglevel-Soluções Informáticas, Lda
Portugal
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Vista
Database:
MS SQL Server
Miscellaneous
Thread ID:
01335448
Message ID:
01335760
Views:
14
>Hello Cetin
>
>could you give me a very simple example with getfldstate() . getfldstate() have parameters, because i need to check a lot of fields, do i must specify al??
>
>
>
>scatter name loOld ,and compare the values with the current ones to find changed ones.
>
>With scatter how can check for example 4 field values to compare?
>some little example will help.
>
>Many thanks
>Luis Santos


lcState = getfldstate(-1,'myAlias')
gets all field states at once into a string (+ delete flag as the first one). But a loop with field() would do better IMHO:
LOCAL ix
FOR ix = 1 TO FCOUNT('myAlias')
 IF GETFLDSTATE(m.ix,'myAlias') % 2 = 0
   ? FIELD(m.ix,'myAlias') + ' has changed'
 endif
endfor
Problem with getfldstate: If you modify a field but before saving restore the old value, the field is still detected as modified (you can override with SetFldState but cumbersome IMHO).

Scatter name is a better one from my POV.

Before any edit starts (typically just after record pointer is positioned in navigation controls):
scatter name thisform.oRecordBuffer memo
Where a detetction is needed (instead of GetFldState):
local loRecord
scatter name loRecord memo
if compobj(loRecord, thisform.oRecordBuffer) && they're same no change
*...
else
 local ix, luOld, luCur
   for ix = 1 to fcount()
        luOld = eval("loRecord."+field(m.ix))
        luNew = eval("thisform.oRecordBuffer."+field(m.ix))
        if  !( (isnull(m.luOld) and isnull(m.luNew)) or m.luOld == m.luNew) 
         ? FIELD(m.ix) + ' has changed'
      endif
   endfor
endif
PS: Please note that code is the top off my head, Would be enhanced and made part of a generic routine.

PS2: If you use "scatter name" approach and scatter name aSomeArray[m.index] at some "checkpoint"s then you provide N level undo capability.
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform