?
Solved

strcopy, strcat or whatever else ;)

Posted on 2003-11-16
6
Medium Priority
?
685 Views
Last Modified: 2010-04-05
Right for now ive got the following:

type tLStr = record
              msgID,
              msg : String;
end;

type tLang = object

              StrM : array[1..200] of tLStr;

              private lang : String;

              public procedure SetLang( pLang : String );
              public procedure Load;
              public function GetMessage(MsgID : Byte) : String;
end;

procedure tLang.Load;
var lngFile : TextFile;
    buf : String;
    IntBuf : PChar;
    HalfLen : Integer;
    cnt : Byte;
begin
 AssignFile(lngFile,'lang/'+Lang+'.lang');
 Reset(lngFile);
 cnt:=1;
 while cnt <= 5 do
  begin
  ReadLn(lngFile,buf);
  if  buf[1] <> '/' then
   begin
    GetMem(IntBuf,5);
    IntBuf^ := Chr(0);
    StrLCat(IntBuf, PChar(buf), 3);
    StrM[cnt].msgID:=IntBuf;
    FreeMem(IntBuf);
    HalfLen := Length(buf)-4;
    GetMem(IntBuf,(HalfLen+2));
    IntBuf^ := Chr(0);
    StrLCopy(IntBuf, PChar(buf)+4, HalfLen);
    {****}
    FreeMem(IntBuf);
   end;
   Inc(cnt);
  end;
  Close(lngFile);
end;

{****} <--- what goes in here to assign whatever is in IntBuf to StrM[cnt].msg ???

I just cant seem to figure out how this works...
Need some help plz
0
Comment
Question by:Professor
[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
6 Comments
 
LVL 5

Expert Comment

by:snehanshu
ID: 9761719
Perhaps:
    StrLCopy(Pchar(StrM[cnt].msg), IntBuf, HalfLen);
???
...Shu
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 9761903
hmm,

looks like you come from java-side.
i guess there is terrible easier way in delphi.

just describe what you want to do,
and provide a sample of your filecontent

meikl ;-)
0
 
LVL 17

Accepted Solution

by:
geobul earned 500 total points
ID: 9762224
Hi,

StrM[cnt].msg := IntBuf;

I think but kretzschmar is right. There are easier ways like:

...
  if  buf[1] <> '/' then
  begin
     StrM[cnt].msgID:=Copy(buf,1,3);
     StrM[cnt].msg:=Copy(buf,4,Length(buf));
  end;
  Inc(cnt);
...

Regards, Geo
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 17

Expert Comment

by:geobul
ID: 9762243
StrM[cnt].msg:=Copy(buf,4,Length(buf));
should be:
StrM[cnt].msg:=Copy(buf,5,Length(buf));
in the code above because as I can see you are skipping the fourth character.
0
 

Author Comment

by:Professor
ID: 9762666
Thank You Everybody ... I kinda got the point ...

And, no Im not from the Java-side ... I actually did program pascal at some point but its been a while.
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 9762753
>no Im not from the Java-side
was just a guess :-))
0

Featured Post

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.

Question has a verified solution.

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

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
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…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

752 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