- 1
- 2
- 3
- 4
function isstring(str1,str2:string):boolean;
begin
result:=(AnsiPos(AnsiLowerCase(str1),AnsiLowerCase(str2))>0)
end;
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+68.6
function isstring(str1,str2:string):boolean;
begin
result:=(AnsiPos(AnsiLowerCase(str1),AnsiLowerCase(str2))>0)
end;
Функция проверяет, содержит ли строка str2 строку str1 не учитывая регистр.
Возвращает true, если содержит, в противном случае возвращает false.
+99
try
SetPropValue(c, aqGetConfigproperty_name.asString,aqGetConfigpropery_value.asvariant);
aqGetConfig.Next;
if aqGetConfigproperty_name.AsString = 'TabVisible'
then begin
if aqGetConfigpropery_value.AsString = '1' then vis:=True
else vis:=False;
SetPropValue(c, aqGetConfigproperty_name.asString,vis);
end
Вот так мы ставим свойства закладок из конфигуратора:)
+103.9
la:
for j:=8 to (length(a)-length(b) div 2) do
begin
...
if(a[j]>'5') goto la;
...
if(a[j]>'7') goto la;
...
if(a[j]>'2') goto la;
...
j:=j-8;
...
form1.memo1.text=form1.memo1.text+'; '+inttostr(j)+'5';
...
if(a[j]>'1') goto g;
...
j:=j+8;
end;
g:
Не знаю почему, но меня охватывают фиерические чувства. Найденно на просторах рунета в разделах готовых решений задач для студентов.
+101.9
function DatePlusOneDay(Date: TDate): TDate;
var
Day, Month, Year: string;
begin
Day := Copy(DateToStr(Date), 1, 2);
Month := Copy(DateToStr(Date), 4, 2);
Year := Copy(DateToStr(Date), 7, 4);
if frac(StrToFloat(Year) / 4) <> 0 then
if (Month = '01') or (Month = '03') or (Month = '05') or (Month = '07') or (Month = '08') or (Month = '10') or (Month = '12') then
if Day <> '31' then
if StrToInt(Day) < 9 then Day := '0' + IntToStr(StrToInt(Day) + 1)
else Day := IntToStr(StrToInt(Day) + 1)
else
begin
Day := '01';
if StrToInt(Month) < 9 then
Month := '0' + IntToStr(StrToInt(Month) + 1)
else
if Month = '12' then
begin
Month := '01';
Year := IntToStr(StrToInt(Year) + 1);
end
else Month := IntToStr(StrToInt(Month) + 1);
end
else
if (Month = '04') or (Month = '06') or
(Month = '09') or (Month = '11') then
if Day <> '30' then
if StrToInt(Day) < 9 then Day := '0' + IntToStr(StrToInt(Day) + 1)
else Day := IntToStr(StrToInt(Day) + 1)
else
begin
Day := '01';
if StrToInt(Month) < 9 then Month := '0' + IntToStr(StrToInt(Month) + 1)
else Month := IntToStr(StrToInt(Month) + 1);
end
else
if Day <> '28' then
if StrToInt(Day) < 9 then Day := '0' + IntToStr(StrToInt(Day) + 1)
else Day := IntToStr(StrToInt(Day) + 1)
else
begin
Day := '01';
if StrToInt(Month) < 9 then Month := '0' + IntToStr(StrToInt(Month) + 1)
else Month := IntToStr(StrToInt(Month) + 1);
end
else
if (Month = '01') or (Month = '03') or (Month = '05') or (Month = '07') or (Month = '08') or (Month = '10') or (Month = '12') then
if Day <> '31' then
if StrToInt(Day) < 9 then Day := '0' + IntToStr(StrToInt(Day) + 1)
else Day := IntToStr(StrToInt(Day) + 1)
else
begin
Day := '01';
if StrToInt(Month) < 9 then
Month := '0' + IntToStr(StrToInt(Month) + 1)
else
if Month = '12' then
begin
Month := '01';
Year := IntToStr(StrToInt(Year) + 1);
end
else
Month := IntToStr(StrToInt(Month) + 1);
end
else
if (Month = '04') or (Month = '06') or
(Month = '09') or (Month = '11') then
if Day <> '30' then
if StrToInt(Day) < 9 then
Day := '0' + IntToStr(StrToInt(Day) + 1)
else
Day := IntToStr(StrToInt(Day) + 1)
else
begin
Day := '01';
if StrToInt(Month) < 9 then
Month := '0' + IntToStr(StrToInt(Month) + 1)
else
Month := IntToStr(StrToInt(Month) + 1);
end
else
if Day <> '28' then
if StrToInt(Day) < 9 then
Day := '0' + IntToStr(StrToInt(Day) + 1)
else
Day := IntToStr(StrToInt(Day) + 1)
else
begin
Day := '01';
if StrToInt(Month) < 9 then
Month := '0' + IntToStr(StrToInt(Month) + 1)
else
Month := IntToStr(StrToInt(Month) + 1);
end;
DatePlusOneDay := StrToDate(Day + '.' + Month + '.' + Year);
end;
Писалось, когда не знали о эквиваленте (Date + 1)
+83.6
procedure TForm1.WMNCHitTest(var M: TWMNCHitTest);
var
P: TPoint;
Left, Right, Top, Bottom: Boolean;
begin
P := ScreenToClient(SmallPointToPoint(M.Pos));
Left := (P.X < 5) and not (akLeft in Anchors);
Right := (P.X > Width - 5) and not (akRight in Anchors);
Top := (P.Y < 5) and not (akTop in Anchors);
Bottom := (P.Y > Height - 5) and not (akBottom in Anchors);
M.Result := HTCLIENT;
if Left then
if Top then
M.Result := HTTOPLEFT
else
if Bottom then
M.Result := HTBOTTOMLEFT
else
M.Result := HTLEFT
else
if Right then
if Top then
M.Result := HTTOPRIGHT
else
if Bottom then
M.Result := HTBOTTOMRIGHT
else
M.Result := HTRIGHT
else
if Top then
M.Result := HTTOP
else
if Bottom then
M.Result := HTBOTTOM;
end;
изменяем размеры формы с BorderStyle = bsNone.
+85
pocedure TForm1.line(x, y, N: integer; l: real; d: boolean);
var
x1,x2,x3,x4,y1,y2,y3,y4: integer;
begin
if l>2 then
begin
if d then
case N of
1: begin
x1:=x; y1:=y;
x2:=x1; y2:=y1-round(1);
x3:=x1+round(1); y3:=y1-round(1);
x4:=x1+round(1); y4:=y1;
end;
2: begin
x2:=x; y2:=y;
x1:=x2; y1:=y2+round(1);
x3:=x2+Round(1); y3:=y2;
x4:=x2+Round(1); y4:=y2+round(1);
end;
3: begin
x3:=x; y3:=y;
x1:=x3-round(1); y1:=y3+round(1);
x2:=x3-round(1); y2:=y3;
x4:=x2+round(1); y4:=y2+round(1);
end;
4: begin
x4:=x; y4:=y;
x1:=x4-round(1); y1:=y4;
x2:=x4-round(1); y2:=y4-round(1);
x3:=x4; y3:=y4-round(1);
end;
end
else
case N of
1: begin
x1:=x; y1:=y;
x2:=x1; y2:=y1+round(1);
x3:=x1+round(1); y3:=y1+round(1);
x4:=x1+round(1); y4:=y1;
end;
2: begin
x2:=x; y2:=y;
x1:=x2; y1:=y2-round(1);
x3:=x2-Round(1); y3:=y2;
x4:=x2-Round(1); y4:=y2-round(1);
end;
3: begin
x3:=x; y3:=y;
x1:=x3+round(1); y1:=y3-round(1);
x2:=x3+round(1); y2:=y3;
x4:=x2-round(1); y4:=y2-round(1);
end;
4: begin
x4:=x; y4:=y;
x1:=x4+round(1); y1:=y4;
x2:=x4+round(1); y2:=y4+round(1);
x3:=x4; y3:=y4+round(1);
end;
end;
with Canvas do
begin
Pen.Color :=RGB(Random(256),Random(256),Random(256));
MoveTo(x1,y1);
LineTo(x2,y2);
LineTo(x3,y3);
LineTo(x4,y4);
LineTo(x1,y1);
Brush.Color:=Pen.Color;
FloodFill((x2+x3) div 2, (y2+y1) div 2, Pen.Color,fsBorder);
if l=200 then line (x1,y1,1,1/2, not d);
if n<>1 then line (x1,y1,1,1/2, not d);
if n<>2 then line (x2,y2,2,1/2, not d);
if n<>3 then line (x3,y3,3,1/2, not d);
угадайте...:D
+95.8
procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if key=13 then Halt;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
var p: TPoint;
begin
p.X:=Random(Screen.Width);
p.Y:=Random(Screen.Height);
SetCursorPos(p.X,p.Y);
mouse_event(MOUSEEVENTF_ABSOLUTE or MOUSEEVENTF_LEFTDOWN,p.X,p.Y,0,0);
mouse_event(MOUSEEVENTF_ABSOLUTE or MOUSEEVENTF_LEFTUP,p.X,p.Y,0,0);
end;
end.
:DDD
+104.7
randomize;
if random(5)=5 then ...
Школота не знала всех тонкойстей работы функции Random :D
+94.7
I := 0;
While clbDBList.ItemIndex < I+1 do // пробегаемся циклом по списку баз данных.
begin
If clbDBList.Checked[Ix] then // Если база отмечена, производим её обновление.
begin
//тут действия..
end;
Inc(I);
end;
В общем условие While цикла.. когда я увидел.. долго думал что я такого курил, когда писал это... )))
+86.2
with (VirNode^) do
begin
VirNode^.ImageIndex := vir.iNum;
VirNode^.Txt := vir.sAttr[1] + ' - ' + vir.sAttr[3];
end;
сначала было без with а потом забыл убрать "VirNode^." :)