With the arrival of typecasting a generic approach became possible, making ord mostly obsolete. Historical note: Originally, Pascal did not have typecasts and ord was a necessary function in order to do certain operations on non-integer ordinal types.
Free pascal ord mac os#
Supported operating systems include Windows (16/32/64 bit, CE, and native NT), Linux, Mac OS X/iOS/iPhoneSimulator/Darwin, FreeBSD and other BSD flavors, DOS (16 bit, or 32 bit DPMI), OS/2, AIX, Android, Haiku, Nintendo GBA/DS/Wii, AmigaOS, MorphOS, AROS. Description Ord returns the Ordinal value of a ordinal-type variable X. It can target many processor architectures: Intel x86 (16 and 32 bit), AMD64/x86-64, PowerPC, PowerPC64, SPARC, SPARC64, ARM, AArch64, MIPS, Motorola 68k, AVR, and the JVM. String capacity is omitted and thus set to 255 by default. Free Pascal is a mature, versatile, open source Pascal compiler. ord returns ASCII-code of a character, while chr converts given ASCII-code into a character.
This example processes the string char by char, and works with ASCII-codes to figure out whether they are lower- or uppercase letters. With other words, in addition to the syntax 'if comparison then assign 1 else assign 0' the following syntax can be optimized too: 'if comparison then assign not (0) else assign 0', at least when targeting x8664. result:word(ord(bytebool( x y))) end and so on, which means that ORD can be used not just to assign zeros and ones, but also zeros and not (zero)s. function Test3 ( x, y: sizeuint): sizeuint begin. Program Camelcase var text, cc : string c : char i : integer lastSpace : boolean upper, lower : set of char begin upper := lower := readln ( text ) lastSpace := true cc := '' for i := 1 to Length ( text ) do begin c := text if ( c in lower ) or ( c in upper ) then begin if ( lastSpace ) then if ( c in upper ) then c := chr ( ord ( c ) + 32 ) cc := cc + c lastSpace := false end else lastSpace := true end writeln ( cc ) end. result:byte(ord(bytebool( x y))) end //returns 0 or 65535.
Free pascal ord series#
Note that in Turbo Pascal series this program works only with Turbo Pascal 4.0 and higher due to the fact that earlier versions didn’t have char datatype. This example is similar to previous one, but uses sets of characters for letter check.
Program Quadratic var A, B, C, D : integer begin write ( 'A = ' ) readln ( A ) if ( A = 0 ) then begin writeln ( 'Not a quadratic equation.' ) halt end write ( 'B = ' ) readln ( B ) write ( 'C = ' ) readln ( C ) D := B * B - 4 * A * C if ( D = 0 ) then begin writeln ( 'x = ' ,- B / 2.0 / A ) halt end if ( D > 0 ) then begin writeln ( 'x1 = ', ( - B + Sqrt ( D )) / 2.0 / A ) writeln ( 'x2 = ', ( - B - Sqrt ( D )) / 2.0 / A ) end else begin writeln ( 'x1 = (' ,- B / 2.0 / A, ',', Sqrt ( - D ) / 2.0 / A, ')' ) writeln ( 'x2 = (' ,- B / 2.0 / A, ',' ,- Sqrt ( - D ) / 2.0 / A, ')' ) end end.