Type Size Range = 3=3 true Boolean 1 false or true 2=3 false
Byte 1 0..255 < 3<4 true
Cardinal 4 0..4294967295 <= 2 <= 3 true
Copyright, 2007-2008 BrandsPatch LLC Char 1 Extended ASCII > 'explain' > 'Explain' true http://www.explainth.at Color key overleaf Currency 8 9.22E14 >= 5 >= 4 true Unit Structure Double 8 5E-324..1.7E308 <> 2 <> 3 true 'explain' <> 'explain' false unit unitName; Extended 10 3.6E-4951..1.1E4932 interface shl 1 shl 2 4 Integer 4 -2147483648..2147483647 [uses UnitA,UnitB...; shr 2 shr 1 1 class declarations1 Int64 8 -263..263 - 1 i:=2;j:=7 exports routineA,routineB...;2 PChar 4+2 pointer to array of char and (i < 3) AND (j >= 5) true var Variables]3 Pointer 4 Generic Pointer i AND j 2 implementation P# 4 # is Integer, Double, etc or (i < 3) or (j > 7) false [{$R *.dfm}1 i OR j 7 {$R WindowsXP.res}4 PWideChar 4+3 pointer to arry of widechar xor (i < 3) XOR (j = 5) true {$R resourceName.res}5 Set 32 See below4 (i < 3) XOR (j = 7) false exports routineA,routineB...;2 (i > 2) XOR (j < 7) false String 4+2 string of char uses UnitAA,UnitBB...; i XOR j 5 TDateTime 8 See below5 var Variables;5] not (i < 3) AND NOT(j > 7) true Code... WideChar 2 Unicode Character not(i) -3 [initialization Initialization Code;] WideString 4+6 string of Unicode characters s1:=[1..3];s2:=[3..7] [ initialization Initialization Code; Word 2 0..65535 + s1 + s2 [1..7] finalization Finalization Code;6] 1. Other types exist. - s1 s2 [1,2] end. 2. 4 + length of string + 1 s2 - s1 [4..7] 1. In a form this includes one form and the $R *.dfm 3. 4 + 2 bytes per stored widechar statement below is obligatory. 4. To store bytes, chars, enumerations with < 256 * s1*s2 [3] members etc. 2. To export routines from a library with unit in its uses 5. 0 is 12:00 am, 12/30/1899. No values between -1 & 0. s1:=[1..3];s2:=[1,2,3];s3:=[1..7] clause. Fraction represents time of day, e.g. 0.25 = 6:00 am. <= s1 <= s3 true 3. Visible in all units that use the present unit For dates prior to 12/30/1899, add time of day to 4. For WindowsXP style UI effects. absolute value of day, e.g. -1.25 for 6:00 am >= s3 >= s2 true 12/29/1899. 5. Any custom resources used. 6. 4+ twice length of string + 1 = s1 = s2 true 6. Visible within the unit Special Constants <> s1 <> s2 false 7. Initialization/finalization code can be a procedure call. false, true, nil, MAXWORD, MAXINT, MAXDOUBLE, No finalization without initialization but just a blank MINDOUBLE etc. in 4 in s1 false initialization statement is enough. 5 in s3 true Names & Notation Enumerations exclude exclude(s1,3) [1,2] e.g. type TDelphiVersion = (dv5[ = 5],dv6,dv7,dv8) As a general rule all identifier names i.e. names for include include(s1,9) [1,2,9] units, controls, objects, variables... - must be Enumerations can be manipulated using inc, dec, pred alphanumeric or the _ character. The first character and succ. ord can be used to get their ordinal value. Conversion from Stringsii cannot be a number. Prepend enumeration members with two or more StrToCurDef(s,def) s to currency. def on error. lowercase letters identifying their parent enumeration. StrToInt[64]Def(s,def) s to integer. def on error. There is no single accepted notation standard. We suggest the following Enumerated values require one or more depending on StrToFloatDef(s,def) s to real. def on error. StrToDateTimeDef(s,def) s to datetime. def on error. Hungarian style notation for control/component & the number of members in the parent enumeration. val(S,V,Code) s converted to number & stored in V. interface identifiers. e.g. btnName for a TButton control Array Types Code > 0 indicates position in s of first error. with Name describing its function. Any ordinal type can be used to define an array type. Conversions to Stringsii i,j,k... for generic integer variables used as loop e.g. FloatToStr(value) value as a string. counters etc. TVersions = array[TDelphiVersions] of String; Format(ptrn,[arg1,arg2...])* - uses ptrn to build a string. Javascript style descriptive camel capitalized names %d, %f etc in pattern are replaced by values in args. TLevels = array[-3..3] of Integer; FormatDateTime(ptrn,datetime) returns datetime as for all other variables. e.g. intRate. TLetters = array['a'..'z'] of Char; string formatted using ptrn. If ptrn is empty uses short Names are not case sensitive. date format. TInfo = array[Boolean,0..9] of PChar; FormatFloat(ptrn,value) returns value as string Visibility, Scope & Garbage Collection Operators formatted using ptrn. Variables declared inside a routine are only visible Operator Example Result IntToHex(value,N) value in hexadecimal with N digits within the routine and to nested routines. IntToStr(value) value as a string. + 3+2 5 Date & Time Routinesii Declarations using the var keyword in the interface 'explain' + 'that' explainthat section of a unit are visible within the unit and wherever Date current date, time fraction set to zero. the unit is present in a uses clause. - 3-2 -1 DateTimeToStr(d) d to string using locale. DecodeDate(Date,Y,M,D) year, month & day to YMD Declarations using the var keyword in the * 3*2 6 DecodeTime(Date,H,M,S,N) hrs, mins, s & ms to implementation section of a unit are visible within the HMSN unit. / 3/2 1.5 EncodeDate(Y,M,D) returns datetime value. Objects implementing interfaces are reference counted. div 3 div 2 1 EncodeTime(H,M,S,N) returns time fraction of They are destroyed when their reference count reaches datetime. zero. All other objects and any allocated memory must mod 3 div 2 3 (3 div 2)*2 FormatDateTime(Format,Date) returns formatted date be explicitly destroyed/released after use. string Delphi Quick Reference Card1.01
Drive/File/Folder Manipulationii d day, no leading zero. case selector of
ChangeFileExt(AFile,AExt) returns filename with new dd day, leading zero if necessary caseList1:code; extension. AExt must include the . character. caseList2:code; System.ChDir(dir) changes current directory. ddd Short day names CreateDir(dir) creates directory. false on error. dddd Long day names ... SysUtils.DirectoryExists(dir) true if dir exists. caseListn:code; SysUtils.DiskFree(drive) free bytes on drive. 0 = m, mm, mmm, mmmm Month names, as above. yy - two digit year [else code;] current, 1 = A etc. ExtractFileExt(AFile) returns .ext. end; yyyy four digit year. ExtractFileName(AFile) returns filename.ext. selector can be any ordinal type. code can be a ExtractFilePath(AFile) returns everything before h, n, s hour, minute & second. No leading zero. function/procedure call. filename.ext. hh, nn,ss- hour, minute & second with leading zero Looping ForceDirectories(path) creates all directories in path. t ShortTimeFormat false on error. for i:=LowBound to HighBound do System.GetDir current directory. tt LongTimeFormat begin RemoveDir(dir) removes dir. am/pm Use 12h clock. Follow h|hh by am or pm Code; Execution/Flow Control ampm use 12h clock. Follow h|hh by TimeAM| SysUitls.abort raise silent exception end; PMString global variables. break - break from loop ( for, repeat or while) continue continue to next iteration of loop / date separator as in DateSeparator global variable for i:=HighBound downto LowBound do exit exit from current procedure : time separator as in TimeSeparator global variable. halt immediate termination of program begin 'xx' or xx - literal characters Number Manipulationiii Code; abs - returns absolute value Format function specifiers end; Math.ceil(arg) lowest integer >= arg Format strings consist of one or more specifiers bearing exp(N) returns eN the form %[-][w].[d]L where repeat Math.floor(arg) highest integer <= arg frac(N) fractional part of N - indicates left justification. (The default is right) Code; int(N) - integer part of real number N w indicates the total character width of the output until Condition; Math.log10(N) log to the base 10 of N value. If necessary this is padded out with spaces Math.log2(N) log to the base 2 of N right or left depending on the justification specifier. Random random number in the range 0..1 while Codition Randomize initialize random number generator d is the precision specifier. The meaning of this RandSeed Seed value for random number generator. depends on the nature of the quantity being formatted. begin Round(N) round N to nearest whole number. Midway The number of characters in integers & Code; values rounded to even number. hexadecimal integers. end; Math.RoundTo(N,d) round N to 10d The number of decimals in real numbers in general Ordinal Manipulation , f, format. dec(arg,N) decrements ordinal arg by N Dispense with the begin & end to execute a single line high(arg) high bound of arg type. The number of decimals + the E in real numbers in of code. repeat loops execute at least once. Use break, inc(arg,N) increments ordinal arg by N scientific format. continue or exit to modify/terminate loop execution. low(arg) low bound of arg type. The number of characters in a string. Notes ord(arg) ordinal value of boolean, char or enumerated L indicates that nature. d for integer, f for real, e for i MAXDOUBLE etc are defined in Math. arg. scientific, n real but with thousands separators, s for ii Unless preceded by Unit., the routine is in SysUtils pred(arg) predecessor of ordinal type arg. string and x for hexadecimal integer. succ(arg) subsequent value of ordinal type arg. iii Unless preceded by Unit., the routine is in System iii Example Function String Manipulation iv Unless preceded by Unit., the routine is in Variants chr(arg) ASCII character at arg. %d Simple Integer formatting * For widestrings use the same function but preceeded SysUtils.CompareStr(s1,s2)* case sensitive comparison. s1 < s2 returns -1;s1 = s2 returns 0 & s1 > %0.nd Integer with n digits padded if by Wide, e.g. WideFormat. s2 returns 1. shorter SysUtils.CompareText(s1,s2)* case insensitive %m.nd Integer with n digits in a width of m. Color Codes comparision. Returns as above. m is ignored if insufficient. Copy(s,Index,Count) Count characters in s starting from Index. %m.nf Floating point number, width m with blue Delphi keyword Delete(s,Index,Count) deletes Count characters in s n decimal digits. green Delphi routine (function or procedure) starting at Index. StrUtils.LeftStr(s,Count) Count characters in s %-m.nf As above but left justified. [option] - optional starting from the left. RightStr is similar. Math. - unit to be specified in uses clause. Does not %m.ns String formatted to a width of m apply to System. StrUtils.MidStr(s,Index,Count) Count characters in s characters and containing n starting from Index. characters. Truncated if n is less Length(s) number of characters in s. than string length. n is ignored if An extensive range of free quick reference cards is SysUtils.LowerCase(s)* s in lower case. UpperCase available at http://www.explainth.at greater than string length. is similar. SysUtils.SameText(s1,s2)* returns true if s1 = s2, not %m.nx Integer in hexadecimal format. Rest case sensitive. Returns true or false. as for %d, above. SetLength(s,len) sets length of string s to len. StringOfChar(Char,Count) - returns string containing Other options exist. Count Chars. UpCase(c) character c in uppercase. Conditional Execution/Brancing Variant Manipulationiv Multiline if..then..else VarFromDateTime(date) date as a variant. VarToDateTime(V) V as TDateTime. if Condition then VarAsType(V,AType) V converted to variant of type begin AType. Code VarToStr(V) V as a string. end[ else VarToWideStr(V) V as a widestring. begin VarType(V) variant type of V. Code Format Specifiers end]; DateTime Formats Single line if..then..else c ShortDateFormat if Condition then Code else Code;
Consumers' Preferences and Willingness To Pay For Bio-Fortified Vitamin-A Garri in South Western, Nigeria: A Conjoint Analysis and Double-Hurdle Model Estimation