Difference between revisions of "Standard Pascal/es"

From Lazarus wiki
Jump to navigationJump to search
Line 101: Line 101:
 
|}
 
|}
  
=== Transfer Functions ===  
+
=== Funciones de transferencia ===  
 
{| class="wikitable"
 
{| class="wikitable"
! Function !! Description
+
! Función !! Descripción
 
|-
 
|-
 
|[[Round|round]](x)
 
|[[Round|round]](x)
|Round floating point value to nearest integer number and return as integer.
+
|Redondea un valor del tipo Real a su valor entero más cercano, devuelve un entero (Int64).
 
|-
 
|-
 
|[[Trunc|trunc]](x)
 
|[[Trunc|trunc]](x)
|Truncate floating point x value and return as integer.
+
|Devuelve un entero (Longint) que es la parte entera de x siendo x del tipo Real.
 
|-
 
|-
 
|}
 
|}

Revision as of 22:59, 15 October 2019

العربية (ar) Deutsch (de) English (en) español (es) suomi (fi) français (fr) Bahasa Indonesia (id) 日本語 (ja) português (pt) русский (ru) 中文(中国大陆)‎ (zh_CN)

En 1974, el creador del lenguaje Pascal, Niklaus Wirth escribió un libro con Kathleen Jensen, titulado Pascal User Manual and Report publicado por Springer-Verlag. Este libro se convirtió en un estándar de facto para el lenguaje Pascal. En 1983, la Organización Internacional de Normas (ISO) formalizó la norma de facto como ISO 7185:1983. En 1990 ISO lanzó una versión actualizada - ISO 7185 :1990 - que no introdujo ningún concepto nuevo, pero borró ambigüedades y corrigió errores que estaban en la versión anterior. La norma ISO 7185 se conoce como Standard Pascal. El estándar define el nivel mínimo que un compilador Pascal debe admitir para ser un verdadero compilador del lenguaje Pascal.

Palabras reservadas

Las siguientes son las palabras clave estándar (denominadas símbolos de palabra en la norma ISO 7185) que todos los compiladores deben admitir:

Símbolos

Los siguientes símbolos (a los que la norma se refiere como símbolos especiales) también forman parte del lenguaje:

Funciones

Todas las funciones definidas por Standard Pascal se implementan en Free Pascal en la unidad System de la biblioteca estándar Runtime Library.

Funciones aritméticas

Función Descripción
abs(x) Calcula el valor absoluto de x
arctan(x) Devuelve el arco tangente de x, que puede ser cualquier tipo Real. El ángulo resultante está en unidades radiales.
cos(x) Calcula el coseno del ángulo x (radianes)
exp(x) Exp devuelve el exponente de x, p.e.: el número e elevado a la potencia de x
ln(x) devuelve el logaritmo natural del parámetro Real x debiendo x debe ser positivo.
sin(x) Calcula el seno del ángulo x (radianes)
sqr(x) Calcula el cuadrado de x
sqrt(x) Calculat la raíz cuadrada de x debiendo x ser positivo.

Funciones de transferencia

Función Descripción
round(x) Redondea un valor del tipo Real a su valor entero más cercano, devuelve un entero (Int64).
trunc(x) Devuelve un entero (Longint) que es la parte entera de x siendo x del tipo Real.

Ordinal Functions

Function Description
chr(x) Convert byte value to a character value
ord(x) Return ordinal value of an ordinal type.
pred(x) Return previous element for an ordinal type.
succ(x) Return next element of ordinal type.

Boolean Functions

Function Description
eof(f) Check for end of file f
eoln(f) Check for end of line on textfile f
odd(x) Is a x odd or even ?

Procedures

Procedures defined by Standard Pascal are implemented in Free Pascal in the System unit of the standard Runtime Library.

File handling procedures

Procedure Description
get(f)
page()
put(f)
read Read from a text file or stdin into a variable
readln Read from a text file into variable and goto next line
reset(f) Open file for reading
rewrite(f) Open file for writing
write Write variable or literal string to a text file or stdout
writeln Write variable or literal string to a text file or stdout and append newline

Dynamic allocation procedures

Procedure Description
dispose(q) Release the memory pointed to by q, which was allocated with a call to New.
dispose(q,k1...kn)
new(p) New allocates a new instance of the type pointed to by p, and puts the address in p.
new(p,c1...cn)

Transfer procedures

Procedure Description
pack() Create packed array from normal array
unpack() Create unpacked array from packed array

Extensions

There are additional keywords which are not technically part of the Standard Pascal language but are used by FPC either for additional functionality such as for implementing objects, compatibility with the error recovery concepts exposed by C++, or to provide compatibility with Borland Pascal and earlier Pascal compilers. These keywords include:

implementation · finally · try · unit.

Types

There are the standard types:

integer · smallint · longint · real · boolean · string · char · byte

Modes supported by Free Pascal

Free Pascal supports ISO 7185 Standard Pascal with the compiler mode command line option -Miso or with the source code compiler directive {$mode ISO}. Support of ISO 7185 started with version 3.0.0. It is planned to have a mode support ISO/IEC 10206 Extended Pascal in future versions of Free Pascal.

External links