阅读:2655回复:0
addrecno.ave
<P>' Name: View.AddRecNumFieldToThemes<BR>'<BR>' Title: Adds a Recno attribute to all active FTabs<BR>'<BR>' Topics: Views<BR>'<BR>' Description: Adds a Recno attribute to Ftab of all active themes, <BR>' if it doesn't exist, and populates it. If it already <BR>' exists, the user is prompted as to whether they want <BR>' it's values updated or not. <BR>'<BR>' Requires: At least one active theme that you can write to.<BR>'<BR>' Self: <BR>'<BR>' Returns: </P>
<P><BR>theView = av.GetActiveDoc<BR>themesList = theView.GetActiveThemes<BR>if (themesList.Count = 0) then<BR> MsgBox.Error("No active themes in view.","Aborting")<BR> exit<BR>end<BR>for each atheme in themesList<BR> currentFtab = atheme.GetFtab<BR> addRecno = FALSE<BR> hasRecno = FALSE<BR> updateattr = FALSE<BR> for each attr in currentFtab.GetFields<BR> if (attr.AsString.UCase = "RECNO") then<BR> hasRecno = TRUE<BR> if (MsgBox.YesNo(atheme.AsString+" contains RECNO attribute."+nl+<BR> "Do you want to update it?","Update",FALSE)) then<BR> updateattr = TRUE<BR> break<BR> else<BR> break<BR> end<BR> end<BR> end<BR> numRecs = currentFTab.GetNumRecords<BR> if (hasRecno.Not) then<BR> addRecno = (MsgBox.YesNo("Add Record Number Attribute "+nl+<BR> "to "+atheme.AsString+"?","Query",TRUE))<BR> if (addRecno) then<BR> currentFtab.SetEditable(TRUE)<BR> recAttr = Field.Make("Recno",#FIELD_LONG,8,0)<BR> av.ShowMsg("Adding Recno Attribute to "+atheme.AsString+"...")<BR> currentFtab.AddFields({recAttr})<BR> av.ClearMsg<BR> end<BR> end<BR> if ((updateattr) or (addRecno)) then <BR> currentFtab.SetEditable(TRUE)<BR> recnoField = currentFtab.FindField("Recno")<BR> for each recNum in currentFtab<BR> recno = ( recNum + 1 ).SetFormat("d").AsString<BR> currentFtab.SetValue( recnoField, recNum, recno )<BR> av.ShowMsg("Populating Recno Attribute of "+atheme.AsString+"...")<BR> proceed = av.SetStatus((recNum / numRecs) * 100)<BR> if ( proceed.Not ) then<BR> av.ClearStatus<BR> av.ShowMsg( "Stopped" )<BR> exit<BR> end<BR> end<BR> currentFtab.SetEditable(FALSE)<BR> av.SetStatus(100)<BR> av.ClearMsg<BR> av.ClearStatus<BR> end<BR>end</P> |
|