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
Forum Rules
About donations (wiki)
Bookstore
Computer Math and Games in Pascal
(preview)
Lazarus Handbook
Search
Advanced search
Recent
Interesting video
by
backprop
[
Today
at 10:57:07 pm]
New version of LazMapView...
by
wp
[
Today
at 10:56:43 pm]
If FileExists(
by
Bart
[
Today
at 10:39:03 pm]
Message CM_ShowingChanged...
by
AlexTP
[
Today
at 09:11:53 pm]
Which Control should I us...
by
J-G
[
Today
at 08:36:07 pm]
If you are looking for Wi...
by
avra
[
Today
at 07:37:10 pm]
SynEdit theme
by
Martin_fr
[
Today
at 07:35:26 pm]
Program experiencing runt...
by
Handoko
[
Today
at 05:26:59 pm]
Can /my/ AI help me with ...
by
microxa
[
Today
at 04:26:18 pm]
Lazarus Bugfix Release 4....
by
Martin_fr
[
Today
at 03:57:39 pm]
Testing with 3.2.4 prepar...
by
Martin_fr
[
Today
at 03:50:17 pm]
IndySecOpenSSL is now ava...
by
LeP
[
Today
at 10:22:50 am]
TDWEdit
by
Ed78z
[
Today
at 10:20:58 am]
Strange Behaviour at Runt...
by
andrew Bubble
[
Today
at 09:54:40 am]
FPC Debug mode releases [...
by
Martin_fr
[
Today
at 09:22:25 am]
Implementing an Elo ratin...
by
paule32
[
Today
at 08:43:20 am]
Death of the Power User
by
wp
[
Today
at 01:29:18 am]
how to add a ForEach call...
by
mas steindorff
[June 11, 2026, 11:42:24 pm]
How to define a type of ...
by
PascalDragon
[June 11, 2026, 09:24:45 pm]
Gitlab site history date.
by
Martin_fr
[June 11, 2026, 08:46:17 pm]
Arkanoid
by
lazarusprogrammer
[June 11, 2026, 08:14:21 pm]
[New Component] ExtTabCtr...
by
d7_2_laz
[June 11, 2026, 05:01:49 pm]
Conscious Artificial Inte...
by
schuler
[June 11, 2026, 04:39:11 pm]
Pdf Viewer in Pascal
by
Tomxe
[June 11, 2026, 03:52:37 pm]
Eye Candy TESCheme
by
Dzandaa
[June 11, 2026, 11:51:52 am]
« previous
next »
Print
Pages: [
1
]
Author
Topic: [SOLVED] Ascii code to string (Read 1122 times)
CM630
Hero Member
Posts: 1700
Не съм сигурен, че те разбирам.
[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,4 32 bit (sometimes 64 bit); FPC3,2,2
Fibonacci
Hero Member
Posts: 1000
Behold, I bring salvation - FPC Unleashed
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
FPC Unleashed
- inline vars, tuples, statement expressions, array equality, compound assignments, indexed/lazy labels, no-RTTI & more. ⭐
Star it on GitHub!
CM630
Hero Member
Posts: 1700
Не съм сигурен, че те разбирам.
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,4 32 bit (sometimes 64 bit); FPC3,2,2
Thaddy
Hero Member
Posts: 19268
Glad to be alive.
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
objects are fine constructs. You can even initialize them with constructors.
CM630
Hero Member
Posts: 1700
Не съм сигурен, че те разбирам.
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,4 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