?
Solved

New to Delphi, need some help...

Posted on 1998-10-25
10
Medium Priority
?
150 Views
Last Modified: 2010-08-05
Hi, I'm a VB programmer that is switching to Delphi and theres a few things I need some help with.  

1. In VB I used to use Left,Mid, & Right.  I couldn't find anything like that in Delphi... maybe I missed it, I don't know.  Is there anything like that in Delphi?

2. I used to use instr in VB to locate text in a string, it worked great because I could tell it where to start.  The closest thing I found in Delphi is the Pos... is there anything in Delphi thats like instr?

ohh yeah, and one last question... using a listbox how can I get the total items in it?

Thanks for the help.
0
Comment
Question by:dokken
[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
10 Comments
 
LVL 4

Expert Comment

by:dwwang
ID: 1344262
I would like to say Delphi is a "REAL" low level programming language so there are not somany build-in functions as VB has.

You can either write some by yourself or lookup on the internet.
0
 
LVL 3

Expert Comment

by:bryan7
ID: 1344263
1: Do you mean Left$ Mid$ and Right$ ?
2: What's "Pos" for ?

maybe I could write some functions that do the same.

bryan
0
 
LVL 3

Accepted Solution

by:
bryan7 earned 240 total points
ID: 1344264
try this:

function Mid(Finalstring,Initialstring: string; InitialPos,NumberOfCharacters: Integer): string;
Var a: Integer;
begin
FinalString:= '';
for a:= InitialPos to (InitialPos + NumberOfCharacters -1 ) do
      FinalString:= FinalString + Initialstring[a];
end;

function Left(Finalstring,Initialstring: string; NumberOfCharacters: Integer): string;
Var a: Integer;
begin
FinalString:= '';
for a:= 1 to NumberOfCharacters do
      FinalString:= FinalString + Initialstring[a];
end;

function Right(Finalstring,Initialstring: string; NumberOfCharacters: Integer): string;
Var a: Integer;
begin
FinalString:= '';
for a:= Length(InitialString) downto (Length(InitialString) - NumberOfCharacters +1) do
      FinalString:= FinalString + Initialstring[a];
end;

bryan
           
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 17

Expert Comment

by:inthe
ID: 1344265
Hello Dokken

pos returns the index value of the first character in a specified substring that occurs in a givin string.  

and  for the listbox items it's :
edit1.text:= inttostr(listbox1.items.count);

¤¤¤¤¤¤¤ InThe ¤¤¤¤¤¤¤
0
 
LVL 3

Expert Comment

by:bryan7
ID: 1344266
And to locate text in a string:

function LocateText(TotalText,TextToFind: string, PosFrom,PosFound: Integer): Integer;
Var a,b: Integer;
      c: string;
begin
c:= '';
For  a:=  PosFrom to length(TotalText) do
    begin
          c:='';
          for b:= a to (a+length(TextToFind)-1) do
               c:= c+TotalText[b];
          if c= TextToFind then
                begin
                       PosFound:= a;
                       Exit;
                end;
    end;
PosFound:= 0;
end;

If it returns 0, then the text wasn't found.
I've not tested it with Delphi, but it should work, as Delphi is somehow like Pascal.

I'll test it later and fix any bugs if there are..

bryan


0
 

Author Comment

by:dokken
ID: 1344267
Thanks for the help, you guys answered my questions perfectly!
0
 
LVL 3

Expert Comment

by:bryan7
ID: 1344268
hey dokken,

Soon I'll start with VB5, then we could exchange some knowledges about
 Delphi - VB5, what do you think ?

Give me your email, if you want so.

bryan
0
 

Author Comment

by:dokken
ID: 1344269
bryan7,

That would be cool, whats your email address?

dokken
0
 
LVL 3

Expert Comment

by:bryan7
ID: 1344270
AerithFantasy@earthling.net

AERISFANTASY@EARTHLING.NET

send a checking email.

bryan =)

0
 
LVL 3

Expert Comment

by:bryan7
ID: 1344271
sorry,  I mean,

AERITHFANTASY@EARTHLING.NET

bryan

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

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…
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…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Suggested Courses

764 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