1. Pascal / Говнокод #18614

    +4

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    with TfmVersionUpdate.Create(Application) do
    begin
      try
        Init;
      except
      end;
      Free;
    end;

    Такой код 100500% отработает без ошибок. Зачем вообще сообщения о них выводить...

    kiryl, 19 Августа 2015

    Комментарии (21)
  2. Pascal / Говнокод #18566

    +1000

    1. 1
    2. 2
    3. 3
    4. 4
    procedure PP.Execute;
    begin inherited;
    (Sender as TIndusImage).KOT;
    end;

    В Delphi XE, не знаю с какой версии начиная (в XE7 и XE8 точно) крупные проблемы с TGifImage, а если точнее - если быстро и много их менять, то рано или поздно вываливается тупо всё вместе с интерфейсом (100% где-то в потоках налажали), причем если быстро менять BMP, то всё ОК.

    Пришла в голову идея в потоке самому менять кадры анимации, подгружая их как BMP, и дабы затестить сработает ли вообще, начал писать тестовую прогу.

    Писал особо не заботясь ни о чем, а потом заметил вот таких индусских котов.

    KOTOM, 03 Августа 2015

    Комментарии (18)
  3. Pascal / Говнокод #18547

    +7

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    function variant (x0, y0, x1, y1, x2, y2, x3, y3:real):integer;
    begin
        if (x0<=x1) and (y0<=y1) and (x1<=x2) and (y1<=y2) and (x2<=x3) and (y2<=y3) or
           (x0>=x1) and (y0<=y1) and (x1>=x2) and (y1<=y2) and (x2>=x3) and (y2<=y3) or
           (x0>=x1) and (y0>=y1) and (x1>=x2) and (y1>=y2) and (x2>=x3) and (y2>=y3) or
           (x0>=x1) and (y0<=y1) and (x1>=x2) and (y1<=y2) and (x2>=x3) and (y2<=y3) then variant:=1;
        if (x0<=x1) and (y0<=y1) and (x1<=x3) and (y1<=y3) and (x3<=x2) and (y3<=y2) or
           (x0>=x1) and (y0<=y1) and (x1>=x3) and (y1<=y3) and (x3>=x2) and (y3<=y2) or
           (x0>=x1) and (y0>=y1) and (x1>=x3) and (y1>=y3) and (x3>=x2) and (y3>=y2) or
           (x0>=x1) and (y0<=y1) and (x1>=x3) and (y1<=y3) and (x3>=x2) and (y3<=y2) then variant:=2;
        if (x1<=x0) and (y1<=y0) and (x0<=x2) and (y0<=y2) and (x2<=x3) and (y2<=y3) or
           (x1>=x0) and (y1<=y0) and (x0>=x2) and (y0<=y2) and (x2>=x3) and (y2<=y3) or
           (x1>=x0) and (y1>=y0) and (x0>=x2) and (y0>=y2) and (x2>=x3) and (y2>=y3) or
           (x1>=x0) and (y1<=y0) and (x0>=x2) and (y0<=y2) and (x2>=x3) and (y2<=y3) then variant:=3;
        if (x1<=x0) and (y1<=y0) and (x0<=x3) and (y0<=y3) and (x3<=x2) and (y3<=y2) or
           (x1>=x0) and (y1<=y0) and (x0>=x3) and (y0<=y3) and (x3>=x2) and (y3<=y2) or
           (x1>=x0) and (y1>=y0) and (x0>=x3) and (y0>=y3) and (x3>=x2) and (y3>=y2) or
           (x1>=x0) and (y1<=y0) and (x0>=x3) and (y0<=y3) and (x3>=x2) and (y3<=y2) then variant:=4;
        if (x0<=x3) and (y0<=y3) and (x3<=x1) and (y3<=y1) and (x1<=x2) and (y1<=y2) or
           (x0>=x3) and (y0<=y3) and (x3>=x1) and (y3<=y1) and (x1>=x2) and (y1<=y2) or
           (x0>=x3) and (y0>=y3) and (x3>=x1) and (y3>=y1) and (x1>=x2) and (y1>=y2) or
           (x0>=x3) and (y0<=y3) and (x3>=x1) and (y3<=y1) and (x1>=x2) and (y1<=y2) then variant:=5;
        if (x0<=x3) and (y0<=y3) and (x3<=x2) and (y3<=y2) and (x2<=x1) and (y2<=y1) or
           (x0>=x3) and (y0<=y3) and (x3>=x2) and (y3<=y2) and (x2>=x1) and (y2<=y1) or
           (x0>=x3) and (y0>=y3) and (x3>=x2) and (y3>=y2) and (x2>=x1) and (y2>=y1) or
           (x0>=x3) and (y0<=y3) and (x3>=x2) and (y3<=y2) and (x2>=x1) and (y2<=y1) then variant:=6;
        if (x0<=x2) and (y0<=y2) and (x2<=x1) and (y2<=y1) and (x1<=x3) and (y1<=y3) or
           (x0>=x2) and (y0<=y2) and (x2>=x1) and (y2<=y1) and (x1>=x3) and (y1<=y3) or
           (x0>=x2) and (y0>=y2) and (x2>=x1) and (y2>=y1) and (x1>=x3) and (y1>=y3) or
           (x0>=x2) and (y0<=y2) and (x2>=x1) and (y2<=y1) and (x1>=x3) and (y1<=y3) then variant:=7;
        if (x0<=x2) and (y0<=y2) and (x2<=x3) and (y2<=y3) and (x3<=x1) and (y3<=y1) or
           (x0>=x2) and (y0<=y2) and (x2>=x3) and (y2<=y3) and (x3>=x1) and (y3<=y1) or
           (x0>=x2) and (y0>=y2) and (x2>=x3) and (y2>=y3) and (x3>=x1) and (y3>=y1) or
           (x0>=x2) and (y0<=y2) and (x2>=x3) and (y2<=y3) and (x3>=x1) and (y3<=y1) then variant:=8;
        if (x1<=x2) and (y1<=y2) and (x2<=x0) and (y2<=y0) and (x0<=x3) and (y0<=y3) or
           (x1>=x2) and (y1<=y2) and (x2>=x0) and (y2<=y0) and (x0>=x3) and (y0<=y3) or
           (x1>=x2) and (y1>=y2) and (x2>=x0) and (y2>=y0) and (x0>=x3) and (y0>=y3) or
           (x1>=x2) and (y1<=y2) and (x2>=x0) and (y2<=y0) and (x0>=x3) and (y0<=y3) then variant:=9;
        if (x1<=x3) and (y1<=y3) and (x3<=x0) and (y3<=y0) and (x0<=x2) and (y0<=y2) or
           (x1>=x3) and (y1<=y3) and (x3>=x0) and (y3<=y0) and (x0>=x2) and (y0<=y2) or
           (x1>=x3) and (y1>=y3) and (x3>=x0) and (y3>=y0) and (x0>=x2) and (y0>=y2) or
           (x1>=x3) and (y1<=y3) and (x3>=x0) and (y3<=y0) and (x0>=x2) and (y0<=y2) then variant:=10;
        if (x2<=x0) and (y2<=y0) and (x0<=x1) and (y0<=y1) and (x1<=x3) and (y1<=y3) or
           (x2>=x0) and (y2<=y0) and (x0>=x1) and (y0<=y1) and (x1>=x3) and (y1<=y3) or
           (x2>=x0) and (y2>=y0) and (x0>=x1) and (y0>=y1) and (x1>=x3) and (y1>=y3) or
           (x2>=x0) and (y2<=y0) and (x0>=x1) and (y0<=y1) and (x1>=x3) and (y1<=y3) then variant:=11;
        if (x2<=x1) and (y2<=y1) and (x1<=x0) and (y1<=y0) and (x0<=x3) and (y0<=y3) or
           (x2>=x1) and (y2<=y1) and (x1>=x0) and (y1<=y0) and (x0>=x3) and (y0<=y3) or
           (x2>=x1) and (y2>=y1) and (x1>=x0) and (y1>=y0) and (x0>=x3) and (y0>=y3) or
           (x2>=x1) and (y2<=y1) and (x1>=x0) and (y1<=y0) and (x0>=x3) and (y0<=y3) then variant:=12;
    end;

    Источник: http://e-olimp.blogspot.com/2013/08/12.html

    Felytic, 29 Июля 2015

    Комментарии (1)
  4. Pascal / Говнокод #18330

    +140

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    s:=0; k:=1;
    while s<200 do begin
    s:=s+3*k;
    end;
    if s<200 then begin
    k:=k+1;
    end;

    Ничего такого..

    MaxLevs, 11 Июня 2015

    Комментарии (1)
  5. Pascal / Говнокод #18296

    +144

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    81. 81
    82. 82
    83. 83
    84. 84
    85. 85
    Unit Web;
    
    interface
    
    uses System, System.Drawing, System.Windows.Forms;
    
    var f: Form;
    
    type
      WebBro = class(Form)
        procedure button1_Click(sender: Object; e: EventArgs);
      {$region FormDesigner}
      private
        {$resource Web.WebBro.resources}
        button1: Button;
        webBrowser1: WebBrowser;
        {$include Web.WebBro.inc}
      {$endregion FormDesigner}
      public
        constructor;
        begin
          InitializeComponent;
        end;
      end;
    
    implementation
    
    Procedure FindForm();
    begin
      var i:=0;
      while i < Application.OpenForms.Count do
        begin
          f := Application.OpenForms.Item[i];
          if f.Name = 'TwiGen_News' then exit
            else inc(i);
        end;
    end;
    
    procedure WebBro.button1_Click(sender: Object; e: EventArgs);
    begin
      WebBro.ActiveForm.Hide();
      FindForm;
      f.Show();
    end;
    
    end.
    
    //----------------
    
    Unit Unit1;
    
    interface
    
    uses System, System.Drawing, System.Windows.Forms, Web;
    
    var NewsForm: WebBro;
    
    type
      TwiGen_News = class(Form)
        procedure News_Click(sender: Object; e: EventArgs);
      {$region FormDesigner}
      private
        {$resource Unit1.TwiGen_News.resources}
        LogIn: Button;
        News: Button;
        Reg: Button;
        {$include Unit1.TwiGen_News.inc}
      {$endregion FormDesigner}
      public
        constructor;
        begin
          InitializeComponent;
        end;
      end;
    
    implementation
    
    procedure TwiGen_News.News_Click(sender: Object; e: EventArgs);
    begin
      TwiGen_News.ActiveForm.Hide();
      NewsForm := new WebBro;
      NewsForm.Show;
    end;
    
    end.

    Друг писал, но мне он говорил, что переписывал говнокод.
    Pascal ABC.NET.

    Janycz, 08 Июня 2015

    Комментарии (8)
  6. Pascal / Говнокод #18294

    +142

    1. 001
    2. 002
    3. 003
    4. 004
    5. 005
    6. 006
    7. 007
    8. 008
    9. 009
    10. 010
    11. 011
    12. 012
    13. 013
    14. 014
    15. 015
    16. 016
    17. 017
    18. 018
    19. 019
    20. 020
    21. 021
    22. 022
    23. 023
    24. 024
    25. 025
    26. 026
    27. 027
    28. 028
    29. 029
    30. 030
    31. 031
    32. 032
    33. 033
    34. 034
    35. 035
    36. 036
    37. 037
    38. 038
    39. 039
    40. 040
    41. 041
    42. 042
    43. 043
    44. 044
    45. 045
    46. 046
    47. 047
    48. 048
    49. 049
    50. 050
    51. 051
    52. 052
    53. 053
    54. 054
    55. 055
    56. 056
    57. 057
    58. 058
    59. 059
    60. 060
    61. 061
    62. 062
    63. 063
    64. 064
    65. 065
    66. 066
    67. 067
    68. 068
    69. 069
    70. 070
    71. 071
    72. 072
    73. 073
    74. 074
    75. 075
    76. 076
    77. 077
    78. 078
    79. 079
    80. 080
    81. 081
    82. 082
    83. 083
    84. 084
    85. 085
    86. 086
    87. 087
    88. 088
    89. 089
    90. 090
    91. 091
    92. 092
    93. 093
    94. 094
    95. 095
    96. 096
    97. 097
    98. 098
    99. 099
    100. 100
    type
      TForm1 = class(TForm)
        IBDB1: TIBDatabase;
        MainMenu1: TMainMenu;
        N1: TMenuItem;
        N2: TMenuItem;
        IBTransaction1: TIBTransaction;
        Pochtamt: TIBQuery;
        DSOPS: TDataSource;
        Detal: TIBQuery;
        DSDetal: TDataSource;
        IBQuery1: TIBQuery;
        ListBox1: TListBox;
        N3: TMenuItem;
        RabMesto: TIBQuery;
        DSRabMesto: TDataSource;
        IdIPWatch1: TIdIPWatch;
        DBGrid2: TDBGrid;
        Panel1: TPanel;
        Button2: TButton;
        Label2: TLabel;
        Edit1: TEdit;
        Label3: TLabel;
        Label4: TLabel;
        Edit3: TEdit;
        Label5: TLabel;
        Label6: TLabel;
        Edit4: TEdit;
        Button3: TButton;
        PMOPS: TPopupMenu;
        N6: TMenuItem;
        N7: TMenuItem;
        PMRabMesto: TPopupMenu;
        N9: TMenuItem;
        N10: TMenuItem;
        ListBox2: TListBox;
        Label14: TLabel;
        Label15: TLabel;
        Button6: TButton;
        PageControl1: TPageControl;
        TabSheet1: TTabSheet;
        TabSheet2: TTabSheet;
        Panel2: TPanel;
        Label11: TLabel;
        Label12: TLabel;
        Label13: TLabel;
        Button4: TButton;
        Memo1: TMemo;
        Button5: TButton;
        Edit6: TEdit;
        DBGrid1: TDBGrid;
        Label1: TLabel;
        DBMemo1: TDBMemo;
        Label16: TLabel;
    //    DBGrid2: TDBGrid;
        TabSheet3: TTabSheet;
        N11: TMenuItem;
        Label18: TLabel;
        Label9: TLabel;
        Edit7: TEdit;
        Label10: TLabel;
        MaskEdit1: TMaskEdit;
        MaskEdit2: TMaskEdit;
        TabSheet5: TTabSheet;
        N12: TMenuItem;
        LSostav: TIBQuery;
        DSLSostav: TDataSource;
        DBGrid4: TDBGrid;
        ListBox3: TListBox;
        PMLSostav: TPopupMenu;
        N13: TMenuItem;
        N14: TMenuItem;
        N15: TMenuItem;
        Panel3: TPanel;
        Label22: TLabel;
        Edit2: TEdit;
        Label23: TLabel;
        Edit8: TEdit;
        Label24: TLabel;
        MaskEdit3: TMaskEdit;
        MaskEdit4: TMaskEdit;
        MaskEdit5: TMaskEdit;
        Label25: TLabel;
        Label26: TLabel;
        MaskEdit6: TMaskEdit;
        Label27: TLabel;
        Button7: TButton;
        Button8: TButton;
        Label28: TLabel;
        Edit9: TEdit;
        Label29: TLabel;
        Edit10: TEdit;
        UpDown1: TUpDown;
        Label30: TLabel;
        Edit11: TEdit;
        Edit12: TEdit;
        Label31: TLabel;
        Label32: TLabel;
        Button9: TButton;
        N16: TMenuItem;

    Там еще 400 строк объявления компонентов формы и процедур и функций с аналогичными названиями...

    BotGovnokot, 08 Июня 2015

    Комментарии (9)
  7. Pascal / Говнокод #18137

    +141

    1. 1
    2. 2
    3. 3
    4. 4
    function GetArgs(const str:string):string;
    begin
      result:=strpas(pathgetargs(pchar(str))); //UB
    end;

    result:=strpas(pathgetargs(pchar(str))); //UB
    Плохой мальчик.

    Stertor, 09 Мая 2015

    Комментарии (0)
  8. Pascal / Говнокод #18113

    +143

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    function CopyEx(s:string; index,count:integer):string;
    var
      len,ln:integer;
    begin
      ln:=0;
      if index <1 then index:=1;
      len:=length(s);
      ln:=len-count;
      dec(ln);
      dec(len,(index+ln));
      result:=copy(s,index,len);
    end;

    Stertor, 04 Мая 2015

    Комментарии (5)
  9. Pascal / Говнокод #18087

    +144

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    cs_zagl.Edit;
          cs_zagl.fieldbyname('count_z').asinteger:=cs_tab.RecordCount;
          cs_zagl.Post;
    
    cs_mk.Edit;
    cs_mk.FieldByName('med_kart_id').Asinteger:=select_row_Form.ClientDataSet1.FieldByName('id_kart').asinteger;
    cs_mk.FieldByName('id_kart_public').Asinteger:=select_row_Form.ClientDataSet1.FieldByName('id_kart_public').asinteger;
    cs_mk.FieldByName('id_pac').Asinteger:=select_row_Form.ClientDataSet1.FieldByName('id_pac').asinteger;
    cs_mk.FieldByName('type_kart').asinteger:=select_row_Form.ClientDataSet1.FieldByName('type_kart').asinteger;
    cs_mk.post;
    
    
          IF (cs_mk.FieldByName('med_kart_id').Value=0) or (cs_mk.FieldByName('type_kart').asinteger<>27) then begin
          cmd := VarArrayCreate([0,20],varVariant);
          cmd[1] := 6832;
          cmd[2] := 17;
          cmd[5] := 1;
          cmd[6] := 0;
          ProvOptions := [grMetadata, grReset];
          cmd[7] := dsp_mk.GetRecords(-1, RecsOut, Byte(ProvOptions));
    
    
      try
    
        rez := MainFormInterface.EXT_call_server('spr_read', cmd);
        cs_tab.Edit;
        cs_tab.FieldByName('med_kart_id').Asinteger:=rez[3];
        cs_tab.Post;
    
    
    
        if rez[1] < 0 then begin
          debug_sql('Ошибка: ' + varastype(rez[1], varstring), 2);
          MessageDlg('Ошибка: '+ #10 + #13 +
                     varastype(rez[1],varstring),mtError,[mbok],0);
          Exit;
        end;
    
    
       except
        on e:exception do
        begin
          MessageDlg(ERROR_MESS_5 + 'Исключение:' + E.ClassName + 'Mess:' + E.Message, mterror, [mbok], 0);
          debug_sql('Ошибка записи документа!', 2);
          debug_all('Err при записи документа тип=' + varastype(cmd[1], varstring)+
                   ' id=' + inttostr(id_doc) + 'Исключение:' + E.ClassName + 'Mess:' + E.Message,2);
    
        end;
      end;
    
    
    
    
    
          end;
          end else begin
    
          
    
    
          end;
          end
          else exit;
    
    
       end else
         begin
        id_pac:=rez[3];
        id_med_kart:=rez[2];
        Application.MessageBox(pchar('Ошибка: '+#10+#13+
               'Даный пациент не найден!!!'),pchar(application_title_short),MB_OK+MB_ICONERROR);
        exit;
        end;
    
    end;

    Это называется стиль

    tucvbif, 29 Апреля 2015

    Комментарии (5)
  10. Pascal / Говнокод #18073

    +142

    1. 1
    2. 2
    3. 3
    TCompareType = (ctGT, ctGE, ctLT, ctLE, ctEQ, ctNE, ctIsIn, ctNIsIn,
        ctLike, ctNLike, ctNull, ctNNull, ctBetween, ctNotBetween, ctExists,
        ctNotExists);

    Преклоняюсь перед истинным ниндзя. Ходил не обращал на ...код, но видимо я осознал глубокий смысл этого пути).

    ViktorR, 28 Апреля 2015

    Комментарии (6)