Delphi is a strongly typed language. In VC, the assignment character uses ″=″, for example X=1, to the Delphi assignment becomes ″:=″, for example X:=1. From the value of the symbol ″:=″ without ″=″, on the looming Delphi to type matching requirements of strict, that is, the right type of assignment must be consistent with the left.
Accustomed to VB or VC programmers, the initial use of Delphi, slightly inattentive, there will be type mismatch errors. For beginners, type conversion is also the focus and difficulty of learning Delphi, for this Benwent to Delphi type conversion to do a summary, for the reference of readers.
Type conversions of one or more numbers
Converts the type of an expression from one type to another, and the resulting value truncates or expands the original value, and the sign bit remains unchanged. For example:
Type conversions of numbers
Example
Converts characters to integers
Integer (' A ')
Integer conversion to character
Char (48)
Integer converts to 1-byte logical type
Boolean (0)
Integer converts to 2-byte logical type
Wordbool (0)
Integer converts to 4-byte logical type
Longbool (0)
Integer converted to 10-in-Pascal string
CAPTION:=INTTOSTR (15)
Integer converted to 16-in-Pascal 4-bit string
Caption:=inttohex (15,4)
Address conversion to Long integer number
Longint (@Buffer)