Home RAP

StringList Properties and default arrays

edited November 2007 in RAP
Hi,

I am trying to use the CommaText property of TStringList, but cannot. How
can I use it?

var

SL: TStringList;

begin

SL:= TStringList.Create;

SL.CommaText:= DBText1.Text;

//do something else here

SL.Free;

end;



It does not like the word CommaText.



Also



why can't i access the default array of the stringlist.

it does not like SL[I]

on another note, i get the same issue with string arrays

How can I do the the following

var

S: String;

I: Integer;

begin

S:= DBText1.Text;

for 0:= 1 to length(S) do

begin

Memo1.Lines.Add(S[I]);

end;

It does not like the S[I]

Why not?



Thanks



Shane

Comments

  • edited November 2007
    I have answered one of my questions

    "why can't i access the default array of the stringlist, it does not like
    SL[I]"

    it looks like i can use SL.Strings[I] with no problem.

    I still need help with the other questions

    Thanks

    Shane






  • edited November 2007
    Hi Shane,

    1. There is now a patch available for RB 10.07 that includes support for
    the CommaText property in RAP. If you would like this patch, please send a
    small email to support@digital-metaphors.com requesting it and we'll send it
    to you asap.

    2. In my testing with RB 10.07, the default "strings" (SL[i]) property of a
    StringList functions correctly in RAP. Be sure you are using the latest
    version of ReportBuilder.

    3. String arrays are not supported in RAP.

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited November 2007
    Ok, thank you!

    Interesting that String Arrays are not supported.

    Is there any way around doing something like

    for I:= 1 to Length(MYString) do
    C:= MyString[I]

    Thanks




  • edited November 2007
    Hi Shane,

    One workaround is to use a TStringList rather than a String type if you need
    to access it like an array. Another would be to create a pass thru function
    to return the given index in a string array.

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited November 2007
    Thank YoU!

    Shane


  • edited March 2008

    I have finally gotten a chance to get back to this outstanding issue...

    Although I (ValuTech) currently have a license for ReportBuilder 10.x, I am
    NOT currently using it.
    I am still using an older version of ReportBuilder.(i believe 7.x)

    Is there a way to add the CommaText property to the StringList - via
    registration?


    I tried descending from TraTStringsRTTI (but i get erros on compile)

    Thanks

    Shane


    see code below

    TVPTStringsRTTI = class(TraTStringsRTTI)
    public
    class procedure GetPropList(aClass: TClass; aPropList: TraPropList);
    override;
    class function RefClass: TClass; override;
    class function GetPropRec(aClass: TClass; const aPropName: String;
    var aPropRec: TraPropRec): Boolean; override;
    class function GetPropValue(aObject: TObject; const aPropName: String;
    var aValue): Boolean; override;
    class function SetPropValue(aObject: TObject; const aPropName: String;
    var aValue): Boolean; override;
    end;


    class procedure TVPTStringsRTTI.GetPropList(aClass: TClass; aPropList:
    TraPropList);
    begin
    inherited GetPropList(aClass, aPropList);
    aPropList.AddProp('CommaText');
    end;

    class function TVPTStringsRTTI.RefClass: TClass;
    begin
    Result := TStrings;
    end;

    class function TVPTStringsRTTI.GetPropRec(aClass: TClass; const aPropName:
    String;
    var aPropRec: TraPropRec):
    Boolean;
    begin
    Result := True;
    if ppEqual(aPropName, 'CommaText') then
    PropToRec(aPropName, daString, False, aPropRec)
    else
    Result := inherited GetPropRec(aClass, aPropName, aPropRec);
    end;

    class function TVPTStringsRTTI.GetPropValue(aObject: TObject;
    const aPropName: String; var aValue): Boolean;
    begin
    Result := True;
    if ppEqual(aPropName, 'CommaText') then
    String(aValue) := TStrings(aObject).CommaText
    else
    Result := inherited GetPropValue(aObject, aPropName, aValue);
    end;

    class function TVPTStringsRTTI.SetPropValue(aObject: TObject; const
    aPropName: String;
    var aValue): Boolean;
    begin
    Result := True;
    if ppEqual(aPropName, 'CommaText') then
    TStrings(aObject).CommaText := String(aValue)
    else
    Result := inherited SetPropValue(aObject, aPropName, aValue);
    end;


    Initialization
    raRegisterRTTI(TVPTStringsRTTI);
    finalization
    raUnregisterRTTI(TVPTStringsRTTI);




  • edited March 2008
    Hi Shane,

    Checking the source, it doesn't look like CommaText is added for the latest
    version either. I will add this for the next release. In the mean time, I
    would recommend creating a simple pass-thru function rather than creating
    and registering a new TraTStringsRTTI descendent.

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited March 2008
    Not sure what you mean by that....since I am creating the stringlist in the
    script

    procedure Memo1OnPrint;
    var
    SL: TStringList;
    begin
    SL:= TStringList.Create;
    SL.CommaText:= DBPipeLine1['User_Rights'];
    Memo1.Lines.Clear;
    for I:= 0 to SL.Count-1 do
    Memo1.Lines.Add(GetRrightSetString(SL[I]));
    SL.Free;
    end;

    Thanks

    Shane

  • edited March 2008
    A pass thru function is a way to call something from Delphi from within RAP.
    This essentially gives you the ability to execute any Delphi code in RAP.
    In your case, you would create a procedure that sends a TStringList and a
    String as a parameter and that function would assign the string to the
    CommaText property in Delphi.

    For examples of Pass-Thru Functions and how to create them please see the
    RAP demo located in the \RBuilder\Demos\0. RAP\... directory and see the RAP
    tutorials in the RB developer's guide.

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited March 2008
    This would require a re-compile of the original application.

    Hmmm, in that case, i have many options, however, i can't exercise that
    option.

    Shane


This discussion has been closed.