Forum OpenACS Development: Basic tcl syntax question

Collapse
Posted by Devon Yoo on
I found several basic tcl syntax on the web but they are not working on my computer!!

----------------------------
proc foo {a b} {puts "$a $b"}
foo a b
----------------------------
->prints nothing

----------------------------
doc_return 200 "text/html" "Hello"
doc_return 200 "text/html" " World"
----------------------------
->this prints only "Hello"

What is wrong???

Collapse
Posted by Dave Bauer on
puts outputs to stdout and not to the web connection.

doc_return returns a document and closes the connection.

What are you trying to accomplish?

Collapse
Posted by Devon Yoo on
oh thx man
I have a lot of basic questions bcuz I just starting tcling.
It is very diff from PHP :(
Collapse
Posted by Jim Lynch on
keep on keepin on...

yes tcl is very different from php, and while you're coming up to speed you'll run into a buncha stuff...

proc foo {a b} { return "$a $b" }

doc_return 200 "text/plain" [foo "ayyy" "beee bayyybee"]

try something like that... or, use acs-templating:

foo.tcl:

ad_page_contract {test/exercise foo proc} -properties {
  out : onevalue
}

proc foo {a b} {return "$a $b"}

set out [foo "ayy bee" "bayyy bee"]

and, foo.adp:

@out@

-or-:

foo.adp (foo.tcl as above):

<master>

<ul>
  <li>@out@</li>
</ul>


Collapse
Posted by Jim Lynch on
Oh, and the template files go in yourOacsInstance/packages/yourPackage/www/

And if you have foo.tcl and foo.adp in there, then you would mount a new instance of yourpackage somewhere, using the site map, say it's mounted on /pkg.

then, you can access it as http://your.site/pkg/foo