Question : Delphi - Load Strings from RCData?

Hello Experts,
I Compilled Strings in a ressource file:
RC_RCData.txt >    Hello\nHow\nAre\nYou

1           RCData      RC_RCData.txt

i attched this ressource file to my project,
now i want to read and get those strings separated in vars like this:

Example:
var  
 String1, String2, String3 : String;
Begin
   String1:= ReadStringFromRCDATA('1');// Hello
   String2:= ReadStringFromRCDATA('2');// How
   String3:= ReadStringFromRCDATA('3');//Are
   ....
end;

Dont ask me to use StringTable
because i tryed it and its worked but the problem i am changing the strings in the Client Program
and till now did not found how to update String Table Ressource in Delphi
the question is here: http://www.experts-exchange.com/Programming/Languages/Pascal/Delphi/Q_26352150.html

anyway i asked this question because i changed my strings to RCDATA ressoource not String Table Ressource.


Good Luck Guys

Answer : Delphi - Load Strings from RCData?

Load your Resource from a ResourceStream as EscuroAnjo hinted, then create a TStrings descendant that will load its content from that stream. You will then have all your strings in each line of TStrings, ready to be accessed.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
Procedure LoadStringTable(TableName:String;SL:TStrings);
var
 RS: TResourceStream;
begin
 RS := TResourceStream.Create( HInstance, TableName, RT_RCDATA);  
 try
  SL.LoadFromStream(RS); 
 finally
  RS.Free;
 end;
end;

// Usage :

var  
 String1, String2, String3 : String;
 StrList:TStringList;
Begin
 StrList:=TStringList.Create;
 try
  LoadStringTable('RCData',StrList);
  String1:= StrList[0];
  String2:= StrList[1];
  String3:= StrList[2];
 finally
  StrList.Free;
 end;
end;
Random Solutions  
 
programming4us programming4us