[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

strcopy, strcat or whatever else ;)

Posted on 2003-11-16
6
Medium Priority
?
691 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
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: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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

656 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