Difference between revisions of "SETFLDSTATE()"
From Recital Documentation Wiki
Yvonnemilne (Talk | contribs) (→<expN>) |
Yvonnemilne (Talk | contribs) |
||
| (4 intermediate revisions by one user not shown) | |||
| Line 1: | Line 1: | ||
==Purpose== | ==Purpose== | ||
| − | Function to | + | Function to assign a field modification value to a field or record |
==Syntax== | ==Syntax== | ||
| − | SETFLDSTATE(<expC>, < | + | SETFLDSTATE(<expC> | <expN1>, <expN2> [, <workarea | alias>]) |
| Line 12: | Line 12: | ||
==Description== | ==Description== | ||
| − | + | The SETFLDSTATE() function can be used to change the field modification value for a field. The field can be specified using the field name in <expC> or the field number in <expN1>. The value to be assigned is specified in <expN2>. | |
If the optional <workarea | alias> is specified, then the function will operate in the required location. | If the optional <workarea | alias> is specified, then the function will operate in the required location. | ||
| − | ====< | + | ====<expN2>==== |
{| class="wikitable" | {| class="wikitable" | ||
!Value||Description | !Value||Description | ||
|- | |- | ||
| − | |1||Field has not been modified | + | |1||Field has not been modified |
|- | |- | ||
| − | |2||Field has been modified | + | |2||Field has been modified |
|- | |- | ||
|} | |} | ||
| + | |||
| + | |||
==Example== | ==Example== | ||
<code lang="recital"> | <code lang="recital"> | ||
| + | close databases | ||
| + | clear | ||
| + | set exclusive off | ||
| + | open database southwind | ||
| + | use customers | ||
| + | // Set to known value before start | ||
| + | replace customerid with "ALFKI" | ||
| + | |||
| + | cursorsetprop("Buffering", 5, "customers") | ||
| + | messagebox("Buffering set to " +etos(cursorgetprop("Buffering"))) | ||
| + | |||
| + | ? "Original customerid value: " + customerid | ||
| + | ? "Curval(): " + curval("customerid") | ||
| + | ? "Oldval(): " + oldval("customerid") | ||
| + | ? "Fieldstate at start: " + getfldstate("customerid") | ||
| + | |||
| + | replace customerid WITH "RECIT" | ||
| + | |||
| + | // Alter in another session | ||
| + | ! recital -c "update southwind\!customers set customerid = 'MULTI' where recno() = 1" | ||
| + | ? "Someone else just updated the record!" | ||
| + | ? "New customerid value: " + customerid | ||
| + | ? "Curval(): " + curval("customerid") | ||
| + | ? "Oldval(): " + oldval("customerid") | ||
| + | ? "Fieldstate after replace: " + getfldstate("customerid") | ||
| + | tablerevert(.T.) | ||
| + | |||
| + | ? "Reverted customerid value: " + customerid | ||
| + | ? "Curval(): " + curval("customerid") | ||
| + | ? "Oldval(): " + oldval("customerid") | ||
| + | ? "Fieldstate after revert: " + getfldstate("customerid") | ||
| + | |||
| + | replace customerid WITH "RECIT" | ||
| + | ? "New customerid value: " + customerid | ||
| + | tableupdate(.T.) | ||
| + | ? "Updated customerid value: " + customerid | ||
| + | ? "Curval(): " + curval("customerid") | ||
| + | ? "Oldval(): " + oldval("customerid") | ||
| + | ? "Fieldstate after replace and update: " + getfldstate("customerid") | ||
| + | setfldstate("customerid",2) | ||
| + | ? "Fieldstate after set: " + getfldstate("customerid") | ||
| + | ? | ||
</code> | </code> | ||
Latest revision as of 11:25, 22 August 2011
Purpose
Function to assign a field modification value to a field or record
Syntax
SETFLDSTATE(<expC> | <expN1>, <expN2> [, <workarea | alias>])
See Also
CURSORGETPROP(), CURSORSETPROP(), CURVAL(), GETFLDSTATE(), OLDVAL(), TABLEREVERT(), TABLEUPDATE()
Description
The SETFLDSTATE() function can be used to change the field modification value for a field. The field can be specified using the field name in <expC> or the field number in <expN1>. The value to be assigned is specified in <expN2>.
If the optional <workarea | alias> is specified, then the function will operate in the required location.
<expN2>
| Value | Description |
|---|---|
| 1 | Field has not been modified |
| 2 | Field has been modified |
Example
close databases clear set exclusive off open database southwind use customers // Set to known value before start replace customerid with "ALFKI" cursorsetprop("Buffering", 5, "customers") messagebox("Buffering set to " +etos(cursorgetprop("Buffering"))) ? "Original customerid value: " + customerid ? "Curval(): " + curval("customerid") ? "Oldval(): " + oldval("customerid") ? "Fieldstate at start: " + getfldstate("customerid") replace customerid WITH "RECIT" // Alter in another session ! recital -c "update southwind\!customers set customerid = 'MULTI' where recno() = 1" ? "Someone else just updated the record!" ? "New customerid value: " + customerid ? "Curval(): " + curval("customerid") ? "Oldval(): " + oldval("customerid") ? "Fieldstate after replace: " + getfldstate("customerid") tablerevert(.T.) ? "Reverted customerid value: " + customerid ? "Curval(): " + curval("customerid") ? "Oldval(): " + oldval("customerid") ? "Fieldstate after revert: " + getfldstate("customerid") replace customerid WITH "RECIT" ? "New customerid value: " + customerid tableupdate(.T.) ? "Updated customerid value: " + customerid ? "Curval(): " + curval("customerid") ? "Oldval(): " + oldval("customerid") ? "Fieldstate after replace and update: " + getfldstate("customerid") setfldstate("customerid",2) ? "Fieldstate after set: " + getfldstate("customerid") ?
Products
Recital, Recital Server