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

Global variables in rtm file

edited April 2002 in General
Hi!
I wonder if it is possible in Delphi source to get hold of the global
variables declared in the rtm file. The reason I ask this is I need to pass
certain information (not DB related) from Delphi into the Report Builder
during printing. Thanks

Thomas Liaw

Comments

  • edited April 2002
    There was a thread on creating a RAP global variable in Delphi code, in the
    RAP newsgroup. Search for the threads dated 3/16/2002 and 3/17/2002 which
    show how to create a global variable and how to initialize them by creating
    a global OnCreate event handler in RAP.


    Cheers,

    Jim Bennett
    Digital Metaphors

  • edited April 2002
    Thanks you Jim for your reply. I am sorry I am probably came to the wrong
    user group for the question. I have found the threads you mentioned. The
    thread contains code how to create a global variable but not saying anything
    about how to initialize it. Actually, I am not so much of wanting to create
    a global variable. Instead, I just want to assign a value into the global
    variable declared in the rtm file in my Delphi code, before I can do that, I
    guess I need to retrieve such global variable (and probably need to cast it
    to the appropriate data type). Any help will be appreciated.

    Thomas Liaw


  • edited April 2002
    I'll try to explain this a little differently. Imagine that you have two
    applications. The first application is able to compile the other. Let's
    say that you have a class in a pas file of the to-be-compiled application,
    but you need to change one of the class' private varaibles which is
    initialized in the class' constructor. The catch is that you need to do
    this from the other application, since the other application calculates the
    value that is to be set. The way to do this is to open the pas file and
    change the initialized value string, before the pas file is compiled.

    The same approach should be taken if you use RAP this way. The RAP programs
    are simply text lines which get compiled (interpreted). This text is what
    needs to be changed so that the new value will be included every time RAP
    compiles the global OnCreate event handler "program." You'll only need to
    set the text once, and it will be persistent as you run the report multiple
    times. In the example code you've found, you'll see that the program is
    extracted and then the lines are cleared. Instead of clearing the lines,
    you just need to parse through these lines and find the variable that you
    want to change. Once you've found the line which sets the variable value,
    simply set that line of code to a new string which sets it to the new value.


    Cheers,

    Jim Bennett
    Digital Metaphors

  • edited April 2002
    Thanks Jim for being patient with me. I know what to do now.

This discussion has been closed.