Console spreadsheet для PascalABC.Net: различия между версиями

Содержимое удалено Содержимое добавлено
→‎К переименованию: Использован шаблон.
Нет описания правки
Строка 15:
<source lang="Pascal">
// код не изменять, сам его писал
//Unit Console_spreadsheet
//Interface
uses
Uses CRT;
CRT;
Var
Graph_color,Graph_mode:string;
Start3,current_X_ceil_adress,current_Y_ceil_adress,start2,start,spreadsheet_max_size_X:integer;
spreadsheet_max_size_Y:integer;
symbol:string;
grid:boolean;
Max_value_in column,SHIFT,current_spreadsheet_column_size:integer;
current_spreadsheet_ceil_string_coordinate:integer;
current_spreadsheet_ceil_column_coordinate:integer;
current_spreadsheet_background_color:string;
current_spreadsheet_ceil_content,current_spreadsheet_border_color,current_spreadsheet_text_color:string;
string_spreadsheet:array[0..80,0..80] of string;
Max_values_in_spreadsheet:array[0..80] of string;
spreadsheet_type:string;
procedure Console_spreadsheet_set_background_color(current_spreadsheet_background_color:string);
Begin
if (current_spreadsheet_background_color='red') then CRT.TextBackground(red);
if (current_spreadsheet_background_color='blue') then CRT.TextBackground(blue);
if (current_spreadsheet_background_color='yellow') then CRT.TextBackground(yellow);
if (current_spreadsheet_background_color='green') then CRT.TextBackground(green);
if (current_spreadsheet_background_color='orange') then CRT.TextBackground(orange);
if (current_spreadsheet_background_color='black') then CRT.TextBackground(black);
if (current_spreadsheet_background_color='white') then CRT.TextBackground(white);
if (current_spreadsheet_background_color<>'red') or (current_spreadsheet_background_color<>'blue') or (current_spreadsheet_background_color<>'yellow') or (current_spreadsheet_background_color<>'green') or (current_spreadsheet_background_color<>'orange') or (current_spreadsheet_background_color<>'black') or (current_spreadsheet_background_color<>'white') then begin CRT.TextBackground(white); CRT.TextColor(Black); Console.System.WriteLine('Function parameter «Console_spreadsheet_set_baxkground» receives an invalid value.'); end;
End;
 
var
procedure Console_spreadsheet_set_text_color(Console_spreadsheet_text_color:string);
Graph_color, Graph_mode: string;
Begin
Start3, current_X_ceil_adress, current_Y_ceil_adress, start2, start, spreadsheet_max_size_X: integer;
if (current_spreadsheet_text_color<>'red') or (current_spreadsheet_text_color<>'blue') or (current_spreadsheet_text_color<>'yellow') or (current_spreadsheet_text_color<>'green') or (current_spreadsheet_text_color<>'orange') or (current_spreadsheet_text_color<>'black') or (current_spreadsheet_text_color<>'white') then begin CRT.TextBackground(white); CRT.TextColor(Black); Console.System.WriteLine('Function parameter «Console_spreadsheet_set_text_color» receives an invalid value.'); end;
spreadsheet_max_size_Y: integer;
End;
symbol: string;
grid: boolean;
Max_value_in_column, SHIFT, current_spreadsheet_column_size: integer;
current_spreadsheet_ceil_string_coordinate: integer;
current_spreadsheet_ceil_column_coordinate:integer ;
current_spreadsheet_background_color: string;
current_spreadsheet_ceil_content, current_spreadsheet_border_color, current_spreadsheet_text_color: string;
string_spreadsheet: array[0..80, 0..80] of string;
Max_values_in_spreadsheet: array[0..80] of integer;
spreadsheet_type: string;
 
procedure Console_spreadsheet_set_border_colorConsole_spreadsheet_set_background_color(current_spreadsheet_border_colorcurrent_spreadsheet_background_color: string);
begin
Begin
if (current_spreadsheet_background_color = 'red') then CRT.TextBackground(red);
if (current_spreadsheet_border_color<>'red') or (current_spreadsheet_border_color<>'blue') or (current_spreadsheet_border_color<>'yellow') or (current_spreadsheet_border_color<>'green') or (current_spreadsheet_border_color<>'orange') or (current_spreadsheet_border_color<>'black') or (current_spreadsheet_border_color<>'white') then begin CRT.TextBackground(white); CRT.TextColor(Black); Console.System.WriteLine('Function parameter «Console_spreadsheet_set_border_color» receives an invalid value.'); end;
if (current_spreadsheet_background_color = 'blue') then CRT.TextBackground(blue);
End;
if (current_spreadsheet_background_color = 'yellow') then CRT.TextBackground(yellow);
if (current_spreadsheet_background_color = 'green') then CRT.TextBackground(green);
//if (current_spreadsheet_background_color='orange') then CRT.TextBackground(orange);
if (current_spreadsheet_background_color = 'black') then CRT.TextBackground(black);
if (current_spreadsheet_background_color = 'white') then CRT.TextBackground(white);
if (current_spreadsheet_background_color <> 'red') or (current_spreadsheet_background_color <> 'blue') or (current_spreadsheet_background_color <> 'yellow') or (current_spreadsheet_background_color <> 'green') or (current_spreadsheet_background_color <> 'orange') or (current_spreadsheet_background_color <> 'black') or (current_spreadsheet_background_color <> 'white') then begin CRT.TextBackground(white); CRT.TextColor(Black); WriteLn('Function parameter «Console_spreadsheet_set_baxkground» receives an invalid value.'); end;
end;
 
procedure Console_spreadsheet_set_text_color(Console_spreadsheet_text_color: string);
Procedure Console_spreadsheet_hide_grid();
begin
Begin
if (current_spreadsheet_text_color <> 'red') or (current_spreadsheet_text_color <> 'blue') or (current_spreadsheet_text_color <> 'yellow') or (current_spreadsheet_text_color <> 'green') or (current_spreadsheet_text_color <> 'orange') or (current_spreadsheet_text_color <> 'black') or (current_spreadsheet_text_color <> 'white') then begin CRT.TextBackground(white); CRT.TextColor(Black);WriteLn('Function parameter «Console_spreadsheet_set_text_color» receives an invalid value.'); end;
grid=false;
Endend;
 
procedure Console_spreadsheet_set_border_color(current_spreadsheet_border_color: string);
Procedure Console_spreadsheet_show_grid();
begin
Begin
if (current_spreadsheet_border_color <> 'red') or (current_spreadsheet_border_color <> 'blue') or (current_spreadsheet_border_color <> 'yellow') or (current_spreadsheet_border_color <> 'green') or (current_spreadsheet_border_color <> 'orange') or (current_spreadsheet_border_color <> 'black') or (current_spreadsheet_border_color <> 'white') then begin CRT.TextBackground(white); CRT.TextColor(Black); WriteLn('Function parameter «Console_spreadsheet_set_border_color» receives an invalid value.'); end;
grid=true;
Endend;
 
procedure Console_spreadsheet_hide_grid();
Procedure Console_spreadsheet_adding_values_method_SHIFT(SHIFT:integer;symbol:string);
begin
Begin
grid := false;
Method=1;
Endend;
 
procedure Console_spreadsheet_show_grid();
Procedure Console_spreadsheet_set_size_for_X_axis(spreadsheet_max_size_X);
begin
Begin
grid := true;
End;
end;
 
{procedure Console_spreadsheet_adding_values_method_SHIFT(SHIFT: integer; symbol: string);
Procedure Console_spreadsheet_set_size_for_Y_axis(spreadsheet_max_size_Y);
begin
Begin
Method := 1;
End;
end;}
 
procedure Console_spreadsheet_set_size_for_X_axis(spreadsheet_max_size_X: integer);
Procedure Console_spreadsheet_set_ceil_content(current_spreadsheet_ceil_string_coordinate:integer;current_spreadsheet_ceil_column_coordinate:integer;current_spreadsheet_ceil_content:string); // доделать
begin
end;
If (current_spreadsheet_ceil_string_coordinate>spreadsheet_max_size_X) or (current_spreadsheet_ceil_column_coordinate>spreadsheet_max_size_Y) then
Begin
CRT.TextBackground(white); CRT.TextColor(Black); Console.System.WriteLine('The cell is outside the table.');
End
Else
Begin
string_spreadsheet[current_spreadsheet_ceil_string_coordinate,current_spreadsheet_ceil_column_coordinate]:=current_spreadsheet_ceil_content;
End;
current_spreadsheet_ceil_string_coordinate:=0;
current_spreadsheet_ceil_column_coordinate:=0;
// сбор макс. значений таблицы в столбцах
// begin
For start:=1 to spreadsheet_max_size_X do
Begin
 
procedure Console_spreadsheet_set_size_for_Y_axis(spreadsheet_max_size_Y: integer);
For start2:=1 to spreadsheet_max_size_Y do
begin
Begin
end;
If (string_spreadsheet[current_spreadsheet_ceil_string_coordinate,current_spreadsheet_ceil_column_coordinate]>Max_value_in column) then begin Max_value_in column:=string_spreadsheet[current_spreadsheet_ceil_string_coordinate,current_spreadsheet_ceil_column_coordinate]; current_spreadsheet_ceil_column_coordinate:=current_spreadsheet_ceil_column_coordinate+1; end else begin current_spreadsheet_ceil_column_coordinate:=current_spreadsheet_ceil_column_coordinate+1; end;
End
Max_values_in_spreadsheet[current_spreadsheet_ceil_string_coordinate]:=Max_value_in column;
current_spreadsheet_ceil_string_coordinate:=current_spreadsheet_ceil_string_coordinate+1;
End;
// end
// вывод таблицы
current_spreadsheet_ceil_string_coordinate:=0;
current_spreadsheet_ceil_column_coordinate:=0;
For start:=1 to spreadsheet_max_size_Y do
Begin
// тут остановился
 
procedure Console_spreadsheet_set_ceil_content(current_spreadsheet_ceil_string_coordinate: integer; current_spreadsheet_ceil_column_coordinate: integer; current_spreadsheet_ceil_content: string);// доделать
For start2:=1 to spreadsheet_max_size_X do
begin
Begin // здесь
if (current_spreadsheet_ceil_string_coordinate > spreadsheet_max_size_X) or (current_spreadsheet_ceil_column_coordinate > spreadsheet_max_size_Y) then
// назначение цвета для вывода значния ячейки
begin
CRT.TextBackground(white); CRT.TextColor(Black); WriteLn('The cell is outside the table.');
end
Else
begin
string_spreadsheet[current_spreadsheet_ceil_string_coordinate, current_spreadsheet_ceil_column_coordinate] := current_spreadsheet_ceil_content;
end;
current_spreadsheet_ceil_string_coordinate := 0;
current_spreadsheet_ceil_column_coordinate := 0;
// сбор макс. значений таблицы в столбцах
// begin
for var start := 1 to spreadsheet_max_size_X do
begin
for var start2 := 1 to spreadsheet_max_size_Y do
begin
if (string_spreadsheet[current_spreadsheet_ceil_string_coordinate, current_spreadsheet_ceil_column_coordinate] > Max_value_in_column) then begin Max_value_in_column := string_spreadsheet[current_spreadsheet_ceil_string_coordinate, current_spreadsheet_ceil_column_coordinate]; current_spreadsheet_ceil_column_coordinate := current_spreadsheet_ceil_column_coordinate + 1; end else begin current_spreadsheet_ceil_column_coordinate := current_spreadsheet_ceil_column_coordinate + 1; end;
end;
Max_values_in_spreadsheet[current_spreadsheet_ceil_string_coordinate] := Max_value_in_column;
current_spreadsheet_ceil_string_coordinate := current_spreadsheet_ceil_string_coordinate + 1;
end;
// end
// вывод таблицы
current_spreadsheet_ceil_string_coordinate := 0;
current_spreadsheet_ceil_column_coordinate := 0;
for start := 1 to spreadsheet_max_size_Y do
begin
// тут остановился
for start2 := 1 to spreadsheet_max_size_X do
begin// здесь
// назначение цвета для вывода значния ячейки
if (current_spreadsheet_text_color = 'red') then CRT.TextColor(red);
if (current_spreadsheet_text_color = 'blue') then CRT.TextColor(blue);
if (current_spreadsheet_text_color = 'yellow') then CRT.TextColor(yellow);
if (current_spreadsheet_text_color = 'green') then CRT.TextColor(green);
if (current_spreadsheet_text_color = 'orange') then CRT.TextColor(orange);
if (current_spreadsheet_text_color = 'black') then CRT.TextColor(black);
if (current_spreadsheet_text_color = 'white') then CRT.TextColor(white);
// назначение цвета для вывода значния ячейки - end
// вывод значения ячейки
Write(string_spreadsheet[current_spreadsheet_ceil_string_coordinate, current_spreadsheet_ceil_column_coordinate]);
// вывод значения ячейки
// вывод пробелов до столбца
for start3 := 1 to Max_values_in_spreadsheet[current_spreadsheet_ceil_string_coordinate] do
begin
Write(' ');
end;
// вывод пробелов до столбца - end
// установка цвета столбца
if (current_spreadsheet_border_color = 'red') then CRT.TextColor(red);
if (current_spreadsheet_border_color = 'blue') then CRT.TextColor(blue);
if (current_spreadsheet_border_color = 'yellow') then CRT.TextColor(yellow);
if (current_spreadsheet_border_color = 'green') then CRT.TextColor(green);
if (current_spreadsheet_border_color = 'orange') then CRT.TextColor(orange);
if (current_spreadsheet_border_color = 'black') then CRT.TextColor(black);
if (current_spreadsheet_border_color = 'white') then CRT.TextColor(white);
// установка цвета столбца - end
Write('|');
current_spreadsheet_ceil_string_coordinate := current_spreadsheet_ceil_string_coordinate + 1;
end;
// вывод линейки
for start3 := 1 to spreadsheet_max_size_X do
begin
for start4 := 1 to Max_values_in_spreadsheet[current_spreadsheet_ceil_string_coordinate] do
begin
Write('-');
end;
Write('+');
end;
// вывод линейки - end
// Переход к следующей строке
current_spreadsheet_ceil_column_coordinate := current_spreadsheet_ceil_column_coordinate + 1;
end;
end;
 
procedure Console_spreadsheet_condition();
if (current_spreadsheet_text_color='red') then CRT.TextColor(red);
begin
if (current_spreadsheet_text_color='blue') then CRT.TextColor(blue);
// определить параметры, и доделать потом
if (current_spreadsheet_text_color='yellow') then CRT.TextColor(yellow);
end;
if (current_spreadsheet_text_color='green') then CRT.TextColor(green);
if (current_spreadsheet_text_color='orange') then CRT.TextColor(orange);
if (current_spreadsheet_text_color='black') then CRT.TextColor(black);
if (current_spreadsheet_text_color='white') then CRT.TextColor(white);
// назначение цвета для вывода значния ячейки - end
 
// вывод значения ячейки
Write(string_spreadsheet[current_spreadsheet_ceil_string_coordinate,current_spreadsheet_ceil_column_coordinate])
// вывод значения ячейки
 
// вывод пробелов до столбца
For start3:=1 to Max_values_in_spreadsheet[current_spreadsheet_ceil_string_coordinate] do
Begin
Write(' ');
End;
// вывод пробелов до столбца - end
 
// установка цвета столбца
if (current_spreadsheet_border_color='red') then CRT.TextColor(red);
if (current_spreadsheet_border_color='blue') then CRT.TextColor(blue);
if (current_spreadsheet_border_color='yellow') then CRT.TextColor(yellow);
if (current_spreadsheet_border_color='green') then CRT.TextColor(green);
if (current_spreadsheet_border_color='orange') then CRT.TextColor(orange);
if (current_spreadsheet_border_color='black') then CRT.TextColor(black);
if (current_spreadsheet_border_color='white') then CRT.TextColor(white);
// установка цвета столбца - end
Write('|');
current_spreadsheet_ceil_string_coordinate:=current_spreadsheet_ceil_string_coordinate+1;
End;
// вывод линейки
For start3:=1 to spreadsheet_max_size_X do
Begin
For start4:=1 to Max_values_in_spreadsheet[current_spreadsheet_ceil_string_coordinate] do
Begin
Write('-');
End;
Write('+');
End;
// вывод линейки - end
// Переход к следующей строке
current_spreadsheet_ceil_column_coordinate:=current_spreadsheet_ceil_column_coordinate+1;
End;
 
End;
 
Procedure Console_spreadsheet_condition();
Begin
// определить параметры, и доделать потом
End;
 
Procedure Console_spreadsheet_add_square(Graph_color:string,width:integer,height:integer,Center_X:integer,Center_Y:integer); // функция рисования
Begin
Var
Graph_color:string; width,height,Center_X,Center_Y:integer;
If (width>100) or (width<0) or (height>100) or (height<0) then
Begin
Clrscr; TextColor(Black; TextBackGround(White); WriteLn('Graph error: very big/small width/height!');
End
Else
Begin
// туто доделать
End;
End;
 
begin
Console_spreadsheet_set_size_for_Y_axis(10);
Console_spreadsheet_set_size_for_Y_axis(5);
end.
</source>