Forum OpenACS Q&A: is it possible to call a tcl proc from adp page ?


is there a way to call a proc from an adp page, that is if my proc is in the tcl directory ?

is this possible ?


Posted by abbas beginner on
just to make it more clear

i am getting a dbmulirow result

and before i print them out onto the page i have to modify the string via a regexp - i have a proc that does it but how can i call this from the adp page directly ?

hope ive been clear


Posted by Malte Sussdorff on
Is there a reason why you do not want to do it in the .tcl page?
Posted by Alfred Werner on
<%= [my_proc params] %>  and
<% [my_proc params] %>

print results or don't

might be 'old school' :) but it works for me.

Lots of %this_stuff% these days. Guess that's when the flow is reversed - tcl runs then you ns_adp_parse ..

Posted by Robert Locke on

Expounding on Malte's suggestion, you can do this:

db_multirow users fetch_users {
    select email from parties
} {
    regsub (.*)@(.*) $email {\1 at \2} email

This changes the value of the email variable in the multirow and you would not need to run any Tcl in your adp.

In other words, would contain "ache9829 at" in your case.  No Tcl needed.

Hope this helps.

Posted by abbas beginner on
thanks for that

the reason why i need it from the adp page is because

i have my adp setting up a grid for my results from db_multirow already and thought if i can call the function from within the adp page itll just be easier

thanks guys

Posted by abbas beginner on

i just saw ur post now

:) problem is solved , look like the better way of doing it


Posted by Dirk Gomez on
I've been missing a warning here :)

Don't call tcl procs from your adp page. It's a leftover from old days and somehow defies the whole sense of a templating sense. Code goes into the tcl file, markup into the adp file. (Well, that's a rule of thumb at least!)