Lazarus
Home
Help
TinyPortal
Search
Login
Register
Lazarus
»
Forum
»
Programming
»
General
»
[SOLVED] Is this a valid code?
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
Has anyone installed TeeB...
by
egsuh
[
Today
at 06:34:29 am]
exception external SIGSEG...
by
dseligo
[
Today
at 06:24:13 am]
Commerce website written ...
by
Handoko
[
Today
at 05:24:32 am]
Single / Double / Float s...
by
srvaldez
[
Today
at 01:50:56 am]
Hashing pointers by using...
by
440bx
[
Today
at 01:15:38 am]
FPC 3.2.4-rc1 available
by
dsiders
[
Today
at 12:59:46 am]
Introducing PasBuild 1.0....
by
dbannon
[December 11, 2025, 11:54:37 pm]
[SOLVED] Program compiles...
by
Schmitty2005
[December 11, 2025, 07:35:39 pm]
TIBDataSet "Closing"? on ...
by
RedOctober
[December 11, 2025, 05:00:04 pm]
So many "newbies"
by
gidesa
[December 11, 2025, 04:18:38 pm]
How can I make a safe app...
by
LeP
[December 11, 2025, 03:30:34 pm]
Lazreport. Multiple print...
by
paweld
[December 11, 2025, 03:12:47 pm]
[SOLVED] Need help conver...
by
srvaldez
[December 11, 2025, 01:52:33 pm]
SpkToolbar custom update
by
wp
[December 11, 2025, 01:48:16 pm]
OS/2 Warp 4 problem with ...
by
Thaddy
[December 11, 2025, 01:35:10 pm]
Is FPGUI still active?
by
BSaidus
[December 11, 2025, 01:25:31 pm]
Bitmap into Paintbox
by
BubikolRamios
[December 11, 2025, 12:58:20 pm]
Notetask 1.1.0 - Free cro...
by
AlexanderT
[December 11, 2025, 12:11:14 pm]
Matching video to form
by
Pe3s
[December 11, 2025, 10:56:47 am]
Is Lazarus' Tool Palette ...
by
Ed78z
[December 11, 2025, 10:37:03 am]
[SOLVED] RXSwitch
by
Petrus Vorster
[December 11, 2025, 10:35:00 am]
fpsockets error: 10047
by
rvk
[December 11, 2025, 09:50:08 am]
Military Grade Directives
by
Thaddy
[December 11, 2025, 08:56:12 am]
Permutation of rows and c...
by
Zvoni
[December 11, 2025, 08:33:20 am]
Jacks or Better card game...
by
TBMan
[December 11, 2025, 03:12:03 am]
« previous
next »
Print
Pages: [
1
]
Author
Topic: [SOLVED] Is this a valid code? (Read 461 times)
egsuh
Hero Member
Posts: 1712
[SOLVED] Is this a valid code?
«
on:
April 12, 2025, 11:03:52 am »
In following example, if Options['LoopSelect'] is not 'true' or 'false' then EConvertError will be raised.
I'd like to treat '' as false.
Code: Pascal
[Select]
[+]
[-]
function
TBlockStart
.
getLoopSelect
:
boolean
;
begin
try
Result
:
=
StrToBool
(
Options
[
'LoopSelect'
]
)
;
except
Result
:
=
False
;
end
;
end
;
«
Last Edit: April 12, 2025, 12:48:10 pm by egsuh
»
Logged
Paolo
Hero Member
Posts: 643
Re: Is this a valid code?
«
Reply #1 on:
April 12, 2025, 12:17:50 pm »
Trystrtobool my help here ?
Logged
n7800
Hero Member
Posts: 586
Lazarus IDE contributor
Re: Is this a valid code?
«
Reply #2 on:
April 12, 2025, 12:23:22 pm »
Actually, there is
StrToBoolDef
for this:
Code: Pascal
[Select]
[+]
[-]
function
StrToBoolDef
(
const
S
:
string
;
Default
:
Boolean
)
:
Boolean
;
Logged
n7800
Hero Member
Posts: 586
Lazarus IDE contributor
Re: Is this a valid code?
«
Reply #3 on:
April 12, 2025, 12:25:46 pm »
By the way, there are global arrays
TrueBoolStrs
and
FalseBoolStrs
, in which you can specify acceptable values.
Logged
egsuh
Hero Member
Posts: 1712
Re: Is this a valid code?
«
Reply #4 on:
April 12, 2025, 12:47:45 pm »
function StrToBoolDef(const S: string; Default: Boolean): Boolean;
This really helps, and good enough. Thank you very much.
Logged
Print
Pages: [
1
]
« previous
next »
Lazarus
»
Forum
»
Programming
»
General
»
[SOLVED] Is this a valid code?
TinyPortal
© 2005-2018