Solved

locate item in a string

Posted on 2002-07-10
7
141 Views
Last Modified: 2010-04-04
hello!

i need a easy and nice way of locating users and theire room

the format is something like this :

user:channel

this si a sample of how i should add them

var
i        : integer;
templist : TStringlist;
temp : string;
temp2 : string;
begin
  templist := TStringlist.Create;
  templist.CommaText := commanicks;

  for i := 0 to templist.Count -1 do
  begin
    temp := templist.Strings[i];
            if pos(temp[1],'@+') <> 0 then
               delete(temp,1,1);

    if frmmain.userlist.Strings.IndexOf(temp) = -1 then
      frmmain.userlist.Strings.Add (temp + '=' + channel);

  end;
  templist.free;

----

someone please help
0
Comment
Question by:joepezt
7 Comments
 
LVL 2

Expert Comment

by:mullet_attack
ID: 7144799
please, a better example of code, and what exactly is the problem/question?
0
 
LVL 7

Expert Comment

by:Cynna
ID: 7144849
joepezt,

I'm not sure if I get you right. If you just need quick way to extract channel
from list of strings with format "username=channel" then copy/paste this:


function UserChannel(list:TStringlist; user:String): String;
var s: String;
    i: Integer;
begin
   i:=list.IndexOf(user+'='); if i=-1 then Exit;
   s:=list.Strings[i];
   Result:=Copy(s, Pos('=',s)+1, Length(s));
end;

// DEMO:
//---------
procedure Tfrmmain.Button1Click(Sender: TObject);
var username: String;
begin
  username:='bla';
  Caption:='User: '+username+' is located in channel: '+UserChannel(frmmain.userlist, username);
end;


If this is not what you want, please be more detailed.
0
 
LVL 2

Expert Comment

by:mullet_attack
ID: 7144905
maybe...

function UserChannel(list:TStringlist; user:String): String;
var s: String;
   i: Integer;
begin
  result := list.strings.values[user];

//  i:=list.IndexOf(user+'='); if i=-1 then Exit;
//  s:=list.Strings[i];
//  Result:=Copy(s, Pos('=',s)+1, Length(s));
end;

0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 2

Author Comment

by:joepezt
ID: 7146687
i temporary solved this by doing:  

    if userlist.IndexOf(temp) = -1 then
    begin
      userlist.Add (temp);
      channellist.Add (channel);
    end;

but i would do nnot want to use 2 stringlists...

the problem is that if this list gets desynked, all channels nmight be out of synch with the userlist..


0
 
LVL 2

Expert Comment

by:mullet_attack
ID: 7147642
solved what exactly? I still don't understand what your question is !
0
 

Expert Comment

by:modulo
ID: 8475184
Dear expert(s),

A request has been made to close this Q in CS:
http://www3.experts-exchange.com/Community_Support/Q_20607180.html

Without a response in 72 hrs, a moderator will finalize this question by:

 - Saving this Q as a PAQ and refunding the points to the questionner

When you agree or disagree, please add a comment here.

Thank you.

modulo

Community Support Moderator
Experts Exchange
0
 

Accepted Solution

by:
modulo earned 0 total points
ID: 8501148
Saving this Q as a PAQ and refunding the 50 points to the questionner

modulo

Community Support Moderator
Experts Exchange
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
A short film showing how OnPage and Connectwise integration works.
Delivering innovative fully-managed cloud services for mission-critical applications requires expertise in multiple areas plus vision and commitment. Meet a few of the people behind the quality services of Concerto.

929 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now