/////////////////////////////////////////////////////////// // MobSurgeon // // Редактор mob-ов для Проклятых Земель // // Copyright (C) 2005-2007 Gipat Group // // Распространяется на условиях // // Gipat Group's opened EI-editor-utility license // // версии 1.0 // // // // www.gipatgroup.org // /////////////////////////////////////////////////////////// //К работе над данным файлом приложили руки, ноги.... короче аффтары: // 1) Sagrer (sagrer@yandex.ru) //////////////////////////////////////////////////////////////////////// unit MySys; ///////////////////////////////////////// // MySys // // Короче самопальные функи всякие // // ver 1.2 // // Crafted by Sagrer // ///////////////////////////////////////// interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Grids, ExtraFunctions; type ChetireBaita = array[1..4] of byte; StoIntegerov = array[1..100] of integer; RCPCResult = record //Запись для реультатов функи CheckPathCor IsFile : boolean; IsCorrect : boolean; IsExists : boolean; end; RPzDbStrRec = record //Запись для ПЗ-шной строки из базы. Str : string; Siz : integer; end; PointToStr =^string; Function GetFilePath(FileName : string) : string; Function GetFileName(const FileName : string) : string; Function GenerateNumName(const Sch : int64; nam : string) : string; Function ByteToIntStr(const buf : byte) : string; Function Chetnoe(const Int : int64) : boolean; Function FileExistsDiv(const FName, Dir : string) : boolean; Function WstateToInt(Const WState : TWindowState) : Integer; Function IntToWstate (Const Int : integer) : TWindowState; Function ConvertDosWin(buf : byte) : byte; Function ConvertWinDos(buf : byte) : byte; Function GetDraNum(stroka : string) : byte; function GetVolumeName(RootPath:string):string; Function GetDirMin1(const pathdir : string) : string; Function GetFileName2(const FileName : string) : string; Function GetUnsignedLong(const ChB : ChetireBaita) : integer; function UnGetUnsignedLong(const intgr : integer) : ChetireBaita; Function GetFloat(const ChB : ChetireBaita) : Extended; Function UnGetFloat(const Flt : Extended) : ChetireBaita; Function RoundFloat(const Flt : Extended; Num : integer) : Extended; Function ObrezatDoNum(const Flt : Extended; Num : integer) : Extended; Function StrToFloat2(const St : String) : Extended; Function AddLastSlash(const Str : string): string; Function CheckPathCor(const Str : string) : RCPCResult; Function HasLastSlash(const Str : string) : boolean; Function GetValueStr(const Str : string) : string; Function SelGridRect (const X, Y : integer) : TGridRect; Function CheckStrPredel (const Str : string; Simvolov : integer) : boolean; Function PzDbStrToStr(const Str : string) : string; Function StrToPzDbStr(const Str : string) : RPzDbStrRec; Function FloatTo4byteStr(const Flt : Extended) : string; Function UnsLongTo4byteStr(const UnsL : Integer) : string; Function GetUnsignedLongOld(const b1, b2, b3, b4 : byte) : integer; Function _4byteStrToUnsLong(const Str : string) : integer; Function _4byteStrToFloat(const Str : string) : Extended; Function TimeTo4byteStr(const Flt : Extended) : string; Function _4byteStrToTime(const Str : string) : Extended; function FloatToStrMy(Value: Extended): string; Function GetStringSize(const Str : string) : integer; Function OtkusitStrokeBashku(Point1 : PointToStr;const baitov : integer) : string; Function IsCifra(const Ch : char) : boolean; Function CheckStrBool(const Str : string) : boolean; Function BoolTo1byteStr(const Bool : boolean) : string; Function _1byteStrToBool(const Str : string) : boolean; Function StrToPzDbStr2(const Str : string) : string; Function FilterValue(const Str : string) : string; Function _1byteStrToByte(const Str : string) : byte; Function ByteTo1byteStr(const Bt : byte) : string; Function CheckStrByte(const Str : string) : boolean; Function StrTo4bTEXT(const Str : string) : string; Function _4byteStrWth4bTEXT_ToStr(const Str : string) : string; Function CheckStr4b1bTEXT(const Str : string) : boolean; Function CheckStr4bTEXT(const Str : string) : boolean; Function DelLastSlash(const Str : string) : string; Function RenameDir(const Old, New : string) : boolean; implementation Function GetFilePath(FileName : string) : string; var I : integer; PathReady, str1 : string; begin I := 0; PathReady := ''; str1 := ''; repeat repeat I := I+1; str1 := str1+FileName[I]; until (FileName[I] = '\') or (FileName[I] = #0); If FileName[I] = '\' then PathReady := PathReady+str1; //ShowMessage(PathReady); str1 := ''; until FileName[I] = #0; result := PathReady; end; Function GetFileName(const FileName : string) : string; var I : integer; buffer, buffer2 : string; //Просто получает имя файла. begin I := 0; Buffer2 := ''; repeat repeat I := I+1; buffer := FileName[I]; if buffer <> '.' then buffer2 := buffer2 + buffer; until (buffer = '\') or (buffer = '.'); if buffer <> '.' then buffer2 := ''; until buffer = '.'; result := buffer2; end; Function GetFileName2(const FileName : string) : string; var I : integer; buffer, buffer2 : string; //Получает имя файла если он с папкой. begin I := 0; Buffer2 := ''; repeat repeat I := I+1; buffer := FileName[I]; if buffer <> '.' then buffer2 := buffer2 + buffer; until (buffer = '\') or (buffer = '.'); if buffer <> '.' then buffer2 := '' until buffer = '.'; if buffer = '.' then begin buffer2 := buffer2+ '.'; repeat I := I+1; buffer := FileName[I]; if buffer <> #0 then buffer2 := buffer2+ buffer; until buffer = #0; end; result := buffer2; end; Function GenerateNumName(const Sch : int64; nam : string) : string; begin If Sch > -1 then result := nam+'000000'+intToStr(Sch); If Sch > 9 then result := nam+'00000'+intToStr(Sch); If Sch > 99 then result := nam+'0000'+intToStr(Sch); If Sch > 999 then result := nam+'000'+intToStr(Sch); If Sch > 9999 then result := nam+'00'+intToStr(Sch); If Sch > 99999 then result := nam+'0'+intToStr(Sch); end; Function ByteToIntStr(const buf : byte) : string; var int : integer; begin int := buf; result := inttostr(int); end; Function Chetnoe(const Int : int64) : boolean; var Rea : real; Int2 : int64; begin Int2 := int div 2; Rea := int / 2; if Int2 = Rea then result := true else result := false; end; Function FileExistsDiv(const FName, Dir : string) : boolean; var st1 : string; begin result := false; st1 := FileSearch(FName,Dir); If st1 <> '' then result := true; end; Function WstateToInt(Const WState : TWindowState) : Integer; begin result := 0; If Wstate = WsMaximized then result := 1; If Wstate = WsMinimized then result := 2; If Wstate = WsNormal then result := 3; end; Function IntToWstate (Const Int : integer) : TWindowState; begin result := WsNormal; If Int = 1 then result := WsMaximized; if int = 2 then result := WsMinimized; If int = 3 then result := WsNormal; end; Function ConvertDosWin(buf : byte) : byte; begin result := buf; If buf = 137 then result := 201; If buf = 150 then result := 214; If buf = 147 then result := 211; If buf = 138 then result := 202; If buf = 133 then result := 197; If buf = 141 then result := 205; If buf = 131 then result := 195; If buf = 152 then result := 216; If buf = 153 then result := 217; If buf = 135 then result := 199; If buf = 149 then result := 213; If buf = 154 then result := 218; If buf = 148 then result := 212; If buf = 155 then result := 219; If buf = 130 then result := 194; If buf = 128 then result := 192; If buf = 143 then result := 207; If buf = 144 then result := 208; If buf = 142 then result := 206; If buf = 139 then result := 203; If buf = 132 then result := 196; If buf = 134 then result := 198; If buf = 157 then result := 221; If buf = 159 then result := 223; If buf = 151 then result := 215; If buf = 145 then result := 209; If buf = 140 then result := 204; If buf = 136 then result := 200; If buf = 146 then result := 210; If buf = 156 then result := 220; If buf = 129 then result := 193; If buf = 158 then result := 222; If buf = 240 then result := 168; If buf = 169 then result := 233; If buf = 230 then result := 246; If buf = 227 then result := 243; If buf = 170 then result := 234; If buf = 165 then result := 229; If buf = 173 then result := 237; If buf = 163 then result := 227; If buf = 232 then result := 248; If buf = 233 then result := 249; If buf = 167 then result := 231; If buf = 229 then result := 245; If buf = 234 then result := 250; If buf = 228 then result := 244; If buf = 235 then result := 251; If buf = 162 then result := 226; If buf = 160 then result := 224; If buf = 175 then result := 239; If buf = 224 then result := 240; If buf = 174 then result := 238; If buf = 171 then result := 235; If buf = 164 then result := 228; If buf = 166 then result := 230; If buf = 237 then result := 253; If buf = 239 then result := 255; If buf = 231 then result := 247; If buf = 225 then result := 241; If buf = 172 then result := 236; If buf = 168 then result := 232; If buf = 226 then result := 242; If buf = 236 then result := 252; If buf = 161 then result := 225; If buf = 238 then result := 254; If buf = 241 then result := 184; end; Function ConvertWinDos(buf : byte) : byte; begin result := buf; If buf = 201 then result := 137; If buf = 214 then result := 150; If buf = 211 then result := 147; If buf = 202 then result := 138; If buf = 197 then result := 133; If buf = 205 then result := 141; If buf = 195 then result := 131; If buf = 216 then result := 152; If buf = 217 then result := 153; If buf = 199 then result := 135; If buf = 213 then result := 149; If buf = 218 then result := 154; If buf = 212 then result := 148; If buf = 219 then result := 155; If buf = 194 then result := 130; If buf = 192 then result := 128; If buf = 207 then result := 143; If buf = 208 then result := 144; If buf = 206 then result := 142; If buf = 203 then result := 139; If buf = 196 then result := 132; If buf = 198 then result := 134; If buf = 221 then result := 157; If buf = 223 then result := 159; If buf = 215 then result := 151; If buf = 209 then result := 145; If buf = 204 then result := 140; If buf = 200 then result := 136; If buf = 210 then result := 146; If buf = 220 then result := 156; If buf = 193 then result := 129; If buf = 222 then result := 158; If buf = 168 then result := 240; If buf = 233 then result := 169; If buf = 246 then result := 230; If buf = 243 then result := 227; If buf = 234 then result := 170; If buf = 229 then result := 165; If buf = 237 then result := 173; If buf = 227 then result := 163; If buf = 248 then result := 232; If buf = 249 then result := 233; If buf = 231 then result := 167; If buf = 245 then result := 229; If buf = 250 then result := 234; If buf = 244 then result := 228; If buf = 251 then result := 235; If buf = 226 then result := 162; If buf = 224 then result := 160; If buf = 239 then result := 175; If buf = 240 then result := 224; If buf = 238 then result := 174; If buf = 235 then result := 171; If buf = 228 then result := 164; If buf = 230 then result := 166; If buf = 253 then result := 237; If buf = 255 then result := 239; If buf = 247 then result := 231; If buf = 241 then result := 225; If buf = 236 then result := 172; If buf = 232 then result := 168; If buf = 242 then result := 226; If buf = 252 then result := 236; If buf = 225 then result := 161; If buf = 254 then result := 238; If buf = 184 then result := 241; end; Function GetDraNum(stroka : string) : byte; begin stroka := UpperCase(stroka); result := 0; if stroka[1] = 'A' then result := 1; if stroka[1] = 'B' then result := 2; if stroka[1] = 'C' then result := 3; if stroka[1] = 'D' then result := 4; if stroka[1] = 'E' then result := 5; if stroka[1] = 'F' then result := 6; if stroka[1] = 'G' then result := 7; if stroka[1] = 'H' then result := 8; if stroka[1] = 'I' then result := 9; if stroka[1] = 'J' then result := 10; if stroka[1] = 'K' then result := 11; if stroka[1] = 'L' then result := 12; if stroka[1] = 'M' then result := 13; if stroka[1] = 'N' then result := 14; if stroka[1] = 'O' then result := 15; if stroka[1] = 'P' then result := 16; if stroka[1] = 'Q' then result := 17; if stroka[1] = 'R' then result := 18; if stroka[1] = 'S' then result := 19; if stroka[1] = 'T' then result := 20; if stroka[1] = 'U' then result := 21; if stroka[1] = 'V' then result := 22; if stroka[1] = 'W' then result := 23; if stroka[1] = 'X' then result := 24; if stroka[1] = 'Y' then result := 25; if stroka[1] = 'Z' then result := 26; end; function GetVolumeName(RootPath:string):string; var VNBuffer:array[0..11] of char; MCLength,FSFlags:DWORD; begin Result:=''; if GetVolumeInformation(PChar(RootPath),VNBuffer,SizeOf(VNBuffer),nil,MCLength,FSFlags,nil,0) then Result:=string(VNBuffer); end; Function GetDirMin1(const pathdir : string) : string; var I : integer; str1, str2 : string; begin I := 0; str1 := ''; str2 := ''; repeat str2 := str2+str1; repeat I := I+1; str1 := str1+pathdir[I]; until pathdir[i] = '\'; until pathdir[I+1] = #0; result := str2; end; Function GetUnsignedLong(const ChB : ChetireBaita) : integer; begin //Процедура получения целого числа из 4 байтов. CopyMemory(@result,@ChB,4); end; Function GetUnsignedLongOld(const b1, b2, b3, b4 : byte) : integer; var i1, i2, i3, i4, sum : integer; begin //Процедура получения целого числа из 4 байтов. i1 := b1; i2 := b2*256; I3 := b3*65536; I4 := b4*16777216; sum := i1+i2+i3+i4; result := sum; end; function UngetUnsignedLong(const intgr : integer) : ChetireBaita; begin CopyMemory(@result,@intgr,4); end; Function GetFloat(const ChB : ChetireBaita) : Extended; var Fl : single; begin CopyMemory(@Fl,@ChB,4); Result := Fl; end; Function UnGetFloat(const Flt : Extended) : ChetireBaita; var Fl : Single; begin Fl := Flt; CopyMemory(@result,@Fl,4); end; Function RoundFloat(const Flt : Extended; Num : integer) : Extended; var Fl1, Fl2, Fl3 : Single; Ch1, Ch2, Ch3, Ch4 : string; I, Dop : integer; Minused : boolean; begin If FloatToStrMy(Flt) <> 'NAN' then begin //Функа округления флоата (сингла) до Num знака после запятой. Minused := false; Fl3 := Flt; If Flt < 0 then begin //Если отрицат. число... Fl3 := Flt*-1; Minused := true; end; Fl1 := int(Fl3); //Целая часть Fl2 := Frac(Fl3); //Дробная часть Ch1 := FloatToStr(Fl1); Ch2 := FloatToStr(Fl2); //Получение дробной части без нуля и запятой до Num знака... if Fl2 <> 0 then begin Ch3 := ''; I := 2; repeat I := I+1; if Ch2[I] <> #0 then Ch3 := Ch3+Ch2[I]; until (ch2[I] = #0) or (I = Num+2); if ch2[I] = #0 then I := I-1; //Если надо круглить.... if I = Num+2 then begin I := Num; if StrToInt(Ch3[I]) > 4 then begin //Если всетаки надо круглить... Ch3[I] := IntToStr(0)[1]; Dop := 1; repeat I := I-1; if ch3[I] = IntToStr(9)[1] then begin ch3[I] := IntToStr(0)[1]; end else begin Ch3[I] := IntToStr(StrToInt(Ch3[I])+Dop)[1]; Dop := 0; //типа, если эта ветка сработала, то больше округления не //требуется. Типа конец округляния :) I := 1; end; until I = 1; end; end; For I := 1 to 15 do begin //Донулить до 15 знаков после запятой. if I > Num then Ch3 := Ch3+'0'; end; Ch4 := Ch1+','+Ch3; end else begin Ch3 := ','; For I := 1 to 15 do begin Ch3 := Ch3+'0'; end; Ch4 := Ch1+Ch3; end; Result := StrToFloat(Ch4); If Minused then Result := Result*-1; end else result := Flt; end; Function ObrezatDoNum(const Flt : Extended; Num : integer) : Extended; var St1, St2 : String; I : integer; begin St1 := FloatToStrMy(Flt); St2 := ''; For I := 1 to Num do begin St2 := St2+St1[I]; end; Result := StrToFloat(St2); end; Function StrToFloat2(const St : String) : Extended; var ChB : ChetireBaita; begin ChB[1] := 255; ChB[2] := 255; ChB[3] := 255; ChB[4] := 255; If St <> 'NAN' then result := StrToFloat(St) else Result := GetFloat(ChB); end; Function HasLastSlash(const Str : string) : boolean; //Функа для проверки наличия последнего слэша. var I : integer; LastCh : char; begin I := 0; LastCh := #0; repeat I := I+1; If str[I] <> #0 then begin LastCh := str[I]; end; until str[I] = #0; //Если последний символ слэш то резулт тру, иначе фалс: If LastCh = '\' then result := true else result := false; end; Function AddLastSlash(const str : string): string; //Функа для добавления в путь последнего слэша (если надо). begin //Если последний символ не слэш - то приплюсоватить его туды. If HasLastSlash(str) = false then result := str+'\' else result := str; end; Function CheckPathCor(const Str : string) : RCPCResult; //Функа предназначена для проверки правильности написания пути. //А также - существует ли этот путь. var IsCorrect, IsExists, IsFile : boolean; begin //Умолчания поставить. IsCorrect := false; IsExists := false; IsFile := false; //Проверка правильности If (Str[2] = ':') and (str[3] = '\') then begin IsCorrect := true; //Это файл или папка. If HasLastSlash(str) = false then IsFile := true; //Далее в зависимости если... If IsFile = true then begin //... это файл. IsExists := FileExists(Str); end else begin //... это папка. IsExists := DirectoryExists(Str); end; end; //Вернуть резалт. result.IsFile := IsFile; result.IsExists := IsExists; result.IsCorrect := IsCorrect; end; Function GetValueStr(const Str : string) : string; //Эта функа выдергивает из строки только то что стоит после знака "=" var I : integer; begin //Прокрутить до начала нужного значения I := 0; repeat I := I+1; until Str[I] = '='; //Получить собственно значение. result := ''; repeat If Str[I] <> #0 then result := result+Str[I]; until Str[I] = #0; end; Function SelGridRect (const X, Y : integer) : TGridRect; //Ну типа эта функа будет на основании X и Y делать выделение одной //ячейки в виде GridRect и выводить его в результат. // Применение: для разных Grid-о подобных VCL-компонентов. begin Result.Left := X; Result.Right := X; Result.Top := Y; Result.Bottom := Y; end; Function CheckStrPredel (const Str : string; Simvolov : integer) : boolean; //Эта функа проверяет, не больше ли в строке символов, чем некоторое число. var I : integer; begin I := 0; If Str <> '' then begin repeat I := I+1; until Str[I] = #0; I := I-1; end; If I > Simvolov then result := false else result := true; end; Function PzDbStrToStr(const Str : string) : string; //Функа для перекидона строк из баз ПЗ в нормальные строки (ноль в конце убрать). var I : integer; begin result := ''; I := 0; repeat I := I+1; If Str[I] <> #0 then result := result+Str[I]; until Str[I] = #0; end; Function StrToPzDbStr(const Str : string) : RPzDbStrRec; //Функа для перевода паскалевских строк в строку ПЗ + подсчет ее длины. var I : integer; begin I := 0; result.Str := ''; //Прибавка нуля в конец строки и подсчет ее длины... If Str <> '' then begin repeat I := I+1; result.Str := result.Str+Str[I]; until Str[I] = #0; end else begin I := 1; Result.Str := ''+#0; end; result.Siz := I; end; Function StrToPzDbStr2(const Str : string) : string; //Функа для перевода паскалевских строк в строку ПЗ. begin result := Str+#0; end; Function FloatTo4byteStr(const Flt : Extended) : string; //Функа переводит число с плавающей точкой в строку, но //не в виде текста а в виде 4 байтов в строке. var ChB : ChetireBaita; begin ChB := UngetFloat(Flt); Result := ''; Result := Char(ChB[1]); Result := Result+Char(ChB[2]); Result := Result+Char(ChB[3]); Result := Result+Char(ChB[4]); end; Function UnsLongTo4byteStr(const UnsL : Integer) : string; //Функа переводит UnsLong в строку, но не в виде текста, // а в виде 4 байтов в строке. var ChB : ChetireBaita; begin ChB := UngetUnsignedLong(UnsL); Result := Char(ChB[1]); Result := Result+Char(ChB[2]); Result := Result+Char(ChB[3]); Result := Result+Char(ChB[4]); end; Function _4byteStrToUnsLong(const Str : string) : integer; //Функа для упрощенного перевода 4-байтовой строки в интегер var ChB : ChetireBaita; begin ChB[1] := byte(str[1]); ChB[2] := byte(str[2]); ChB[3] := byte(str[3]); ChB[4] := byte(str[4]); result := GetUnsignedLong(ChB); end; Function _4byteStrToFloat(const Str : string) : Extended; //Функа для упрощенного перевода 4-байтовой строки в флоат var ChB : ChetireBaita; begin ChB[1] := byte(str[1]); ChB[2] := byte(str[2]); ChB[3] := byte(str[3]); ChB[4] := byte(str[4]); result := GetFloat(ChB); end; Function TimeTo4byteStr(const Flt : Extended) : string; //Функа для перевода TIME в 4байт строку. var Flt1 : Extended; int1 : integer; begin Flt1 := Flt; Flt1 := ((Flt1-0.1)*15)+1; Int1 := Round(Flt1); //Округлить... Result := UnsLongTo4byteStr(Int1); end; Function _4byteStrToTime(const Str : string) : Extended; //Функа для упрощенного перевода 4-байтовой строки в TIME. var int1 : integer; begin int1 := _4ByteStrToUnsLong(Str); Result := (((int1-1)/15)+0.1); Result := ObrezatDoNum(Result,3); end; function FloatToStrMy(Value: Extended): string; //Функа переводит флоат в строку с добавлением в конец ,0 если нет //дробной части. var Str1 : string; I : integer; NetZapyatoy : boolean; begin Str1 := FloatToStr(Value); If Str1 <> 'NAN' then begin I := 0; NetZapyatoy := true; repeat I := I+1; If Str1[I] = ',' then NetZapyatoy := false; until Str1[I] = #0; If NetZapyatoy then result := Str1+',0' else result := Str1; end else result := Str1; end; Function GetStringSize(const Str : string) : integer; var I : integer; begin //Функа для подсчета длины строки. If Str <> '' then begin I := 0; repeat I := I+1; until Str[I] = #0; result := I-1; end else result := 0; end; Function OtkusitStrokeBashku(Point1 : PointToStr;const baitov : integer) : string; var I : integer; BufSt : string; begin //Функа должна отрезать от строки первые baitov байтов, //и возвращать их в резалте. //Сначала приготовить резалт result := ''; For I := 1 to baitov do begin result := result+Point1^[I]; end; //Теперь получить строчку без первых батйтов. BufSt := ''; If Length(Point1^) > baitov then begin //Если меньше или равно - просто прицепится строка будет пустой. For I := baitov+1 to Length(Point1^) do begin BufSt := BufSt+Point1^[I]; end; end; //Теперь изменить саму строку. Point1^ := BufSt; //Ну вот, в принципе, и все... end; Function IsCifra(const Ch : char) : boolean; begin //Функция проверяет, является ли символ цифрой. result := false; If Ch = '0' then result := true; If Ch = '1' then result := true; If Ch = '2' then result := true; If Ch = '3' then result := true; If Ch = '4' then result := true; If Ch = '5' then result := true; If Ch = '6' then result := true; If Ch = '7' then result := true; If Ch = '8' then result := true; If Ch = '9' then result := true; end; Function CheckStrBool(const Str : string) : boolean; begin //Функа проверяет, бульен в строке или нет. If (Str <> '1') and (Str <> '0') then result := false else result := true; end; Function BoolTo1byteStr(const Bool : boolean) : string; var Str1 : string; b1 : byte; begin //Функа переводит бульен в чар в виде строки. Str1 := BoolToStr(Bool); b1 := StrToInt(Str1[1]); result := char(b1); end; Function _1byteStrToBool(const Str : string) : boolean; var b1 : byte; begin //Функа переводит строку в буль. b1 := byte(Str[1]); If b1 = 0 then result := false else result := true; end; Function FilterValue(const Str : string) : string; //Функа возвращает начало строки - до первого пробела. var I : integer; begin result := ''; If Str <> '' then begin I := 0; repeat I := I+1; if (Str[I] <> ' ') or (I > length(Str)) then begin result := result + str[I]; end; until (I = length(Str)) or (Str[I] = ' '); end; end; Function _1byteStrToByte(const Str : string) : byte; //Функа для упрощенного перевода 1-байтовой строки в байт begin result := Byte(Str[1]); end; Function ByteTo1byteStr(const Bt : byte) : string; //Функа переводит UnsLong в строку, но не в виде текста, // а в виде 4 байтов в строке. begin Result := Char(Bt); end; Function CheckStrByte(const Str : string) : boolean; //Проверялка строки с инфой типа байт... begin Result := false; If CheckStrInt(Str) = true then begin If (StrToInt(Str) <= 255) and (StrToInt(Str) >= -128) then begin Result := true; end; end; end; Function StrTo4bTEXT(const Str : string) : string; //Функа для перевода паскалевских строк в 4bTEXT. //В этой строке по любому 4 байта, но первые - текст. //незанятые - всегда нули. var I : integer; begin I := Length(Str); If I <= 4 then begin result := ''; result := result + Str; If I < 4 then begin repeat I := I+1; result := result+#0; until I >= 4; end; end else begin Result := #0+#0+#0+#0; end; end; Function _4byteStrWth4bTEXT_ToStr(const Str : string) : string; //Функа для упрощенного перевода 4-байтовой строки в //виде 4bTEXT, в паскалевскую строку. var I : integer; begin I := 0; result := ''; repeat I := I+1; If Str[I] <> #0 then begin result := result + Str[I]; end; until Str[I] = #0; end; Function CheckStr4b1bTEXT(const Str : string) : boolean; begin //Задача этой функи - проверить, строка ли это и 1 ли в ней символ. //вот такая вот тупость ;), но мне проще каждый раз вызывать эту //функу, чем каждый раз писать код. If Length(Str) <= 1 then begin Result := true; end else begin Result := false; end; end; Function CheckStr4bTEXT(const Str : string) : boolean; begin //Задача этой функи - проверить, строка ли это и 1 ли в ней символ. //вот такая вот тупость ;), но мне проще каждый раз вызывать эту //функу, чем каждый раз писать код. If Length(Str) <= 4 then begin Result := true; end else begin Result := false; end; end; Function DelLastSlash(const Str : string) : string; //Удаляет последний слеш если он есть. begin Result := ''; if HasLastSlash(Str) = true then begin SetLength(Result,Length(Str)-1); CopyMemory(@Result[1],@Str[1],Length(Str)-1); end else begin Result := Str; end; end; Function RenameDir(const Old, New : string) : boolean; //Переименовывает директорию. var DirFile : File; begin Result := true; if FileExists(New) = false then begin AssignFile(DirFile,DelLastSlash(Old)); Rename(DirFile,DelLastSlash(New)); end else begin Result := false; end; end; end.