Solved

strcopy, strcat or whatever else ;)

Posted on 2003-11-16
6
661 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
6 Comments
 
LVL 5

Expert Comment

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

Expert Comment

by:kretzschmar
Comment Utility
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
Comment Utility
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 17

Expert Comment

by:geobul
Comment Utility
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
Comment Utility
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
Comment Utility
>no Im not from the Java-side
was just a guess :-))
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

762 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

15 Experts available now in Live!

Get 1:1 Help Now