Lazarus
Home
Help
TinyPortal
Search
Login
Register
Lazarus
»
Forum
»
Free Pascal
»
Beginners
(Moderators:
FPK
,
Tomas Hajny
) »
[SOLVED] Ascii code to string
Free Pascal
Website
Downloads
Wiki
Documentation
Bugtracker
Mailing List
Lazarus
Website
Downloads (Laz+FPC)
Packages (OPM)
FAQ
Wiki
Documentation (RTL/FCL/LCL)
Bugtracker
CCR Bugs
GIT
Mailing List
Other languages
Foundation
Website
Useful Wiki Links
Project Roadmap
Getting the Source
Screenshots
How to use the forum
About donations (wiki)
Bookstore
Computer Math and Games in Pascal
(preview)
Lazarus Handbook
Search
Advanced search
WIKI Timeout issues
Please read here if you have trouble connecting to the wiki
Recent
High resolution timing - ...
by
AlanTheBeast
[
Today
at 08:43:24 pm]
IStringList...
by
cdbc
[
Today
at 08:35:57 pm]
Threaded application in M...
by
AlanTheBeast
[
Today
at 07:54:52 pm]
No access to the wiki
by
zed
[
Today
at 06:53:08 pm]
A Tutorial for LazReport
by
miab3
[
Today
at 06:35:40 pm]
ShellListView Bug ?
by
Bart
[
Today
at 06:32:33 pm]
Will pay for a solution
by
Juerg
[
Today
at 05:54:28 pm]
Window positioning in QT5
by
HotShoe
[
Today
at 05:48:21 pm]
Has anyone loaded ReactOS...
by
Jonax
[
Today
at 05:36:55 pm]
FPSpreadsheet v2.0 releas...
by
paweld
[
Today
at 03:54:54 pm]
Using TMemDataset
by
rdxdt
[
Today
at 03:25:10 pm]
DBF sorting
by
Petrus Vorster
[
Today
at 02:40:11 pm]
Using AI to generate fpdo...
by
dstrenz
[
Today
at 02:24:34 pm]
FPC 3.2.4-rc1 available
by
marcov
[
Today
at 01:42:16 pm]
Why is -Cg forced and can...
by
n7800
[
Today
at 12:47:26 pm]
[SOLVED] Are there units ...
by
Thaddy
[
Today
at 11:23:06 am]
TTask 'file not found' er...
by
Thaddy
[
Today
at 11:03:46 am]
A cross-platform cryptog...
by
Thaddy
[
Today
at 10:55:38 am]
IBX 2.7.2, What's wrong w...
by
rvk
[
Today
at 10:38:10 am]
Trouble compiling fpc for...
by
ccrause
[
Today
at 07:32:32 am]
Variable number of button...
by
Fibonacci
[
Today
at 05:29:12 am]
LAMW complaining about "A...
by
nobody.00
[
Today
at 04:14:57 am]
OpenDialog is too big and...
by
user5
[
Today
at 12:54:27 am]
How do you place a breakp...
by
Hansvb
[June 23, 2025, 09:29:48 pm]
Output folder?
by
TBMan
[June 23, 2025, 08:32:57 pm]
« previous
next »
Print
Pages: [
1
]
Author
Topic: [SOLVED] Ascii code to string (Read 840 times)
CM630
Hero Member
Posts: 1409
Не съм сигурен, че те разбирам.
[SOLVED] Ascii code to string
«
on:
May 23, 2025, 08:35:22 am »
Oddly, I cannot find the answer.
I need to convert an ASCII code to a string.
In other words, I need to convert the number $48 to the string 'H'. How?
«
Last Edit: May 23, 2025, 08:43:37 am by CM630
»
Logged
Лазар 4,0 32 bit (sometimes 64 bit); FPC3,2,2
Fibonacci
Hero Member
Posts: 757
Internal Error Hunter
Re: Ascii code to string
«
Reply #1 on:
May 23, 2025, 08:37:28 am »
https://www.freepascal.org/docs-html/rtl/system/chr.html
or
Code: Pascal
[Select]
[+]
[-]
str
:
=
#
$48
;
Logged
CM630
Hero Member
Posts: 1409
Не съм сигурен, че те разбирам.
Re: [SOLVED] Ascii code to string
«
Reply #2 on:
May 23, 2025, 08:44:23 am »
Thanks, this seems to work:
Code: Pascal
[Select]
[+]
[-]
String
(
#
$48
)
or
Code: Pascal
[Select]
[+]
[-]
String
(
char
(
$48
)
)
Logged
Лазар 4,0 32 bit (sometimes 64 bit); FPC3,2,2
Thaddy
Hero Member
Posts: 17213
Ceterum censeo Trump esse delendam
Re: [SOLVED] Ascii code to string
«
Reply #3 on:
May 23, 2025, 12:44:46 pm »
The casts are not necessary. That puts people on the wrong foot imho.
Code: Pascal
[Select]
[+]
[-]
{$mode objfpc}
begin
writeln
(
#
$48
)
;
// this is already a string in hex notation: H.
end
.
Logged
Due to censorship, I changed this to "Nelly the Elephant". Keeps the message clear.
CM630
Hero Member
Posts: 1409
Не съм сигурен, че те разбирам.
Re: [SOLVED] Ascii code to string
«
Reply #4 on:
May 23, 2025, 09:47:01 pm »
Indeed. Both line result in
H
.
Code: Pascal
[Select]
[+]
[-]
procedure
TForm1
.
Button1Click
(
Sender
:
TObject
)
;
var
i
:
byte
=
$48
;
begin
ShowMessage
(
String
(
char
(
i
)
)
)
;
ShowMessage
(
char
(
i
)
)
;
end
;
Logged
Лазар 4,0 32 bit (sometimes 64 bit); FPC3,2,2
Print
Pages: [
1
]
« previous
next »
Lazarus
»
Forum
»
Free Pascal
»
Beginners
(Moderators:
FPK
,
Tomas Hajny
) »
[SOLVED] Ascii code to string
TinyPortal
© 2005-2018