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