[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

locate item in a string

Posted on 2002-07-10
7
Medium Priority
?
149 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
[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
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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

649 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