unit fun_win;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, SynEdit;


 procedure shablon_fx();
 procedure input_output();
 procedure shablon_swing();
 procedure shablon_console();
 procedure console_cr_linux();
 procedure console_cr_run_linux();
 procedure console_cr_fx_linux();
 procedure shablon_applet();
 procedure jar_linux();
 procedure jar_win();
 procedure console_cr_win();
 procedure console_cr_fx_win();
 procedure console_run_linux();
 function Str_Char_Del(str: String; ch: Char): String;
 function Name_Package(str1: String): String;
 function Name_Package_Dir(str: String): String;
 procedure Name_Package_Create_Dir(str: String);
 function Find_Package(SynEdit1: TSynEdit): Integer;
 function rep(java_home: String):String;
 function First_Package_Word(str: String): String;
 
implementation
uses
  Unit1, Unit2;


function First_Package_Word(str: String): String;
var word, str0: String;
    p: Integer;
begin
str0:=str;
if LastDelimiter('.',str0)>0 then
 begin
    p:= LastDelimiter('.',str0);
    word := copy(str0, 0, p-1);
    str0:= word;
 end;
      First_Package_Word:= str0;
end;



function rep(java_home: String):String;
var java_home_new: String;
    len, i: Integer;
begin
  java_home_new:='';
  len:= length(java_home);
  for i := 1 to len do
      begin
        if java_home[i] = '\' then java_home_new:= java_home_new + java_home[i] + '\'
          else java_home_new:= java_home_new + java_home[i];
      end;
  rep:=java_home_new;
end;


function Find_Package(SynEdit1: TSynEdit): Integer;
var i, se_len, p_n: Integer;
begin
 p_n:=0;
 se_len:= SynEdit1.Lines.Count;
 for i := 0 to se_len-1 do
     begin
          if pos('package', SynEdit1.Lines.Strings[i])>0 then
          begin
           p_n:=i;
           break;
          end;
     end;
  Find_Package:=p_n;
end;


 procedure Name_Package_Create_Dir(str: String);
var str1: string;
    z, p, len: integer;
    list: TStringList;
begin
 str1:=str;
 list := TStringList.Create;
 while LastDelimiter('.',str1)>0 do
  begin
     p:= LastDelimiter('.',str1);
     len:= Length(str1);
     list.add(copy(str1, p+1, len));
     str1:=copy(str1, 0, p-1);
  end;
  list.add(str1);
  for z:=list.count-1 downto 0 do
  begin
    If Not DirectoryExists(list.strings[z]) then CreateDir (list.strings[z]);
        chdir(list.strings[z]);
  end;
  list.Destroy;
end;


  function Name_Package_Dir(str: String): String;
  var str0: String;
      p: Integer;
  begin
  str0:=str;
  while LastDelimiter('.',str0)>0 do
   begin
      p:= LastDelimiter('.',str0);
      str0[p]:='\';
   end;
	Name_Package_Dir:= str0;
  end;




function Name_Package(str1: String): String;
var str_return, s2: String;
    p_n: Integer;
begin
  str_return:= str1;
  p_n:=pos('package', str_return);
  if p_n>0 then
   begin
    if pos('//', str_return)> 0 then Name_Package:= ''
    else
     begin
      s2 := copy(str_return, p_n+7, Length(str_return));
      s2:= Str_Char_Del(s2, ' ');
      s2:= Str_Char_Del(s2, ';');
      Name_Package:=s2;
     end
   end
  else Name_Package:= '';
end;


// Удаление из стоки str всех символов заданых в параметре ch
function Str_Char_Del(str: String; ch: Char): String;
var str_return: String;
begin
    str_return:= str;
    while pos(ch, str_return)<>0 do
      begin
       Delete(str_return,pos(ch, str_return),1);
      end;
    Str_Char_Del:= str_return;
end;








procedure jar_win();
var sss, sss1, jarstr, dop :String;
    i, n:  integer;
begin
  if FileExists('file_dir.ini') then Form2.ListBox1.Items.LoadFromFile('file_dir.ini');
  Form1.SynEdit1.Lines.SaveToFile(fullFileName);
  list := TStringList.Create;
  ChDir(ExtractFileDir(fullFileName));
  FileName := ExtractFileName(fullFileName);
  i:= Length(FileName);
  sss1:=Copy(FileName,1,i-5);
  sss := 'main-class: ' + sss1;
  list.Clear;
  list.Add(sss);
  list.Add('');
  list.SaveToFile('MYMANIFEST.MF');
  list.Destroy;
  jarstr := DirJDK+ st_bin +'jar' + ' -cvfm '+ sss1 + '.jar' +' MYMANIFEST.MF ' + '*.class ';
  n:= Form2.ListBox1.Count;
  dop:='';
  //if FileExists(sss1+'$1' + '.class') then dop:= dop + sss1+'$1' + '.class ';
  //if FileExists(sss1+'$2' + '.class') then dop:= dop + sss1+'$2' + '.class ';
  //if FileExists(sss1+'$3' + '.class') then dop:= dop + sss1+'$3' + '.class ';
  //if FileExists(sss1+'$4' + '.class') then dop:= dop + sss1+'$4' + '.class ';
  //if FileExists(sss1+'$5' + '.class') then dop:= dop + sss1+'$5' + '.class ';
  //if FileExists(sss1+'$6' + '.class') then dop:= dop + sss1+'$6' + '.class ';
  //if FileExists(sss1+'$7' + '.class') then dop:= dop + sss1+'$7' + '.class ';
  //if FileExists(sss1+'$8' + '.class') then dop:= dop + sss1+'$8' + '.class ';
  //if FileExists(sss1+'$9' + '.class') then dop:= dop + sss1+'$9' + '.class ';
  //if FileExists(sss1+'$10' + '.class') then dop:= dop + sss1+'$10' + '.class ';
  //if FileExists(sss1+'$11' + '.class') then dop:= dop + sss1+'$11' + '.class ';
  if n>=0 then
     begin
         for i := 0 to n-1 do
         begin
              dop:= dop + Form2.ListBox1.Items.Strings[i] + ' ';
         end;
     end;

  Form1.ProcessUTF8_3.CommandLine:=jarstr + dop;
  Form1.ProcessUTF8_3.Execute;
  Form1.Memo1.Clear;
  Form1.memo1.Lines.LoadFromStream(Form1.ProcessUTF8_3.Output);
end;





procedure jar_linux();
var sss, sss1, jarstr, dop :String;
    i, n:  integer;
begin
  if FileExists('file_dir.ini') then Form2.ListBox1.Items.LoadFromFile('file_dir.ini');
  Form1.SynEdit1.Lines.SaveToFile(fullFileName);
  list := TStringList.Create;
  ChDir(ExtractFileDir(fullFileName));
  FileName := ExtractFileName(fullFileName);
  i:= Length(FileName);
  sss1:=Copy(FileName,1,i-5);
  sss := 'main-class: ' + sss1;
  list.Clear;
  list.Add(sss);
  list.Add('');
  list.SaveToFile('MYMANIFEST.MF');
  list.Destroy;
  jarstr := DirJDK+ st_bin +'jar' + ' -cvfm '+ sss1 + '.jar' +' MYMANIFEST.MF ' + sss1 + '.class ';
  n:= Form2.ListBox1.Count;
  dop:='';
  if FileExists(sss1+'$1' + '.class') then dop:= dop + sss1+'$1' + '.class ';
  if FileExists(sss1+'$2' + '.class') then dop:= dop + sss1+'$2' + '.class ';
  if FileExists(sss1+'$3' + '.class') then dop:= dop + sss1+'$3' + '.class ';
  if FileExists(sss1+'$4' + '.class') then dop:= dop + sss1+'$4' + '.class ';
  if FileExists(sss1+'$5' + '.class') then dop:= dop + sss1+'$5' + '.class ';
  if FileExists(sss1+'$6' + '.class') then dop:= dop + sss1+'$6' + '.class ';
  if FileExists(sss1+'$7' + '.class') then dop:= dop + sss1+'$7' + '.class ';
  if FileExists(sss1+'$8' + '.class') then dop:= dop + sss1+'$8' + '.class ';
  if FileExists(sss1+'$9' + '.class') then dop:= dop + sss1+'$9' + '.class ';
  if FileExists(sss1+'$10' + '.class') then dop:= dop + sss1+'$10' + '.class ';
  if FileExists(sss1+'$11' + '.class') then dop:= dop + sss1+'$11' + '.class ';
  if n>=0 then
     begin
         for i := 0 to n-1 do
         begin
              dop:= dop + Form2.ListBox1.Items.Strings[i] + ' ';
         end;
     end;

  Form1.ProcessUTF8_3.CommandLine:=jarstr + dop;
  Form1.ProcessUTF8_3.Execute;
  Form1.Memo1.Clear;
  Form1.memo1.Lines.LoadFromStream(Form1.ProcessUTF8_3.Output);
end;





procedure shablon_applet();
 var str: String;
begin
  Form1.SynEdit1.Lines.Clear;
  str:='//Шаблон ';
  Form1.SynEdit1.Lines.add(str);
  Form1.SynEdit1.Lines.add('/*');
  Form1.SynEdit1.Lines.add(' Пример Базового Java-Апплета');
  Form1.SynEdit1.Lines.add('*/');
  Form1.SynEdit1.Lines.add(' ');
  Form1.SynEdit1.Lines.add('import java.applet.Applet;');
  Form1.SynEdit1.Lines.add('import java.awt.Graphics;');
  Form1.SynEdit1.Lines.add('');
  Form1.SynEdit1.Lines.add('/*');
  Form1.SynEdit1.Lines.add(' <applet code = "BasicAppletExample" width = 400 height = 200>');
  Form1.SynEdit1.Lines.add(' </applet>');
  Form1.SynEdit1.Lines.add('*/');
  Form1.SynEdit1.Lines.add('');
  Form1.SynEdit1.Lines.add('public class BasicAppletExample extends Applet{');
  Form1.SynEdit1.Lines.add(' public void paint(Graphics g){');
  Form1.SynEdit1.Lines.add('  g.drawString("This is my First Applet",20,100);');
  Form1.SynEdit1.Lines.add(' }');
  Form1.SynEdit1.Lines.add('}');
end;


procedure console_cr_fx_win();
 var sss :String;
     i:  integer;
begin
    Form1.SynEdit1.Lines.SaveToFile(fullFileName);
    ChDir(ExtractFileDir(fullFileName));
    FileName := ExtractFileName(fullFileName);
    Form1.Caption:=FileName;
    i:= Length(FileName);
    sss:=Copy(FileName,1,i-5);


     list := TStringList.Create;
     list.Clear;
     list.Add('echo off');
     list.Add('');
     list.Add('set mainclass=' + FileName);
     list.Add('set path="' + DirJDK + st_bin + '";%path%');
     list.Add('set PATH_TO_FX="' + DirFX + st_lib + '"');
     list.Add('set modules="javafx.base,javafx.controls,javafx.fxml,javafx.graphics,javafx.media,javafx.swing,javafx.web"');
     list.Add('');
     list.Add('echo "------------------------Версия javac-----------------------------"');
     list.Add('echo. ');
     list.Add('javac ' + '-version ');
     list.Add('echo.');
     list.Add('echo "-----------------------------------------------------------------"');
     list.Add('echo "------------------Компиляция java программы----------------------"');
     list.Add('echo. ');
     list.Add('javac -encoding utf8 --module-path %PATH_TO_FX% --add-modules %modules% ' + FileName);
     list.Add('echo. ');
     list.Add('echo "-------------------Конец компиляции java программы---------------"');
     list.Add('echo.');
     list.Add('echo "---------------------Версия java --------------------------------"');
     list.Add('echo. ');
     list.Add('java ' + '-version ');
     list.Add('echo. ');
     list.Add('echo "-----------------------------------------------------------------"');
     list.Add('echo. ');
     list.Add('echo "-----------------Запуск java программы---------------------------"');
     list.Add('echo. ');
     list.Add('java --module-path %PATH_TO_FX% --add-modules %modules% ' + sss);
     list.Add('echo. ');
     list.Add('echo "---------------Конец работы java программы-----------------------"'); 
     list.Add('echo. ');
     list.Add('pause');
     list.SaveToFile(file_con_fx);
     list.Destroy;
end;



procedure console_cr_fx_linux();
 var sss :String;
     i:  integer;
begin
    Form1.SynEdit1.Lines.SaveToFile(fullFileName);
    ChDir(ExtractFileDir(fullFileName));
    FileName := ExtractFileName(fullFileName);
    Form1.Caption:=FileName;
    i:= Length(FileName);
    sss:=Copy(FileName,1,i-5);


     list := TStringList.Create;
     list.Clear;
     list.Add('#!/bin/bash');
     list.Add('');
     list.Add('echo " " ');
     list.Add('echo " " ');
     list.Add('echo " " ');
     list.Add('echo " " ');
     list.Add('echo " " ');
     list.Add('echo "------------------------Версия javac-----------------------------"');
     list.Add('echo " " ');
     list.Add(DirJDK+ st_bin + 'javac ' + '-version ');
     list.Add('echo " "');
     list.Add('echo "-----------------------------------------------------------------"');
     list.Add('echo "------------------Компиляция java программы----------------------"');
     list.Add('echo " " ');
     list.Add(DirJDK+ st_bin + 'javac -encoding utf8 --module-path ' + DirFX + ' --add-modules javafx.base,javafx.controls,javafx.fxml,javafx.graphics,javafx.media,javafx.swing,javafx.web ' + FileName);
     list.Add('echo " " ');
     list.Add('echo "-------------------Конец компиляции java программы---------------"');
     list.Add('echo " "');
     list.Add('echo "---------------------Версия java --------------------------------"');
     list.Add('echo " " ');
     list.Add(DirJDK+ st_bin + 'java ' + '-version ');
     list.Add('echo " " ');
     list.Add('echo "-----------------------------------------------------------------"');
     list.Add('echo " " ');
     list.Add('echo "-----------------Запуск java программы---------------------------"');
     list.Add('echo " " ');

     list.Add(DirJDK+ st_bin + 'java --module-path ' + DirFX + ' --add-modules javafx.base,javafx.controls,javafx.fxml,javafx.graphics,javafx.media,javafx.swing,javafx.web ' + sss);
     list.Add('echo " " ');
     list.Add('echo "---------------Конец работы java программы-----------------------"');
     list.Add('echo " " ');
     list.SaveToFile(file_con_fx);
     list.Destroy;
end;

 procedure console_run_linux();
 var sss :String;
     i:  integer;
begin
    Form1.SynEdit1.Lines.SaveToFile(fullFileName);
    ChDir(ExtractFileDir(fullFileName));
    FileName := ExtractFileName(fullFileName);
    Form1.Caption:=FileName;
    i:= Length(FileName);
    sss:=Copy(FileName,1,i-5);


     list := TStringList.Create;
     list.Clear;
     list.Add('#!/bin/bash');
     list.Add('');
     list.Add('echo " " ');
     list.Add('echo " " ');
     list.Add('echo " " ');
     list.Add('echo " " ');
     list.Add('echo " "');
     list.Add('echo "------------------------ Версия java -----------" ');
     list.Add('echo " " ');
     list.Add(DirJDK+ st_bin + 'java ' + '-version ');
     list.Add('echo " " ');
     list.Add('echo "-----------------------------------------------" ');
     list.Add('echo " " ');
     list.Add('echo "------------------------ Запуск программы --------------"');
     list.Add('echo " " ');

     list.Add(DirJDK+ st_bin + 'java ' + sss);
     list.Add('echo " " ');
     list.Add('echo "------------------------end java program--------------"');
     list.Add('echo " " ');
     list.SaveToFile(file_con);
     list.Destroy;
end;

procedure console_cr_linux();
 var sss :String;
     i:  integer;
begin
    Form1.SynEdit1.Lines.SaveToFile(fullFileName);
    ChDir(ExtractFileDir(fullFileName));
    FileName := ExtractFileName(fullFileName);
    Form1.Caption:=FileName;
    i:= Length(FileName);
    sss:=Copy(FileName,1,i-5);


     list := TStringList.Create;
     list.Clear;
     list.Add('#!/bin/bash');
     list.Add('');
     list.Add('echo " " ');
     list.Add('echo " " ');
     list.Add('echo " " ');
     list.Add('echo " " ');
     list.Add('echo "------------------------javac version-----------"');
     list.Add('echo " " ');
     list.Add(DirJDK+ st_bin + 'javac ' + '-version ');
     list.Add('echo " "');
     list.Add('echo "-----------------------------------------------" ');
     list.Add('echo "------------------------compiling program-----------" ');
     list.Add('echo " " ');
     list.Add(DirJDK+ st_bin + 'javac -encoding utf8 *.java');     //FileName
     list.Add('echo " " ');
     list.Add('echo "-----------------------------------------------"');
     list.Add('echo " "');
     list.Add('echo "------------------------java version-----------" ');
     list.Add('echo " " ');
     list.Add(DirJDK+ st_bin + 'java ' + '-version ');
     list.Add('echo " " ');
     list.Add('echo "-----------------------------------------------" ');
     list.Add('echo " " ');
     list.Add('echo "------------------------run java program--------------"');
     list.Add('echo " " ');

     list.Add(DirJDK+ st_bin + 'java ' + sss);
     list.Add('echo " " ');
     list.Add('echo "------------------------end java program--------------"');
     list.Add('echo " " ');
     list.Add('read p');
     list.SaveToFile(file_con);
     list.Destroy;
end;

procedure console_cr_run_linux();
 var sss :String;
     i:  integer;
begin
    Form1.SynEdit1.Lines.SaveToFile(fullFileName);
    ChDir(ExtractFileDir(fullFileName));
    FileName := ExtractFileName(fullFileName);
    Form1.Caption:=FileName;
    i:= Length(FileName);
    sss:=Copy(FileName,1,i-5);


     list := TStringList.Create;
     list.Clear;
     list.Add('#!/bin/bash');
     list.Add('');
     list.Add('echo " " ');
     list.Add('echo " " ');
     list.Add('echo " "');
     list.Add('echo "------------------------java version-----------" ');
     list.Add('echo " " ');
     list.Add(DirJDK+ st_bin + 'java ' + '-version ');
     list.Add('echo " " ');
     list.Add('echo "-----------------------------------------------" ');
     list.Add('echo " " ');
     list.Add('echo "------------------------run java program--------------"');
     list.Add('echo " " ');

     list.Add(DirJDK+ st_bin + 'java ' + sss);
     list.Add('echo " " ');
     list.Add('echo "------------------------end java program--------------"');
     list.Add('echo " " ');
     list.Add('read p');
     list.SaveToFile(file_run);
     list.Destroy;
end;



procedure console_cr_win();
 var sss :String;
     i:  integer;
begin
    Form1.SynEdit1.Lines.SaveToFile(fullFileName);
    ChDir(ExtractFileDir(fullFileName));
    FileName := ExtractFileName(fullFileName);
    Form1.Caption:=FileName;
    i:= Length(FileName);
    sss:=Copy(FileName,1,i-5);


     list := TStringList.Create;
     list.Clear;
     list.Add('echo off');
     list.Add('');
     list.Add('set mainclass=' + FileName);
     list.Add('set path="' + DirJDK + st_bin + '";%path%');
     list.Add('');
     list.Add('echo ------------------------javac version-----------');
     list.Add('echo. ');
     list.Add('javac ' + '-version ');
     list.Add('echo.');
     list.Add('echo ----------------------------------------------- ');
     list.Add('echo ------------------------compiling program----------- ');
     list.Add('echo. ');
     list.Add('javac -encoding utf8 ' + FileName);
     list.Add('echo. ');
     list.Add('echo -----------------------------------------------');
     list.Add('echo.');
     list.Add('echo ------------------------java version----------- ');
     list.Add('echo. ');
     list.Add('java ' + '-version ');
     list.Add('echo. ');
     list.Add('echo ----------------------------------------------- ');
     list.Add('echo. ');
     list.Add('echo ------------------------run java program--------------');
     list.Add('echo. ');

     list.Add('java ' + sss);
     list.Add('echo. ');
     list.Add('echo ------------------------end java program--------------');
     list.Add('echo. ');
     list.Add('pause');
     list.SaveToFile(file_con);
     list.Destroy;
end;


procedure shablon_console();
 var str: String;
begin
  Form1.SynEdit1.Lines.Clear;
  str:='//Шаблон ';
  Form1.SynEdit1.Lines.add(str);
  str:='import java.util.Scanner; ';
  Form1.SynEdit1.Lines.add(str);
  str:='public class Shablon{';
  Form1.SynEdit1.Lines.add(str);
  str:='   public static void main(String[] args){';
  Form1.SynEdit1.Lines.add(str);
  Form1.SynEdit1.Lines.add('      System.out.println("_________________________________\n");');
  str:='      //Ваш код ';
  Form1.SynEdit1.Lines.add(str);
  Form1.SynEdit1.Lines.add('      System.out.println("Шаблон программы!");');
  str:='      //Остановка закрытия окна ';
  Form1.SynEdit1.Lines.add(str);
  str:='      Scanner sc_stop = new Scanner(System.in);';
  Form1.SynEdit1.Lines.add(str);
  str:='      System.out.println("_________________________________\n");';
  Form1.SynEdit1.Lines.add(str);
  str:='      char cr = sc_stop.next().charAt(0);';;
  Form1.SynEdit1.Lines.add(str);
  str:='   } ';
  Form1.SynEdit1.Lines.add(str);
  str:='}';
  Form1.SynEdit1.Lines.add(str);
  Form1.SynEdit1.Lines.add('');

 end;



 procedure shablon_swing();
 var str: String;
begin
 Form1.SynEdit1.Lines.Clear;
  str:='//Шаблон ';
  Form1.SynEdit1.Lines.add(str);
  Form1.SynEdit1.Lines.add('  import javax.swing.*;');
  Form1.SynEdit1.Lines.add('import java.awt.*;');
  Form1.SynEdit1.Lines.add('class HelloWorldGUI { ');
   Form1.SynEdit1.Lines.add( '  private static void createAndShowGUI() {');
    Form1.SynEdit1.Lines.add('      JFrame frame = new JFrame("HelloWorldGUI");');
    Form1.SynEdit1.Lines.add('		frame.setSize(150,200); ');
    Form1.SynEdit1.Lines.add('		frame.setLocation(150,150); ');
    Form1.SynEdit1.Lines.add('        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); ');
     Form1.SynEdit1.Lines.add('       frame.setLayout (new FlowLayout(FlowLayout.CENTER)); ');
     Form1.SynEdit1.Lines.add('        JLabel label0 = new JLabel("Привет народ!!!");');
     Form1.SynEdit1.Lines.add('        JLabel label = new JLabel("HelloWorldGUI"); ');
     Form1.SynEdit1.Lines.add('       frame.add(label0);');
     Form1.SynEdit1.Lines.add('        frame.add(label); ');
     Form1.SynEdit1.Lines.add('                   ');
     Form1.SynEdit1.Lines.add('                   ');
     Form1.SynEdit1.Lines.add('        frame.setVisible(true); ');
     Form1.SynEdit1.Lines.add('    }              ');
     Form1.SynEdit1.Lines.add('                   ');
     Form1.SynEdit1.Lines.add('   public static void main(String[] args) { ');
     Form1.SynEdit1.Lines.add('                       ');
     Form1.SynEdit1.Lines.add('       javax.swing.SwingUtilities.invokeLater(new Runnable() { ');
     Form1.SynEdit1.Lines.add('           public void run() {     ');
     Form1.SynEdit1.Lines.add('                createAndShowGUI();  ');
     Form1.SynEdit1.Lines.add('            }   ');
     Form1.SynEdit1.Lines.add('        });     ');
     Form1.SynEdit1.Lines.add('    }           ');
     Form1.SynEdit1.Lines.add('}                ');
  Form1.SynEdit1.Lines.add('');

 end;


procedure input_output();
 var str: String;
begin
 Form1.SynEdit1.Lines.Clear;
  str:='//Требуется сложить два целых числа А и В. ';
  Form1.SynEdit1.Lines.add(str);
  Form1.SynEdit1.Lines.add('');
  Form1.SynEdit1.Lines.add('import java.util.*;');
  Form1.SynEdit1.Lines.add('import java.io.*;');
  Form1.SynEdit1.Lines.add('');
  Form1.SynEdit1.Lines.add('public class Main  {');
  Form1.SynEdit1.Lines.add('    PrintWriter pw;');
  Form1.SynEdit1.Lines.add('    Scanner sc;');
  Form1.SynEdit1.Lines.add('    public static void main(String[] args) throws FileNotFoundException { ');
  Form1.SynEdit1.Lines.add('        new Main().run();');
  Form1.SynEdit1.Lines.add('    }');
  Form1.SynEdit1.Lines.add('    public  void run() throws FileNotFoundException {');
  Form1.SynEdit1.Lines.add('        sc = new Scanner( new File("input.txt"));');
  Form1.SynEdit1.Lines.add(' ');
  Form1.SynEdit1.Lines.add('        int a = sc.nextInt();');
  Form1.SynEdit1.Lines.add('        int b = sc.nextInt(); ');
  Form1.SynEdit1.Lines.add('        int c = a + b;');
  Form1.SynEdit1.Lines.add('        String sss = "" + c;');
  Form1.SynEdit1.Lines.add(' ');
  Form1.SynEdit1.Lines.add('        pw = new PrintWriter(new File("output.txt"));');
  Form1.SynEdit1.Lines.add('        pw.println(sss); ');
  Form1.SynEdit1.Lines.add('        pw.close();');
  Form1.SynEdit1.Lines.add('    } ');
  Form1.SynEdit1.Lines.add('} ');
 end;



procedure shablon_fx();
var str: String;
begin
 Form1.SynEdit1.Lines.Clear;
 str:='//Шаблон ';
 Form1.SynEdit1.Lines.add(str);
 Form1.SynEdit1.Lines.add('import javafx.application.Application; ');
 Form1.SynEdit1.Lines.add('import javafx.geometry.Pos; ');
 Form1.SynEdit1.Lines.add('import javafx.scene.Scene;  ');
 Form1.SynEdit1.Lines.add('import javafx.scene.control.Label; ');
 Form1.SynEdit1.Lines.add('import javafx.stage.Stage;');
 Form1.SynEdit1.Lines.add(' ');
 Form1.SynEdit1.Lines.add('public class HelloWorldApplicationFX extends Application { ');
 Form1.SynEdit1.Lines.add(' ');
 Form1.SynEdit1.Lines.add('    @Override ');
 Form1.SynEdit1.Lines.add('    public void init() throws Exception {');
 Form1.SynEdit1.Lines.add('        super.init();');
 Form1.SynEdit1.Lines.add('        System.out.println("Inside init() method! Perform necessary initializations here.");');
 Form1.SynEdit1.Lines.add('    }  ');
 Form1.SynEdit1.Lines.add('      ');
 Form1.SynEdit1.Lines.add('    @Override');
 Form1.SynEdit1.Lines.add('    public void start(Stage primaryStage) throws Exception { ');
 Form1.SynEdit1.Lines.add('        Label label = new Label("Hello World");');
 Form1.SynEdit1.Lines.add('        label.setAlignment(Pos.CENTER); ');
 Form1.SynEdit1.Lines.add('        Scene scene = new Scene(label, 500, 350);');
 Form1.SynEdit1.Lines.add('');
 Form1.SynEdit1.Lines.add('        primaryStage.setTitle("Hello World Application");');
 Form1.SynEdit1.Lines.add('        primaryStage.setScene(scene);');
 Form1.SynEdit1.Lines.add('        primaryStage.show();');
 Form1.SynEdit1.Lines.add('    }');
 Form1.SynEdit1.Lines.add('');
 Form1.SynEdit1.Lines.add('    @Override');
 Form1.SynEdit1.Lines.add('    public void stop() throws Exception {');
 Form1.SynEdit1.Lines.add('        super.stop();');
 Form1.SynEdit1.Lines.add('        System.out.println("Inside stop() method! Destroy resources. Perform Cleanup.");');
 Form1.SynEdit1.Lines.add('    }');
 Form1.SynEdit1.Lines.add('');
 Form1.SynEdit1.Lines.add('    public static void main(String[] args) {');
 Form1.SynEdit1.Lines.add('        launch(args);');
 Form1. SynEdit1.Lines.add('    }');
 Form1.SynEdit1.Lines.add('}');
end;
end.

