?
Solved

ini file reading

Posted on 2006-06-20
8
Medium Priority
?
357 Views
Last Modified: 2010-05-18
Hello all

I have an application that needs to read an ini file.

It needs to compare a number (a count) from an SQL statement to a number stored in the ini file. The number in the ini file will be stored next to an identifier such as  'client=3' and if possible i want to set how many places along the string the number will be in the ini file eg 'client=12*3*456' so the number i want for comparrison is still number 3

any help appreciated
0
Comment
Question by:Paul-Brooks
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 14

Expert Comment

by:DragonSlayer
ID: 16940952
i don't get you :-(
0
 

Author Comment

by:Paul-Brooks
ID: 16940969
OK

If i have an ini file that contains the line client=3, how do i read that in my delphi app and as a secondary question can i hide that number(the 3) in a string and count the places to find it as a sort of encryption

Cheers
0
 
LVL 4

Accepted Solution

by:
David_Ward earned 2000 total points
ID: 16941028
uses TiniFiles;

Function GetMyINI_Data(IniFname,SectionName,KeyName: String): Integer;
var
  ThisINI:    TIniFile;
  s1:           String;
begin
  result:=-1;
  ThisINI:=TiniFile.Create(IniFname);

  try
    s1:=ThisINI.ReadString(SectionName,KeyName,'-1');
    if s1<>'-1'  then
      begin
          result:=StrToIntDef(s1,-2);

          // decode "whatever" you did to encode the number before you saved it in the INI file

      end;

   
  finally
    ThisINI.free;
   
  end;

end;
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 4

Expert Comment

by:David_Ward
ID: 16941033
// decode "whatever" you did to encode the number before you saved it in the INI file
// i.e.
result:=(result div 12) div 456;
0
 
LVL 4

Expert Comment

by:David_Ward
ID: 16941052
>>if possible i want to set how many places along the string the number will be in the ini file eg 'client=12*3*456' so the number i want for comparrison is still number 3

I really would not bother with something like this, I would just mathematically alter the number according to -some- formula

Some.INI
[Some.Section]
Client=16416

// 16416/12/456=3


0
 
LVL 10

Expert Comment

by:atul_parmar
ID: 16941065
Or to decode the hidden number from string you can use
  s := '12*3*456';
  s := Copy(s, pos('*', s)+1, length(s));
  s := copy(s, 1, pos('*', s)-1);
0
 

Author Comment

by:Paul-Brooks
ID: 16941103
David

I am using Delphi 2005 and when i put the TiniFiles in the uses, the project will not compile with a cant resolve unit name error

0
 
LVL 4

Expert Comment

by:David_Ward
ID: 16941140
yea, sorry, the unit name is;

IniFiles

not "T"
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses
Course of the Month13 days, 21 hours left to enroll

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question