• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 317
  • Last Modified:

using or with strings

I am trying to use a line like
"if string = '.bmp' or '.jpg' then
but I get
[DCC Warning] MAIN.PAS(376): W1058 Implicit string cast with potential data loss from 'string' to 'ShortString'

It also doesn't seem to work if I type
"if string = 'bmp' or if string = '.jpg' "then

how can I write this ?
  • 2
1 Solution
Ephraim WangoyaCommented:

do it like this

if (string = '.bmp') or (string = '.jpg') then
Ephraim WangoyaCommented:

if you want it cleaner, you can use AnsiIndexText

if AnsiIndexText(lowercase(yourstring), ['.bmp', '.jpg']) >= 0 then
     //your stuff

Open in new window

ChLaAuthor Commented:
That worked...Thank You

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now