Solved

strcopy, strcat or whatever else ;)

Posted on 2003-11-16
6
664 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
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

867 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

25 Experts available now in Live!

Get 1:1 Help Now