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
TTask 'file not found' er...
by
sollapse
[
Today
at 01:34:50 pm]
Variable number of button...
by
MaxCuriosus
[
Today
at 01:06:37 pm]
Sqlite & Zeos
by
cdbc
[
Today
at 01:05:42 pm]
DBF / DBGRID
by
wp
[
Today
at 12:56:49 pm]
OpenDialog is too big and...
by
wp
[
Today
at 12:48:29 pm]
Why is -Cg forced and can...
by
Gustavo 'Gus' Carreno
[
Today
at 12:36:21 pm]
[SOLVED] Shenanigans with...
by
Gustavo 'Gus' Carreno
[
Today
at 12:32:00 pm]
Color change without cons...
by
HMM
[
Today
at 12:18:15 pm]
[SOLVED] Are there units ...
by
Gustavo 'Gus' Carreno
[
Today
at 11:16:37 am]
Loop Iteration Speed Test
by
paweld
[
Today
at 11:13:59 am]
Has anyone loaded ReactOS...
by
Thaddy
[
Today
at 10:51:44 am]
Status and Maintenance of...
by
Thaddy
[
Today
at 09:53:53 am]
Inheritance of Classes th...
by
Thaddy
[
Today
at 09:31:25 am]
Trouble compiling fpc for...
by
ermok
[
Today
at 09:22:20 am]
A Tutorial for LazReport
by
Thaddy
[
Today
at 09:12:25 am]
LAMW complaining about "A...
by
Alcatiz
[
Today
at 08:03:36 am]
Hints for method name mis...
by
CM630
[
Today
at 07:55:47 am]
Has the function of findi...
by
gary
[
Today
at 06:02:48 am]
TaurusTLS 1.0.0.25 beta 2...
by
J. Peter Mugaas
[
Today
at 05:26:43 am]
My second "paint" program
by
TBMan
[
Today
at 04:13:41 am]
Zeos 8, Acces violation
by
incendio
[
Today
at 04:08:35 am]
Opencv version 4.6 C++ AP...
by
Mongkey
[
Today
at 02:39:07 am]
TBitBtn no longer shows g...
by
wp
[
Today
at 01:09:04 am]
Modbus summary thread
by
bobby100
[June 22, 2025, 11:18:35 pm]
connection lost
by
ADMGNS
[June 22, 2025, 10:58:19 pm]
« previous
next »
Print
Pages: [
1
]
Author
Topic: [SOLVED] Ascii code to string (Read 837 times)
CM630
Hero Member
Posts: 1408
Не съм сигурен, че те разбирам.
[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: 755
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: 1408
Не съм сигурен, че те разбирам.
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: 17198
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: 1408
Не съм сигурен, че те разбирам.
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