Guest User

Untitled

a guest
Jul 26th, 2017
602
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 2.71 KB | None | 0 0
  1. Procedure GetPIORecordFields;
  2. {Creates a worksheet showing the display and field names}
  3. {for the first selected object on the active layer}
  4. {Useful for determining the record.field names required}
  5. {for use in a worksheet.}
  6.  
  7. {Updated May 2017}
  8. {Fixed bug with table not having enought cells in VW2017}
  9.  
  10. {Corrected December 11, 2008}
  11. {Now shows correct field types}
  12.  
  13. {Updated October 29, 2008}
  14. {Now includes the field type for each field}
  15.  
  16. {January 30, 2008}
  17. {© 2008, Coviana, Inc - Pat Stanford [email protected]}
  18. {Licensed under the GNU Lesser General Public License}
  19.  
  20. {Modified 8/19/08  Pat Stanford}
  21. {Now puts quotes around both record and field instead of both combined}
  22.  
  23. {Modified 8/19/08 Pat Stanford}
  24. {Now displays non-localized field names if no localization}
  25.  
  26. Var H1  ,H2                 :Handle;
  27.         S1,S2,S3,S4,S5,S6, S7       :String;
  28.         N1, N2, N3              :Integer;
  29.         WSH                     :Handle;
  30.         B1                          :Boolean;
  31.  
  32. Begin
  33.     H1:=FSActLayer; {The active object}
  34.     H2:=GetRecord(H1,NumRecords(H1));  {Handle to the first record}
  35.     If H2 <> Nil then
  36.         Begin                               {If a record exists then create worksheet}
  37.             S1:=GetName(H2);
  38.             N1:=NumFields(H2);
  39.             N2:=1;
  40.             S3:='';
  41.             WSH:=CreateWS(Concat(S1,' ',Date(2,1)),N1+3,4);
  42.             SetWSPlacement(WSH,200,200,800,850);
  43.  
  44.             SetWSColumnWidth(WSH,1,1,200);
  45.             SetWSColumnWidth(WSH,2,2,200);
  46.             SetWSCOlumnWidth(WSH,3,3,200);
  47.             SetWSCOlumnWidth(WSH,4,4,200);
  48.             SetWSCellFormula(WSH,1,1,1,1,Concat('Parameter Fields for PIO: ',S1));
  49.             SetWSCellFormula(WSH,3,1,3,1,'Display Name');
  50.             SetWSCellFormula(WSH,3,2,3,2,'Cell Formula');
  51.             SetWSCellFormula(WSH,3,3,3,3,'Field Type');
  52.             SetWSCellFormula(WSH,3,4,3,4,'Current value');
  53.  
  54.             While N2<=N1 Do
  55.                 Begin                               {populate the worksheet with all the fields}
  56.                     S2:=GetFldName(H2,N2);
  57.                     S3:=Concat(Chr(39),S1,CHR(39),'.',CHR(39),S2,Chr(39));
  58.                     SetWSCellFormula(WSH,N2+3,2,N2+3,2,S3);
  59.  
  60.                     B1:=GetLocalizedPluginParameter(S1,S2,S4);
  61.                     if S4='' then S5:=S2 else S5:=S4;
  62.                     SetWSCellFormula(WSH,N2+3,1,N2+3,1,S5);
  63.  
  64.                     N3:=GetFldType(H2,N2);
  65.                    
  66.                     Case N3 of
  67.                         1:  S6:='Integer';
  68.                         2: S6:='Boolean';
  69.                         3: S6:='Real';
  70.                         4:  S6:='Text';
  71.  
  72.  
  73.                         7: S6:='Real - Coordinate Displacement';
  74.                         8: S6:='Text - Popup Menu Item';
  75.                         9: S6:='Text - Radio Button';
  76.                         10: S6:='Real - Coodinate X Location';
  77.                         11: S6:='Real - Coordinate Y Location';
  78.  
  79.  
  80.                         14: S6:='Static Text';
  81.  
  82.                         Otherwise S6:='Some Numeric Format';
  83.                     End;
  84.        
  85.                     SetWSCellFormula(WSH,N2+3,3,N2+3,3,S6);
  86.                    
  87.                     S7:=GetRField(H1,GetName(H2), S2);
  88.                     SetWSCellFormula(WSH, N2+3,4,N2+3,4, S7);
  89.  
  90.                     N2:=N2+1;
  91.                 end;
  92.  
  93.             ShowWS(WSH,True);
  94.             SetTopVisibleWS(WSH);
  95.            
  96.         end;
  97. End;
  98.  
  99. Run(GetPIORecordFields);
Advertisement
Add Comment
Please, Sign In to add comment