Home RAP
New Blog Posts: Merging Reports - Part 1 and Part 2

TraValue - Change Constants by code in runtime

edited February 2006 in RAP
How can I change the value of GlobalConstants declared on a report on
runtime by code


Already I can acces the TdaDataModule and the TraConstProgram, I can see the
constants and the values
for example:

TraProgram(lConstDeclaration) := lCodeModule.GlobalConstProgram;
for i:=0 to lConstDeclaration.ConstantCount-1 do
begin
memo1.lines.add( lConstDeclaration.Constants[i].VarName );
memo1.lines.add( lConstDeclaration.Constants[i].Value.AsString );

//here how change the value ??
lConstDeclaration.Constants[i].Value := 55; //this is wrong, just an
example

end;

lCodeModule.BuildAll(True);


The Value property is a TraValue type. I need to create a TraValue object
??? and how assign the value ?


Thanks in advance
Jair Garza

Comments

  • edited February 2006

    a. One option is to use TraProgram.BodyText to read and write the constant
    declarations. For the global constant program, that BodayText string will
    return the entire declaration as a single string.

    const
    myFirstConstant = 5;
    mySecondConstant = 6;


    b. Another option is to use the TraProgram SourceLines property. This
    property is a TStrings.

    The global const program is internally a TraProgram whose source code looks
    like:

    procedure Constants;
    const
    myFirstConstant = 5;
    mySecondConstant = 6;
    begin

    end;





    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited February 2006

    Yes, I can do that, but I need to code my own parser procedure to
    manipulate that string (find, read, update, add or delete constants), so I
    was wondering, if ReportBuilder already do that parsing on the
    GlobalConstProgram I can just use it and change the values ..that's what I
    intended to do

    I'm testing changing the BodyText property ..

    Thanks
    Jair Garza


This discussion has been closed.