Solved

locate item in a string

Posted on 2002-07-10
7
140 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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

707 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

17 Experts available now in Live!

Get 1:1 Help Now