Char/it: what changed
Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.
Title: Char/it
| Old | New | Line | |
|---|---|---|---|
| 1 | + | Una [[Variable|variabile]] **char** contiene un solo carattere. Un [[Byte/it|byte]] e un char sono la stessa cosa, con l'eccezione che un char può essere usato come carattere, o come parte di una [[String|stringa]], e non può essere usata in espressioni aritmetiche, mentre un byte può solo essere riferito a un'espressione numerica. | |
| 2 | + | ||
| 3 | + | Ad esempio: | |
| 4 | + | ||
| 5 | + | ``` pascal | |
| 6 | + | var ch: char; | |
| 7 | + | c: byte; | |
| 8 | + | ||
| 9 | + | begin | |
| 10 | + | ch := 'A'; c := 64; { sono la stessa azione, ed è legittimo } | |
| 11 | + | ch := 64; c := 'A'; { questo è illegittimo } | |
| 12 | + | end. | |
| 13 | + | ``` | |
| 14 | + | ||
| 15 | + | L'uso di char o byte come data type permette una migliore comprensione dell'uso della particolare variabile. Il char può essere [[coersion|convertito]] in byte usando la funzione [[Ord|ord]]. I valori delle variabile byte può essere convertito in char tramite la funzione [[Chr|chr]]. | |
| 16 | + | ||
| 17 | + | Le funzioni del char seguono il codice [[ASCII]]. | |
| 18 | + | ||
| 19 | + | Il precedente programma reso legittimo: | |
| 20 | + | ||
| 21 | + | ``` pascal | |
| 22 | + | var ch: char; | |
| 23 | + | c: byte; | |
| 24 | + | ||
| 25 | + | begin | |
| 26 | + | ch := 'A'; c := 64; { sono la stessa azione, e sono legittimi } | |
| 27 | + | ch := chr(64); c := ord('A'); { ora legittimo } | |
| 28 | + | end. | |
| 29 | + | ``` | |
| 30 | + | ||
| 31 | + | --- | |
| 32 | + | *From the Free Pascal wiki, page "Char/it", as it stood on 2020-01-24 after a change by Bart, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).* | |
| 33 | + | Category: Italiano |
