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
Solved

locate item in a string

Posted on 2002-07-10
7
143 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
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.

 
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

Suggested Solutions

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

840 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