STATISTICA







STATISTICA BASIC Program ModifyScrollNames.stb

{{This program illustrates how to automatically reformat the names of columns and rows of a Scrollsheet by operating on the active Scrollsheet on screen. It changes any column & row name currently in the form 'G_1:4' to the form '4'.}

Program written, modified, or edited at StatSoft, Inc.}


RandomAccess;
{get current Scrollsheet}
scroll:=GetScrollsheet(0);
{get number of rows & columns in the Scrollsheet}
nrows:=ScrollsheetGetNbRows (scroll);
ncols:=ScrollsheetGetNbCols (scroll);
{start loop for changing row names}
for i:=1 to nrows do begin
   {get current row name}
   ScrollsheetGetRowName (scroll, i, Name$);
   {get first 2 characters of row name}
   str$:=Mid (Name$, 1, 2);
   {check if row name is in 'G_1:4' form and delete all necessary characters to put in '4' form}
   if str$='G_' then begin
      if (i>=1) and (i<=9) then Name$:=SDelete (Name$, 1, 4)
      else if (i>=10) and (i<=99) then Name$:=SDelete(Name$, 1, 5)
      else if (i>=100) and (i<=999) then Name$:=SDelete(Name$,1,6)
      else if (i>=1000) and (i<=9999) then Name$:=SDelete(Name$,1,7)
      else Name$:=Str (i, 8, 0);
   end;
   {set new row name}
   ScrollsheetSetRowName (scroll, i, Name$);
end;
{start loop for changing column names}
for i:=1 to ncols do begin
   {get current column name}
   ScrollsheetGetColName (scroll, i, Name1$, Name2$);
   {get first 2 characters of column name}
   str$:=Mid (Name2$, 1, 2);
   {check if column name is in 'G_1:4' form and delete all necessary characters to put in '4' form}
   if str$='G_' then begin
      if (i>=1) and (i<=9) then Name2$:=SDelete (Name2$, 1, 4)
      else if (i>=10) and (i<=99) then Name2$:=SDelete(Name2$, 1, 5)
      else if (i>=100) and (i<=999) then Name2$:=SDelete(Name2$,1,6)
      else if (i>=1000) and (i<=9999) then Name2$:=SDelete(Name2$,1,7)
      else Name2$:=Str (i, 8, 0);
   end;
    {set new column name}
   ScrollsheetSetColumnName (scroll, i, ' ', Name2$);
end;
Back to List of Programs



[StatSoft]
2300 East 14th Street, Tulsa, OK 74104
Phone: (918) 749-1119; Fax: (918) 749-2217

[StatSoft]e-mail: info@statsoft.com

©Copyright StatSoft, Inc., 1984-2004.
StatSoft, StatSoft logo, STATISTICA, SEWSS, SEDAS, Data Miner, SEPATH and GTrees are trademarks of StatSoft, Inc.