Solved

strcopy, strcat or whatever else ;)

Posted on 2003-11-16
6
679 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 125 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
Independent Software Vendors: 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

Independent Software Vendors: 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!

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…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …

724 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