Bu unit program çevirici işleminde kullanılır.
Kod: Tümünü seç
Unit Ads_Conv;
{Copyright(c)2000 Advanced Delphi Systems
Richard Maley
Advanced Delphi Systems
12613 Maidens Bower Drive
Potomac, MD 20854 USA
phone 301-840-1554
maley@advdelphisys.com
The code herein can be used or modified by anyone. Please retain references
to Richard Maley at Advanced Delphi Systems. If you make improvements to the
code please send your improvements to maley@advdelphisys.com so that the
entire Delphi community can benefit. All comments are welcome.
}
Interface
Uses
SysUtils, StdCtrls, Dialogs, Forms, ExtCtrls,
Messages, WinProcs, WinTypes, Buttons, Classes,
DB, DBTables, Controls, Grids, IniFiles, Graphics,
ShellAPI, FileCtrl, wininet {$IFNDEF WIN32}, ToolHelp{$ENDIF};
{!~ Converts a Boolean value to String where
True = Y
and
False = N}
Function ConvertBooleanToStringYN(bo : Boolean) : String;
{!~ Converts a Boolean value to String where
True = Yes
and
False = No}
Function ConvertBooleanToStringYesNo(bo : Boolean) : String;
{!~ Converts a Boolean value to String where
True = T
and
False = F}
Function ConvertBooleanToStringTF(bo : Boolean) : String;
{!~ Converts a Boolean value to String where
True = True
and
False = False}
Function ConvertBooleanToStringTrueFalse(bo : Boolean) : String;
{!~ Converts a String value to a Boolean}
Function ConvertStringToBoolean(sg : String) : Boolean;
{!~ Converts an integer value to its binary equivalent
as a ShortString }
Function ConvertIntegerToBinaryString(Int, Length : Integer) : ShortString;
{!~ Converts A PChar To String}
Function ConvertPCharToString(PCharValue: PChar): String;
{!~ Converts A String To Char}
Function ConvertStringToChar(InputString: String; CharPosition: Integer): Char;
{!~ Converts A String To Integer, If An Error Occurrs The Function Returns -0}
Function ConvertStringToInteger(StringValue: String): Integer;
{!~ Converts A String To A PChar, If An Error Occurrs The Function Returns 0}
Function ConvertStringToPChar(StringValue: String): PChar;
{!~ Converts a word value to its binary equivalent
as a ShortString }
Function ConvertWordToBinaryString(InputWord : Word; Length : Integer) : ShortString;
Implementation
Uses Ads_Strg;
Type
TPanel_Cmp_Sec_ads = class(TPanel)
Public
procedure ResizeShadowLabel(Sender: TObject);
End;
procedure TPanel_Cmp_Sec_ads.ResizeShadowLabel(
Sender : TObject);
Var
PH, PW : Integer;
LH, LW : Integer;
begin
PH := TPanel(Sender).Height;
PW := TPanel(Sender).Width;
LH := TLabel(Controls[0]).Height;
LW := TLabel(Controls[0]).Width;
TLabel(Controls[0]).Top := ((PH-LH) div 2)-3;
TLabel(Controls[0]).Left := ((Pw-Lw) div 2)-3;
end;
Type
TEditKeyFilter = Class(TEdit)
Published
{!~ Throws away all keys except 0-9,-,+,.}
Procedure OnlyNumbers(Sender: TObject; var Key: Char);
{!~ Throws away all keys except 0-9}
Procedure OnlyNumbersAbsolute(Sender: TObject; var Key: Char);
{!~ Throws away all keys except a-z and A-Z}
Procedure OnlyAToZ(Sender: TObject; var Key: Char);
End;
{!~ Throws away all keys except 0-9,-,+,.}
Procedure TEditKeyFilter.OnlyNumbers(Sender: TObject; var Key: Char);
Begin
KeyPressOnlyNumbers(Key);
End;
{!~ Throws away all keys except 0-9}
Procedure TEditKeyFilter.OnlyNumbersAbsolute(Sender: TObject; var Key: Char);
Begin
KeyPressOnlyNumbersAbsolute(Key);
End;
{!~ Throws away all keys except a-z and A-Z}
Procedure TEditKeyFilter.OnlyAToZ(Sender: TObject; var Key: Char);
Begin
KeyPressOnlyAToZ(Key);
End;
{!~ Converts an integer value to its binary equivalent
as a ShortString }
Function ConvertIntegerToBinaryString(Int, Length : Integer) : ShortString;
Begin
Result := ConvertWordToBinaryString(Word(Int),Length);
End;
{!~
The following example returns the binary value of 12 as a shortstring of length 8.
ConvertIntegerToBinaryString(12, 8);
}
{!~ Converts A PChar To String}
Function ConvertPCharToString(PCharValue: PChar): String;
Begin
Result := StrPas(PCharValue);
End;
{!~ Converts A String To Char}
Function ConvertStringToChar(InputString: String; CharPosition: Integer): Char;
Begin
Result := InputString[CharPosition];
End;
{!~ Converts A String To Integer, If An Error Occurrs The Function Returns -0}
Function ConvertStringToInteger(StringValue: String): Integer;
Var
I, Code: Integer;
Begin
VAL(StringValue, I, Code);
{Was There An Error}
If Not (Code=0) Then
Begin
{An Error Occurred}
Result := 0;
End
Else
Begin
{Conversion Ran Properly}
Result := I;
End;
End;
{!~ Converts A String To A PChar, If An Error Occurrs The Function Returns 0}
Function ConvertStringToPChar(StringValue: String): PChar;
Var
PCharString: Array[0..255] of Char;
Begin
Result := StrPCopy(PCharString,StringValue);
End;
{!~ Converts a word value to its binary equivalent
as a ShortString }
Function ConvertWordToBinaryString(InputWord : Word; Length : Integer) : ShortString;
var
Counter, Number : Cardinal;
D : Array[0..1] of Char;
Begin
D[0] := '0';
D[1] := '1';
Number := 1;
Result[0] := #16;
For Counter := 15 Downto 0 Do
Begin
Result[Number] :=
D[Ord(InputWord and (1 shl Counter) <> 0)];
Inc(Number);
End;
If Length > 16 Then Length := 16;
If Length < 1 Then Length := 1;
Result := SubStr(Result,16-Length,Length);
End;
{!~ Converts a Boolean value to String where
True = Y
and
False = N}
Function ConvertBooleanToStringYN(bo : Boolean) : String;
Begin
If bo Then Result := 'Y' Else Result := 'N';
End;
{!~ Converts a Boolean value to String where
True = Yes
and
False = No}
Function ConvertBooleanToStringYesNo(bo : Boolean) : String;
Begin
If bo Then Result := 'Yes' Else Result := 'No';
End;
{!~ Converts a Boolean value to String where
True = T
and
False = F}
Function ConvertBooleanToStringTF(bo : Boolean) : String;
Begin
If bo Then Result := 'T' Else Result := 'F';
End;
{!~ Converts a Boolean value to String where
True = True
and
False = False}
Function ConvertBooleanToStringTrueFalse(bo : Boolean) : String;
Begin
If bo Then Result := 'True' Else Result := 'False';
End;
{!~ Converts a String value to a Boolean}
Function ConvertStringToBoolean(sg : String) : Boolean;
Begin
Result := False;
sg := UpperCase(sg);
If (sg = 'T') Or
(sg = 'Y') Or
(sg = 'TRUE') Or
(sg = 'YES') Then Result := True;
End;
End.