Link to home
Start Free TrialLog in
Avatar of kinnon_2000
kinnon_2000

asked on

INI File readstring drops start and end quotes

Hello,

Working on a simple app that uses an inifile which contains search values within its ini strings.


In the ini file these look like this

               and words= 'Jim bob' 'sqirrel eater' 'big ol mammoth'
               or words= 'red jumper' 'big mistake'
the commands I use to read these are:
               ands:=ini.ReadString(checkname,'and words','');
               ors:=ini.ReadString(checkname,'or words','');

My problem is ands looks like
Jim bob' 'sqirrel eater' 'big ol mammoth
when I want it to look like
'Jim bob' 'sqirrel eater' 'big ol mammoth'

The start and end quotes get chopped off. The same happens for double quotes. For single word phrases, quotes may be excluded, so just sticking a quote on each end would cause my app to possibly take the entire string as a single search phrase.

If anyone can suggest a way round this without changing from quotes to something else like brackets I'd be very thankful.

All the best,
Kinnon_2000
Avatar of atul_parmar
atul_parmar
Flag of India image

Try
ands:=QuotedStr(ini.ReadString(checkname,'and words',''));
Or
ands:='''' +ini.ReadString(checkname,'and words','') + '''';
ASKER CERTIFIED SOLUTION
Avatar of Russell Libby
Russell Libby
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of kinnon_2000
kinnon_2000

ASKER

Many thanks for both your input. rllibby, in reply to your question about whether I'm writing the values or not, thats a yes. I think the double quotes idea is an acceptable solution. Eventually the values in the file will be dealt with using a nice setup application, but for now its all manual editing. I'm using an ini file rather than a database to keep things light. I fancied using an xml file but havn't used one witha delphi app before so skipped efficiency in place of speed. Maybe I'll change this later. Out of curiosity for future reference, do either of you folks know a good reference tutorial for working with xml using delphi? I havn't looked about yet but if you know one, that would be cool.

All the best,
Allan.