>use TableName alias FunnyTableName >repl Field1 with 'abc' > > >FUNCTION NewModNumber > >LPARAMETERS tcTable, tcField >&& tcTable should be TableName >&& alias (in the case above) should be FunnyTableName (caps) > >assert (upper(m.tcTable) == CursorGetProp('SourceName')) message 'Not on table ' + m.tcTable && test > >LOCAL liModNumber > >liModNumber = AssignModNumber( m.tcTable, m.tcField ) > >assert (upper(m.tcTable) == CursorGetProp('SourceName')) message 'Not on table ' + m.tcTable && test > >REPLACE (m.tcField) WITH m.liModNumber >RETURN .T. > >endfunc >>
>>>FUNCTION NewModNumber >>> >>>LPARAMETERS tcTable, tcField >>> >>>LOCAL liModNumber >>>> >>>liModNumber = AssignModNumber( m.tcTable, m.tcField ) >>>REPLACE (m.tcField) WITH m.liModNumber >>>RETURN .T. >>> >>>endfunc >>>>>>
>>>*--------------------------------------------------------------------------- >>>function do_it() >>> >>> create cursor ppp (ppp I) >>> =afields(aa) >>> use >>> aa[1,10] = 'ValidateMyRecord()' >>> >>> create cursor ppp from array aa >>> select 999 && get off the alias >>> >>> insert into ppp values (2) >>> repl ppp with 500 in ppp >>>endfunc >>>*--------------------------------------------------------------------------- >>>function ValidateMyRecord() >>> >>> acti screen >>> ?'Called' >>> >>> repl ppp with 1000 >>> repl ppp with 1100 >>> repl ppp with 1200 >>> >>>endfunc >>>*--------------------------------------------------------------------------- >>>>>>
FUNCTION NewModNumber >>>> >>>>LPARAMETERS tcTable, tcField >>>> >>>>LOCAL liModNumber >>>> >>>>liModNumber = AssignModNumber( tcTable, tcField ) >>>>REPLACE ( tcField ) WITH liModNumber IN ( tcTable ) >>>> >>>>RETURN .T. >>>>** End NewModNumber >>>>>>>>I am getting the error "Illegal recursion in rule evaluation" when the REPLACE statement is executed.
*********************************** >>>>** from Craig Berntson's Knowledgebase - 8/24/99 >>>>** used to generate ModNumbers >>>>FUNCTION AssignModNumber >>>> >>>>LPARAMETERS tcTable, tcField >>>> >>>>LOCAL lnArea, liModNumber >>>> >>>>* Save current work area >>>>lnArea = SELECT() >>>> >>>>IF !USED("GeneratePK") >>>> USE sagenpk IN 0 SHARED ALIAS GeneratePK >>>>ENDIF >>>>SELECT GeneratePK >>>>SET ORDER TO TAG GPK_PK >>>> >>>>* FLOCK seems to work a bit better than RLOCK. >>>>* I've never had a problem with it >>>>DO WHILE !FLOCK() >>>>ENDDO >>>> >>>>SEEK UPPER(tcTable) >>>>IF FOUND() >>>> REPLACE gpk_CurrentModNumber WITH gpk_CurrentModNumber + 1 >>>> liModNumber = gpk_CurrentModNumber >>>>ELSE >>>> INSERT INTO GeneratePK ( GPK_PK, gpk_CurrentNumber, gpk_CurrentModNumber ) ; >>>> VALUES ( UPPER( tcTable ), 0, 1 ) >>>> liModNumber = 1 >>>>ENDIF >>>> >>>>FLUSH >>>>UNLOCK >>>> >>>>SELECT (lnArea) >>>>RETURN liModNumber >>>>** End AssignModNumber >>>>>>>>